From d12a9a253328f3923aba1aa766040909ebedda4c Mon Sep 17 00:00:00 2001 From: jianhengyi Date: Fri, 30 Jun 2017 16:18:38 +0800 Subject: [PATCH 01/53] 0.10.19 --- pom.xml | 2 +- .../java/com/baidubce/AbstractBceClient.java | 26 +- .../com/baidubce/BceClientConfiguration.java | 15 +- src/main/java/com/baidubce/BceConstants.java | 2 +- .../java/com/baidubce/auth/SignOptions.java | 7 +- .../java/com/baidubce/http/BceHttpClient.java | 35 +- .../baidubce/http/IdleConnectionReaper.java | 6 +- src/main/java/com/baidubce/model/User.java | 4 +- .../baidubce/services/batch/BatchClient.java | 19 +- .../services/batch/model/ListJobsRequest.java | 2 +- .../bmr/model/CreateClusterRequest.java | 2 +- .../bmr/model/ListClustersRequest.java | 2 +- .../services/bmr/model/ListStepsRequest.java | 2 +- .../com/baidubce/services/bos/BosClient.java | 5 + .../CompleteMultipartUploadResponse.java | 4 + .../services/bos/model/CopyObjectRequest.java | 51 +- .../CopyObjectResponseWithExceptionInfo.java | 25 +- .../bos/model/GetBucketAclResponse.java | 4 + .../services/bos/model/GetObjectRequest.java | 17 +- .../baidubce/services/bos/model/Grant.java | 4 +- .../baidubce/services/bos/model/Grantee.java | 3 +- .../bos/model/ListObjectsResponse.java | 36 +- .../services/bos/model/ObjectMetadata.java | 39 +- .../bos/model/ResponseHeaderOverrides.java | 23 +- .../bos/model/SetBucketAclRequest.java | 29 +- .../com/baidubce/services/cdn/CdnClient.java | 606 +++++++++++++++++- .../baidubce/services/cdn/model/CacheTTL.java | 118 ++++ .../services/cdn/model/CdnResponse.java | 13 + .../cdn/model/CreateDomainRequest.java | 36 ++ .../cdn/model/CreateDomainResponse.java | 28 +- .../cdn/model/DeleteDomainRequest.java | 58 ++ .../cdn/model/DeleteDomainResponse.java | 21 + .../cdn/model/DisableDomainRequest.java | 73 +++ .../cdn/model/DisableDomainResponse.java | 20 + .../baidubce/services/cdn/model/Domain.java | 10 + .../cdn/model/EnableDomainRequest.java | 58 ++ .../cdn/model/EnableDomainResponse.java | 20 + .../services/cdn/model/FlowRegionData.java | 83 +++ .../cdn/model/GetCacheQuotaRequest.java | 34 + .../cdn/model/GetCacheQuotaResponse.java | 81 +++ .../cdn/model/GetDomainCacheTTLRequest.java | 89 +++ .../cdn/model/GetDomainCacheTTLResponse.java | 52 ++ .../cdn/model/GetDomainConfigRequest.java | 73 +++ .../cdn/model/GetDomainConfigResponse.java | 204 ++++++ .../cdn/model/GetDomainLogRequest.java | 108 ++++ .../cdn/model/GetDomainLogResponse.java | 41 ++ .../cdn/model/GetPrefetchStatusRequest.java | 63 +- .../cdn/model/GetPrefetchStatusResponse.java | 25 + .../cdn/model/GetPurgeStatusRequest.java | 59 ++ .../cdn/model/GetPurgeStatusResponse.java | 19 + .../cdn/model/GetStatAvgSpeedRequest.java | 147 +++++ .../cdn/model/GetStatAvgSpeedResponse.java | 40 ++ .../cdn/model/GetStatFlowRequest.java | 102 ++- .../cdn/model/GetStatFlowResponse.java | 10 + .../cdn/model/GetStatHitRateRequest.java | 131 ++++ .../cdn/model/GetStatHitRateResponse.java | 40 ++ .../cdn/model/GetStatHttpCodeRequest.java | 146 +++++ .../cdn/model/GetStatHttpCodeResponse.java | 40 ++ .../services/cdn/model/GetStatPvRequest.java | 161 +++++ .../services/cdn/model/GetStatPvResponse.java | 40 ++ .../cdn/model/GetStatSrcFlowRequest.java | 131 ++++ .../cdn/model/GetStatSrcFlowResponse.java | 40 ++ .../cdn/model/GetStatTopRefererRequest.java | 132 ++++ .../cdn/model/GetStatTopRefererResponse.java | 40 ++ .../cdn/model/GetStatTopUrlRequest.java | 131 ++++ .../cdn/model/GetStatTopUrlResponse.java | 40 ++ .../services/cdn/model/GetStatUvRequest.java | 146 +++++ .../services/cdn/model/GetStatUvResponse.java | 40 ++ .../cdn/model/HttpCodeRegionData.java | 69 ++ .../baidubce/services/cdn/model/IpACL.java | 78 +++ .../services/cdn/model/JsonObject.java | 8 + .../services/cdn/model/KvCounter.java | 51 ++ .../cdn/model/ListDomainsRequest.java | 18 +- .../cdn/model/ListDomainsResponse.java | 59 +- .../baidubce/services/cdn/model/LogEntry.java | 89 +++ .../services/cdn/model/OriginPeer.java | 47 +- .../services/cdn/model/PrefetchRequest.java | 38 +- .../services/cdn/model/PrefetchResponse.java | 10 + .../services/cdn/model/PrefetchStatus.java | 35 +- .../services/cdn/model/PrefetchTask.java | 14 + .../services/cdn/model/PurgeRequest.java | 32 +- .../services/cdn/model/PurgeResponse.java | 10 + .../services/cdn/model/PurgeStatus.java | 34 + .../services/cdn/model/PurgeTask.java | 24 + .../services/cdn/model/PvRegionData.java | 75 +++ .../services/cdn/model/RefererACL.java | 95 +++ .../model/SetDomainCacheFullUrlRequest.java | 89 +++ .../model/SetDomainCacheFullUrlResponse.java | 20 + .../cdn/model/SetDomainCacheTTLRequest.java | 112 ++++ .../cdn/model/SetDomainCacheTTLResponse.java | 20 + .../cdn/model/SetDomainIpACLRequest.java | 97 +++ .../cdn/model/SetDomainIpACLResponse.java | 20 + .../cdn/model/SetDomainLimitRateRequest.java | 97 +++ .../cdn/model/SetDomainLimitRateResponse.java | 22 + .../cdn/model/SetDomainOriginRequest.java | 99 +++ .../cdn/model/SetDomainOriginResponse.java | 20 + .../cdn/model/SetDomainRefererACLRequest.java | 97 +++ .../model/SetDomainRefererACLResponse.java | 20 + .../cdn/model/StatAvgSpeedDetails.java | 50 ++ .../services/cdn/model/StatFlowDetails.java | 63 +- .../cdn/model/StatHitRateDetails.java | 50 ++ .../cdn/model/StatHttpCodeDetails.java | 64 ++ .../services/cdn/model/StatPvDetails.java | 77 +++ .../cdn/model/StatTopRefererDetails.java | 52 ++ .../services/cdn/model/StatTopUrlDetails.java | 52 ++ .../services/cdn/model/StatUvDetails.java | 50 ++ .../com/baidubce/services/doc/DocClient.java | 40 +- .../services/doc/model/DocumentImage.java | 77 +++ .../doc/model/GetDocumentImagesRequest.java | 56 ++ .../doc/model/GetDocumentImagesResponse.java | 61 ++ .../doc/model/RegisterDocumentRequest.java | 96 ++- .../baidubce/services/iotdm/IotDmClient.java | 7 +- .../services/iotdm/IotDmClientHelper.java | 31 +- .../services/iotdm/IotDmV2Client.java | 158 +++++ .../iotdm/model/CreateEndpointRequest.java | 53 ++ .../iotdm/model/CreateEndpointResponse.java | 49 ++ .../iotdm/model/EndpointInResponse.java | 47 ++ .../iotdm/model/GetEndpointsResponse.java | 39 ++ .../services/iothub/IotHubClient.java | 5 +- .../com/baidubce/services/lss/LssClient.java | 498 ++++++++++---- .../services/lss/model/AntiLeech.java | 35 + .../baidubce/services/lss/model/Audio.java | 49 +- .../com/baidubce/services/lss/model/Auth.java | 35 + .../baidubce/services/lss/model/AuthInfo.java | 51 ++ .../com/baidubce/services/lss/model/Bos.java | 35 + .../services/lss/model/CodecOptions.java | 15 +- .../lss/model/CreatePresetRequest.java | 111 +++- .../lss/model/CreateStreamResponse.java | 171 ++++- .../lss/model/DeleteStreamRequest.java | 122 ++++ .../services/lss/model/GetStreamResponse.java | 213 +++++- ...UpdateStreamDestinationPushUrlRequest.java | 150 +++++ .../lss/model/UpdateStreamPresetsRequest.java | 153 +++++ .../lss/model/UpdateStreamPullUrlRequest.java | 150 +++++ .../model/UpdateStreamRecordingRequest.java | 150 +++++ .../model/UpdateStreamWatermarkRequest.java | 150 +++++ .../baidubce/services/media/MediaClient.java | 6 +- .../services/modbus/ModbusClient.java | 428 +++++++++++++ .../services/modbus/ModbusClientHelper.java | 93 +++ .../services/modbus/model/BaseResponse.java | 31 + .../model/CreateCustomFieldRequest.java | 43 ++ .../modbus/model/CreateDataDescRequest.java | 203 ++++++ .../modbus/model/DataDescRequest.java | 73 +++ .../modbus/model/DataDescription.java | 201 ++++++ .../modbus/model/ListCustomFieldRespons.java | 34 + .../modbus/model/ListDataDescResponse.java | 82 +++ .../model/ListParserObjectResponse.java | 82 +++ .../services/modbus/model/ListResponse.java | 83 +++ .../services/modbus/model/ParserObject.java | 154 +++++ .../modbus/model/ParserObjectRequest.java | 57 ++ .../modbus/model/QueryDataDescResponse.java | 200 ++++++ .../modbus/model/UpdateDataDescRequest.java | 212 ++++++ .../modbus/model/device/CreateDevice.java | 111 ++++ .../services/modbus/model/device/Device.java | 146 +++++ .../modbus/model/device/DeviceResponse.java | 147 +++++ .../model/device/ListDeviceRequest.java | 77 +++ .../model/device/ListDeviceResponse.java | 69 ++ .../model/device/UpdateDeviceRequest.java | 99 +++ .../model/gateway/CreateGatewayRequest.java | 39 ++ .../modbus/model/gateway/Gateway.java | 126 ++++ .../modbus/model/gateway/GatewayResponse.java | 128 ++++ .../model/gateway/ListGatewayRequest.java | 59 ++ .../model/gateway/ListGatewayResponse.java | 69 ++ .../model/gateway/UpdateGatewayRequest.java | 39 ++ .../CreateParserObjectRequest.java | 58 ++ .../parserobject/ParserObjectResponse.java | 117 ++++ .../parserobject/UpdateParserObject.java | 70 ++ .../model/pullrule/CreatePullRuleRequest.java | 71 ++ .../pullrule/CreatePullRuleResponse.java | 22 + .../modbus/model/pullrule/DeviceUnitDto.java | 46 ++ .../model/pullrule/ListPullRuleRequest.java | 69 ++ .../model/pullrule/ListPullRuleResponse.java | 71 ++ .../modbus/model/pullrule/PullRule.java | 106 +++ .../model/pullrule/PullRuleResponse.java | 97 +++ .../pullrule/PullRuleResponseWithDevice.java | 16 + .../model/pullrule/UpdatePullRuleRequest.java | 17 + .../services/moladb/MolaDbClient.java | 2 +- .../moladb/model/BatchGetItemRequest.java | 2 +- .../moladb/model/BatchGetItemResponse.java | 17 +- .../moladb/model/CreateTableRequest.java | 88 +-- .../moladb/model/GetInstanceResponse.java | 19 +- .../services/moladb/model/GetItemRequest.java | 1 - .../moladb/model/GetItemResponse.java | 4 +- .../baidubce/services/moladb/model/Key.java | 2 +- .../moladb/model/KeySchemaElement.java | 2 +- .../moladb/model/KeysAndAttributes.java | 6 +- .../moladb/model/ListInstancesResponse.java | 4 +- .../moladb/model/ListTablesResponse.java | 4 +- .../services/moladb/model/PutItemRequest.java | 71 +- .../services/moladb/model/QueryRequest.java | 98 +-- .../services/moladb/model/QueryResponse.java | 2 +- .../moladb/model/UpdateItemRequest.java | 6 +- .../services/ruleengine/RuleEngineClient.java | 3 +- .../ruleengine/model/Destination.java | 6 +- .../ruleengine/model/DestinationKind.java | 25 +- .../services/ses/SesClientSupport.java | 4 +- .../com/baidubce/services/sms/SmsClient.java | 32 +- .../services/sms/SmsClientSupport.java | 4 +- .../services/sms/model/TemplateStatus.java | 2 +- .../services/tsdb/TsdbAdminClient.java | 3 +- .../baidubce/services/tsdb/TsdbClient.java | 20 + .../baidubce/services/tsdb/TsdbConstants.java | 12 + .../services/tsdb/model/Aggregator.java | 29 +- .../services/tsdb/model/Datapoint.java | 19 + .../services/tsdb/model/GetFieldsRequest.java | 31 + .../tsdb/model/GetFieldsResponse.java | 34 + .../baidubce/services/tsdb/model/Group.java | 4 +- .../baidubce/services/tsdb/model/Query.java | 21 +- .../baidubce/services/tsdb/model/Result.java | 12 +- .../services/tsdb/model/ValueFilter.java | 4 +- .../com/baidubce/services/vod/VodClient.java | 23 +- .../vod/model/InternalCreateMediaRequest.java | 122 +++- .../java/com/baidubce/util/HttpUtils.java | 1 - .../java/com/baidubce/util/Mimetypes.java | 11 +- 213 files changed, 12633 insertions(+), 645 deletions(-) create mode 100644 src/main/java/com/baidubce/services/cdn/model/CacheTTL.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DeleteDomainRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DeleteDomainResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DisableDomainRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DisableDomainResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/EnableDomainRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/EnableDomainResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/FlowRegionData.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainCacheTTLRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainCacheTTLResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainConfigRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainConfigResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainLogRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetDomainLogResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatHitRateRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatHitRateResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatPvRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatPvResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatUvRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/GetStatUvResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/HttpCodeRegionData.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/IpACL.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/KvCounter.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/LogEntry.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/PvRegionData.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/RefererACL.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainOriginRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainOriginResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatAvgSpeedDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatHitRateDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatHttpCodeDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatPvDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatTopRefererDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatTopUrlDetails.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/StatUvDetails.java create mode 100644 src/main/java/com/baidubce/services/doc/model/DocumentImage.java create mode 100644 src/main/java/com/baidubce/services/doc/model/GetDocumentImagesRequest.java create mode 100644 src/main/java/com/baidubce/services/doc/model/GetDocumentImagesResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/IotDmV2Client.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/CreateEndpointRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/CreateEndpointResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/EndpointInResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/GetEndpointsResponse.java create mode 100644 src/main/java/com/baidubce/services/lss/model/DeleteStreamRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/UpdateStreamDestinationPushUrlRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/UpdateStreamPresetsRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/UpdateStreamPullUrlRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/UpdateStreamRecordingRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/UpdateStreamWatermarkRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/ModbusClient.java create mode 100755 src/main/java/com/baidubce/services/modbus/ModbusClientHelper.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/BaseResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/CreateCustomFieldRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/CreateDataDescRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/DataDescRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/DataDescription.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ListCustomFieldRespons.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ListDataDescResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ListParserObjectResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ListResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ParserObject.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/ParserObjectRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/QueryDataDescResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/UpdateDataDescRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/CreateDevice.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/Device.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/DeviceResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/ListDeviceRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/ListDeviceResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/device/UpdateDeviceRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/CreateGatewayRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/gateway/UpdateGatewayRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/parserobject/CreateParserObjectRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/parserobject/ParserObjectResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/parserobject/UpdateParserObject.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/CreatePullRuleResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/DeviceUnitDto.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleRequest.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/ListPullRuleResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/PullRule.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponse.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/PullRuleResponseWithDevice.java create mode 100755 src/main/java/com/baidubce/services/modbus/model/pullrule/UpdatePullRuleRequest.java create mode 100644 src/main/java/com/baidubce/services/tsdb/model/GetFieldsRequest.java create mode 100644 src/main/java/com/baidubce/services/tsdb/model/GetFieldsResponse.java diff --git a/pom.xml b/pom.xml index bd7dc87c..5d8c03c0 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.17 + 0.10.19 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html diff --git a/src/main/java/com/baidubce/AbstractBceClient.java b/src/main/java/com/baidubce/AbstractBceClient.java index c8065049..8be3fcd6 100644 --- a/src/main/java/com/baidubce/AbstractBceClient.java +++ b/src/main/java/com/baidubce/AbstractBceClient.java @@ -28,11 +28,9 @@ /** * 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. @@ -88,20 +86,19 @@ 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. + * 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[])} + * {@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 IllegalArgumentException if the endpoint specified in the client configuration is not a valid URI. */ - public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, + public AbstractBceClient(BceClientConfiguration config, HttpResponseHandler[] responseHandlers, boolean isHttpAsyncPutEnabled) { this.serviceId = this.computeServiceId(); this.config = config; @@ -111,7 +108,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 +123,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 +160,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 +169,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 responseClass the response class. + * @param the type of response * @return the final response object. */ protected T invokeHttpClient(InternalRequest request, Class responseClass) { @@ -189,7 +191,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 @@ -215,7 +216,7 @@ private String computeServiceId() { /** * 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 +227,6 @@ private String computeServiceId() { /** * Returns the default target service endpoint. - * *

* The endpoint will be in the form of "http(s)://[.].baidubce.com". * diff --git a/src/main/java/com/baidubce/BceClientConfiguration.java b/src/main/java/com/baidubce/BceClientConfiguration.java index e100b41e..54608f1f 100644 --- a/src/main/java/com/baidubce/BceClientConfiguration.java +++ b/src/main/java/com/baidubce/BceClientConfiguration.java @@ -213,6 +213,7 @@ public BceClientConfiguration(BceClientConfiguration other) { * In this case endpoint should be changed while other attributes keep same. * * @param other the configuration to copy settings from. + * @param endpoint the endpoint */ public BceClientConfiguration(BceClientConfiguration other, String endpoint) { this.endpoint = endpoint; @@ -308,7 +309,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 +328,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. @@ -382,7 +381,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 +392,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 +414,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 +425,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. * @@ -748,7 +743,7 @@ public String getEndpoint() { * * @param endpoint the service endpoint URL to which the client will connect. * @throws IllegalArgumentException if endpoint is not a valid URL. - * @throws NullPointerException if endpoint is null. + * @throws NullPointerException if endpoint is null. */ public void setEndpoint(String endpoint) { checkNotNull(endpoint, "endpoint should not be null."); @@ -762,7 +757,7 @@ public void setEndpoint(String endpoint) { * @param endpoint the service endpoint URL to which the client will connect. * @return the updated configuration instance. * @throws IllegalArgumentException if endpoint is not a valid URL. - * @throws NullPointerException if endpoint is null. + * @throws NullPointerException if endpoint is null. */ public BceClientConfiguration withEndpoint(String endpoint) { this.setEndpoint(endpoint); @@ -782,7 +777,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 +789,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. * @@ -856,5 +849,5 @@ public String toString() { + 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..db6c5f45 100644 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -16,5 +16,5 @@ * 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.19"; } diff --git a/src/main/java/com/baidubce/auth/SignOptions.java b/src/main/java/com/baidubce/auth/SignOptions.java index aa722819..8016e787 100644 --- a/src/main/java/com/baidubce/auth/SignOptions.java +++ b/src/main/java/com/baidubce/auth/SignOptions.java @@ -19,10 +19,9 @@ /** * Options for signing the request. - * *

* There are 3 options available: - * + *
* * * @@ -49,7 +48,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 { @@ -130,7 +128,6 @@ 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; @@ -142,5 +139,5 @@ public String toString() { + timestamp + ",\n expirationInSeconds=" + expirationInSeconds + "]"; } - + } diff --git a/src/main/java/com/baidubce/http/BceHttpClient.java b/src/main/java/com/baidubce/http/BceHttpClient.java index fe304962..2af7a11e 100644 --- a/src/main/java/com/baidubce/http/BceHttpClient.java +++ b/src/main/java/com/baidubce/http/BceHttpClient.java @@ -102,7 +102,7 @@ public class BceHttpClient { * Internal client for sending HTTP requests */ protected CloseableHttpClient httpClient; - + /** * Client configuration options, such as proxy settings, max retries, etc. */ @@ -123,8 +123,8 @@ public class BceHttpClient { * settings, etc), and request metric collector. * * @param config Configuration options specifying how this client will communicate with BCE (ex: proxy settings, - * retry count, etc.). - * + * 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) { @@ -164,8 +164,10 @@ 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.). + * 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) { @@ -176,12 +178,13 @@ public BceHttpClient(BceClientConfiguration config, Signer signer, boolean isHtt /** * Executes the request and returns the result. * - * @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 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 - * - * @throws com.baidubce.BceClientException If any errors are encountered on the client while making the - * request or handling the response. + * @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. * @throws com.baidubce.BceServiceException If any errors occurred in BCE while processing the request. */ public T execute(InternalRequest request, Class responseClass, @@ -193,7 +196,7 @@ public T execute(InternalRequest request, Class< credentials = request.getCredentials(); } long delayForNextRetryInMillis = 0; - for (int attempt = 1; ; ++attempt) { + for (int attempt = 1; ; ++attempt) { HttpRequestBase httpRequest = null; CloseableHttpResponse httpResponse = null; CloseableHttpAsyncClient httpAsyncClient = null; @@ -202,7 +205,7 @@ public T execute(InternalRequest request, Class< if (credentials != null) { this.signer.sign(request, credentials); } - + requestLogger.debug("Sending Request: {}", request); httpRequest = this.createHttpRequest(request); @@ -213,13 +216,13 @@ public T execute(InternalRequest request, Class< 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(); @@ -361,7 +364,7 @@ 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 { ConnectingIOReactor ioReactor = @@ -398,7 +401,7 @@ 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) { HttpAsyncClientBuilder builder = HttpAsyncClients.custom().setConnectionManager(connectionManager); int socketBufferSizeInBytes = this.config.getSocketBufferSizeInBytes(); diff --git a/src/main/java/com/baidubce/http/IdleConnectionReaper.java b/src/main/java/com/baidubce/http/IdleConnectionReaper.java index e1c12234..d1533411 100644 --- 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/model/User.java b/src/main/java/com/baidubce/model/User.java index bfdf07f1..bba75eba 100644 --- 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/batch/BatchClient.java b/src/main/java/com/baidubce/services/batch/BatchClient.java index c4ec5cf9..5c65414a 100644 --- 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 index 14e6eaa3..1cf87f5c 100644 --- 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/bmr/model/CreateClusterRequest.java b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java index 71b042fa..08daac1a 100644 --- a/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/CreateClusterRequest.java @@ -133,7 +133,7 @@ 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) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java index 600e5440..4e5ef5da 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListClustersRequest.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 ListClustersRequest */ public ListClustersRequest withMarker(String marker) { diff --git a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java index ded14eab..55a5bda4 100644 --- a/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java +++ b/src/main/java/com/baidubce/services/bmr/model/ListStepsRequest.java @@ -64,7 +64,7 @@ public ListStepsRequest withClusterId(String clusterId) { * Configure the marker for the query request. * The marker marks the starting point for the query. * - * @param marker + * @param marker the marker * @return ListStepsRequest */ public ListStepsRequest withMarker(String marker) { diff --git a/src/main/java/com/baidubce/services/bos/BosClient.java b/src/main/java/com/baidubce/services/bos/BosClient.java index 417fc942..1d05e673 100644 --- a/src/main/java/com/baidubce/services/bos/BosClient.java +++ b/src/main/java/com/baidubce/services/bos/BosClient.java @@ -76,6 +76,11 @@ public class BosClient extends AbstractBceClient { */ public static final String STORAGE_CLASS_STANDARD_IA = "STANDARD_IA"; + /** + * Cold access BOS storage class + */ + public static final String STORAGE_CLASS_COLD = "COLD"; + /** * Constructs a new client to invoke service methods on Bos. */ diff --git a/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java b/src/main/java/com/baidubce/services/bos/model/CompleteMultipartUploadResponse.java index f22be91f..d5e04355 100644 --- 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/CopyObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectRequest.java index 8b1bb22f..0b4c7d8c 100644 --- 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; @@ -73,9 +72,9 @@ public class CopyObjectRequest extends GenericObjectRequest { * 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 +107,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 +234,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 +245,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 +255,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 +265,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 +276,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 +296,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 +309,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 +320,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 +328,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 +341,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 +350,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,19 +360,20 @@ 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) { diff --git a/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java b/src/main/java/com/baidubce/services/bos/model/CopyObjectResponseWithExceptionInfo.java index 4f5fbce6..e9360555 100644 --- 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/GetBucketAclResponse.java b/src/main/java/com/baidubce/services/bos/model/GetBucketAclResponse.java index f10ba262..4aaad14e 100644 --- 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; diff --git a/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java b/src/main/java/com/baidubce/services/bos/model/GetObjectRequest.java index 2bb66b6d..9bb64b95 100644 --- 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: *

*/ public class GetObjectRequest extends GenericObjectRequest { @@ -42,7 +40,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 +84,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 +98,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 +116,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. * diff --git a/src/main/java/com/baidubce/services/bos/model/Grant.java b/src/main/java/com/baidubce/services/bos/model/Grant.java index a5065a6b..9cfb3ae4 100644 --- a/src/main/java/com/baidubce/services/bos/model/Grant.java +++ b/src/main/java/com/baidubce/services/bos/model/Grant.java @@ -29,7 +29,7 @@ public Grant() { /** * Constructs a new Grant object using the specified grantee and permission objects. * - * @param grantee The grantee being granted a permission by this grant. + * @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) { @@ -59,6 +59,7 @@ 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); @@ -87,6 +88,7 @@ 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); diff --git a/src/main/java/com/baidubce/services/bos/model/Grantee.java b/src/main/java/com/baidubce/services/bos/model/Grantee.java index 83b92feb..90a62fad 100644 --- a/src/main/java/com/baidubce/services/bos/model/Grantee.java +++ b/src/main/java/com/baidubce/services/bos/model/Grantee.java @@ -27,7 +27,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 +55,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/ListObjectsResponse.java b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java index 9495a901..ffe882c9 100644 --- a/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java +++ b/src/main/java/com/baidubce/services/bos/model/ListObjectsResponse.java @@ -99,7 +99,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 +106,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 +125,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 +143,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; @@ -174,12 +172,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 +199,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 +223,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 +238,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 +248,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 +258,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 +278,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,7 +293,7 @@ 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") public void setTruncated(boolean isTruncated) { diff --git a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java index 8130d70d..9dce5bcd 100644 --- a/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java +++ b/src/main/java/com/baidubce/services/bos/model/ObjectMetadata.java @@ -135,7 +135,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."); @@ -147,8 +147,8 @@ public void setUserMetadata(Map userMetadata) { * object. If the entry in the custom user-metadata map already contains the * 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. + * @param key The key for the custom user metadata entry. Note that the key + * 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 +157,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 +207,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 +253,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 +264,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 +277,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 +291,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 +303,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 +315,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 +326,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 +343,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 +358,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 +368,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 +380,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 +393,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; diff --git a/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java b/src/main/java/com/baidubce/services/bos/model/ResponseHeaderOverrides.java index a010a56c..e566c198 100644 --- 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/SetBucketAclRequest.java b/src/main/java/com/baidubce/services/bos/model/SetBucketAclRequest.java index 957564f9..5a102f85 100644 --- 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/cdn/CdnClient.java b/src/main/java/com/baidubce/services/cdn/CdnClient.java index 05b10c8d..57448bbe 100644 --- a/src/main/java/com/baidubce/services/cdn/CdnClient.java +++ b/src/main/java/com/baidubce/services/cdn/CdnClient.java @@ -39,17 +39,63 @@ import com.baidubce.services.cdn.model.ListDomainsRequest; import com.baidubce.services.cdn.model.ListDomainsResponse; +import com.baidubce.services.cdn.model.OriginPeer; import com.baidubce.services.cdn.model.PrefetchRequest; import com.baidubce.services.cdn.model.PrefetchResponse; +import com.baidubce.services.cdn.model.PrefetchTask; import com.baidubce.services.cdn.model.PurgeRequest; import com.baidubce.services.cdn.model.PurgeResponse; +import com.baidubce.services.cdn.model.PurgeTask; +import com.baidubce.services.cdn.model.SetDomainCacheFullUrlRequest; +import com.baidubce.services.cdn.model.SetDomainCacheFullUrlResponse; +import com.baidubce.services.cdn.model.SetDomainCacheTTLRequest; +import com.baidubce.services.cdn.model.SetDomainCacheTTLResponse; +import com.baidubce.services.cdn.model.SetDomainIpACLRequest; +import com.baidubce.services.cdn.model.SetDomainIpACLResponse; +import com.baidubce.services.cdn.model.SetDomainLimitRateRequest; +import com.baidubce.services.cdn.model.SetDomainLimitRateResponse; +import com.baidubce.services.cdn.model.SetDomainOriginRequest; +import com.baidubce.services.cdn.model.SetDomainOriginResponse; +import com.baidubce.services.cdn.model.SetDomainRefererACLRequest; +import com.baidubce.services.cdn.model.SetDomainRefererACLResponse; import com.baidubce.services.cdn.model.GetPurgeStatusRequest; import com.baidubce.services.cdn.model.GetPurgeStatusResponse; +import com.baidubce.services.cdn.model.GetStatAvgSpeedRequest; +import com.baidubce.services.cdn.model.GetStatAvgSpeedResponse; +import com.baidubce.services.cdn.model.CreateDomainRequest; +import com.baidubce.services.cdn.model.CreateDomainResponse; +import com.baidubce.services.cdn.model.DeleteDomainRequest; +import com.baidubce.services.cdn.model.DeleteDomainResponse; +import com.baidubce.services.cdn.model.EnableDomainRequest; +import com.baidubce.services.cdn.model.EnableDomainResponse; +import com.baidubce.services.cdn.model.GetCacheQuotaRequest; +import com.baidubce.services.cdn.model.GetCacheQuotaResponse; +import com.baidubce.services.cdn.model.GetDomainCacheTTLRequest; +import com.baidubce.services.cdn.model.GetDomainCacheTTLResponse; 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.GetStatHitRateRequest; +import com.baidubce.services.cdn.model.GetStatHitRateResponse; +import com.baidubce.services.cdn.model.GetStatHttpCodeRequest; +import com.baidubce.services.cdn.model.GetStatHttpCodeResponse; +import com.baidubce.services.cdn.model.GetStatPvRequest; +import com.baidubce.services.cdn.model.GetStatPvResponse; +import com.baidubce.services.cdn.model.GetStatSrcFlowRequest; +import com.baidubce.services.cdn.model.GetStatSrcFlowResponse; +import com.baidubce.services.cdn.model.GetStatTopRefererRequest; +import com.baidubce.services.cdn.model.GetStatTopRefererResponse; +import com.baidubce.services.cdn.model.GetStatTopUrlRequest; +import com.baidubce.services.cdn.model.GetStatTopUrlResponse; +import com.baidubce.services.cdn.model.GetStatUvRequest; +import com.baidubce.services.cdn.model.GetStatUvResponse; +import com.baidubce.services.cdn.model.DisableDomainRequest; +import com.baidubce.services.cdn.model.DisableDomainResponse; +import com.baidubce.services.cdn.model.GetDomainConfigRequest; +import com.baidubce.services.cdn.model.GetDomainConfigResponse; +import com.baidubce.services.cdn.model.GetDomainLogRequest; +import com.baidubce.services.cdn.model.GetDomainLogResponse; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; import com.baidubce.util.DateUtils; @@ -81,6 +127,11 @@ public class CdnClient extends AbstractBceClient { */ private static final String CACHE = "cache"; + /** + * The common URI prefix for log operation. + */ + private static final String LOG = "log"; + /** * Generate signature with specified headers. */ @@ -109,6 +160,84 @@ 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) { + 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); + } + + /** + * Enable an existing domain acceleration. + * + * @param domain The specified domain name. + */ + public void enableDomain(String domain) { + enableDomain(new EnableDomainRequest().withDomain(domain)); + } + + /** + * Enable an existing domain acceleration. + * + * @param request The request containing user-defined domain information. + * @return Result of the enableDomain operation returned by the service. + */ + public EnableDomainResponse enableDomain(EnableDomainRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DOMAIN, request.getDomain()); + internalRequest.addParameter("enable", ""); + return invokeHttpClient(internalRequest, EnableDomainResponse.class); + } + + /** + * Disable an existing domain acceleration. + * + * @param domain Name of the domain. + */ + public void disableDomain(String domain) { + disableDomain(new DisableDomainRequest().withDomain(domain)); + } + + /** + * Disable an existing domain acceleration. + * + * @param request The request containing user-defined domain information. + * @return Result of the disableDomain operation returned by the service. + */ + public DisableDomainResponse disableDomain(DisableDomainRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.POST, DOMAIN, request.getDomain()); + internalRequest.addParameter("disable", ""); + return invokeHttpClient(internalRequest, DisableDomainResponse.class); + } + + /** + * Delete an existing domain acceleration. + * + * @param domain Name of the domain. + */ + public void deleteDomain(String domain) { + deleteDomain(new DeleteDomainRequest().withDomain(domain)); + } + + /** + * Delete an existing domain acceleration + * + * @param request The request containing user-defined domain information. + * @return Result of the deleteDomain operation returned by the service. + */ + public DeleteDomainResponse deleteDomain(DeleteDomainRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.DELETE, DOMAIN, request.getDomain()); + return invokeHttpClient(internalRequest, DeleteDomainResponse.class); + } + /** * Returns a list of all CDN domains that the authenticated sender of the request owns. * @@ -129,23 +258,225 @@ public ListDomainsResponse listDomains(ListDomainsRequest request) { InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN); return invokeHttpClient(internalRequest, ListDomainsResponse.class); } + + /** + * Get detailed information of a domain. + * + * @param domain Name of the domain. + * @return getDomainConfig of the getDomainConfig operation returned by the service. + */ + public GetDomainConfigResponse getDomainConfig(String domain) { + return getDomainConfig(new GetDomainConfigRequest().withDomain(domain)); + } + + /** + * Get detailed information of a domain. + * + * @param request The request containing all of the options related to the domain. + * @return getDomainConfig of the getDomainConfig operation returned by the service. + */ + public GetDomainConfigResponse getDomainConfig(GetDomainConfigRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN, request.getDomain(), "config"); + return invokeHttpClient(internalRequest, GetDomainConfigResponse.class); + } + + /** + * Update origin of specified domain acceleration. + * + * @param domain Name of the domain. + * @param peer The peer address of new origin. + */ + public void setDomainOrigin(String domain, String peer) { + List origin = new ArrayList(); + origin.add(new OriginPeer().withPeer(peer)); + SetDomainOriginRequest request = new SetDomainOriginRequest() + .withDomain(domain) + .withOrigin(origin); + setDomainOrigin(request); + } + + /** + * 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 SetDomainOriginResponse setDomainOrigin(SetDomainOriginRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("origin",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainOriginResponse.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) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheTTL",""); + return invokeHttpClient(internalRequest, GetDomainCacheTTLResponse.class); + } + + /** + * 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 SetDomainCacheTTLResponse setDomainCacheTTL(SetDomainCacheTTLRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheTTL",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainCacheTTLResponse.class); + } + + /** + * Update cache policy of specified domain acceleration. + * + * @param domain Name of the domain. + * @param setting For true, treat the full URL as unique cache id, otherwise + * ignore query string parameters. + */ + public void setDomainCacheFullUrl(String domain, boolean setting) { + SetDomainCacheFullUrlRequest request = new SetDomainCacheFullUrlRequest() + .withDomain(domain); + request.setCacheFullUrl(setting); + setDomainCacheFullUrl(request); + } + + /** + * 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 setDomainCacheFullUrl operation returned by the service. + */ + public SetDomainCacheFullUrlResponse setDomainCacheFullUrl(SetDomainCacheFullUrlRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("cacheFullUrl",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainCacheFullUrlResponse.class); + } + + /** + * 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 SetDomainRefererACLResponse setDomainRefererACL(SetDomainRefererACLRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("refererACL",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainRefererACLResponse.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 SetDomainIpACLResponse setDomainIpACL(SetDomainIpACLRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("ipACL",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainIpACLResponse.class); + } + + /** + * Set the rate limit of specified domain acceleration. + * + * @param domain Name of the domain. + * @param limitRate The limit of downloading rate, in Bytes/s. + */ + public void setDomainLimitRate(String domain, int limitRate) { + SetDomainLimitRateRequest request = new SetDomainLimitRateRequest() + .withDomain(domain) + .withLimitRate(limitRate); + setDomainLimitRate(request); + } + + /** + * Set the rate limit of specified domain acceleration. + * + * @param request The request containing all of the options related to the update request. + * @return Result of the setDomainLimitRate operation returned by the service. + */ + public SetDomainLimitRateResponse setDomainLimitRate(SetDomainLimitRateRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("limitRate",""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetDomainLimitRateResponse.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 The task id + * @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) { InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CACHE, "prefetch"); this.attachRequestToBody(request, internalRequest); return this.invokeHttpClient(internalRequest, PrefetchResponse.class); } + + /** + * 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 The task id + * @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) { InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, CACHE, "purge"); @@ -215,6 +546,37 @@ public GetPrefetchStatusResponse getPrefetchStatus(GetPrefetchStatusRequest requ return this.invokeHttpClient(internalRequest, GetPrefetchStatusResponse.class); } + /** + * Get pv statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatPvResponse getStatPv(GetStatPvRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "pv"); + + 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())); + } + + if (request.isWithRegion()) { + internalRequest.addParameter("withRegion", ""); + } + return this.invokeHttpClient(internalRequest, GetStatPvResponse.class); + } + /** * Get flow statistics with specified attributes. * @@ -239,9 +601,243 @@ public GetStatFlowResponse getStatFlow(GetStatFlowRequest request) { if (request.getPeriod() != null) { internalRequest.addParameter("period", String.valueOf(request.getPeriod())); } + + if (request.isWithRegion()) { + internalRequest.addParameter("withRegion", ""); + } return this.invokeHttpClient(internalRequest, GetStatFlowResponse.class); } + /** + * Get origin flow statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatSrcFlowResponse getStatSrcFlow(GetStatSrcFlowRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "srcflow"); + + 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, GetStatSrcFlowResponse.class); + } + /** + * Get hit rate statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatHitRateResponse getStatHitRate(GetStatHitRateRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "hitrate"); + + 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, GetStatHitRateResponse.class); + } + + /** + * Get http code statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatHttpCodeResponse getStatHttpCode(GetStatHttpCodeRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "httpcode"); + + 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())); + } + + if (request.isWithRegion()) { + internalRequest.addParameter("withRegion", ""); + } + + return this.invokeHttpClient(internalRequest, GetStatHttpCodeResponse.class); + } + + /** + * Get top url statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatTopUrlResponse getStatTopUrl(GetStatTopUrlRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "topn", "url"); + + 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, GetStatTopUrlResponse.class); + } + + /** + * Get top http referer statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatTopRefererResponse getStatTopReferer(GetStatTopRefererRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "topn", "referer"); + + 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, GetStatTopRefererResponse.class); + } + + /** + * Get uv statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatUvResponse getStatUv(GetStatUvRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "uv"); + + 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, GetStatUvResponse.class); + } + + /** + * Get average speed statistics with specified attributes. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetStatAvgSpeedResponse getStatAvgSpeed(GetStatAvgSpeedRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, STAT, "avgspeed"); + + 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, GetStatAvgSpeedResponse.class); + } + + /** + * Get cache operation quota. + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetCacheQuotaResponse getCacheQuota() { + GetCacheQuotaRequest request = new GetCacheQuotaRequest(); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CACHE, "quota"); + return this.invokeHttpClient(internalRequest, GetCacheQuotaResponse.class); + } + + /** + * Get URLs of log files + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics + */ + public GetCacheQuotaResponse getCacheQuota(GetCacheQuotaRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, CACHE, "quota"); + return this.invokeHttpClient(internalRequest, GetCacheQuotaResponse.class); + } + + /** + * + */ + public GetDomainLogResponse getDomainLog(GetDomainLogRequest request) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, LOG, request.getDomain(), "log"); + return this.invokeHttpClient(internalRequest, GetDomainLogResponse.class); + } + /** * Creates and initializes a new request object for the specified resource. * diff --git a/src/main/java/com/baidubce/services/cdn/model/CacheTTL.java b/src/main/java/com/baidubce/services/cdn/model/CacheTTL.java new file mode 100644 index 00000000..91205617 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/CacheTTL.java @@ -0,0 +1,118 @@ +/* + * 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 + * + * Cache TTL policy + */ +public class CacheTTL extends JsonObject { + private String type; + private String value; + private Integer ttl; + private Integer weight; + + /** + * @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; + } +} 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..b71108e8 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/CdnResponse.java @@ -17,12 +17,25 @@ 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 java.lang.Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java index da31ab63..d1274591 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/CreateDomainRequest.java @@ -27,49 +27,85 @@ public class CreateDomainRequest extends AbstractBceRequest { private List origin; 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 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; } + /** + * (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 java.lang.Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java index 0abf1e8e..90ee19d5 100644 --- a/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/CreateDomainResponse.java @@ -12,14 +12,24 @@ */ package com.baidubce.services.cdn.model; -import com.baidubce.model.AbstractBceResponse; - -public class CreateDomainResponse extends AbstractBceResponse { - @Override - public String toString() { - final StringBuilder sb = new StringBuilder(); - sb.append("class CreateDomainResponse {\n"); - sb.append("}\n"); - return sb.toString(); +/** + * @author yixing + * + */ +public class CreateDomainResponse extends CdnResponse { + private String cname; + + /** + * @return cname + */ + public String getCname() { + return cname; + } + + /** + * @param cname + */ + public void setCname(String cname) { + this.cname = cname; } } diff --git a/src/main/java/com/baidubce/services/cdn/model/DeleteDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/DeleteDomainRequest.java new file mode 100644 index 00000000..13d6ac53 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +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/DeleteDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/DeleteDomainResponse.java new file mode 100644 index 00000000..2f7a6626 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/DeleteDomainResponse.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.cdn.model; + +/** + * @author yixing + * + */ +public class DeleteDomainResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/DisableDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/DisableDomainRequest.java new file mode 100644 index 00000000..09b4b828 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +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 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/cdn/model/DisableDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/DisableDomainResponse.java new file mode 100644 index 00000000..8e03daaf --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/DisableDomainResponse.java @@ -0,0 +1,20 @@ +/* + * 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 DisableDomainResponse extends CdnResponse { +} 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/EnableDomainRequest.java b/src/main/java/com/baidubce/services/cdn/model/EnableDomainRequest.java new file mode 100644 index 00000000..830b7352 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +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/EnableDomainResponse.java b/src/main/java/com/baidubce/services/cdn/model/EnableDomainResponse.java new file mode 100644 index 00000000..cac5558d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/EnableDomainResponse.java @@ -0,0 +1,20 @@ +/* + * 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 EnableDomainResponse extends CdnResponse { +} 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/GetCacheQuotaRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaRequest.java new file mode 100644 index 00000000..aa775e0d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaRequest.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.cdn.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetCacheQuotaRequest extends AbstractBceRequest { + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetCacheQuotaRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} 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..528c2e2d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetCacheQuotaResponse.java @@ -0,0 +1,81 @@ +/* + * 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; + private Integer urlRemain; + private Integer dirQuota; + 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/GetDomainCacheTTLRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainCacheTTLRequest.java new file mode 100644 index 00000000..202f98f3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +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 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/cdn/model/GetDomainCacheTTLResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainCacheTTLResponse.java new file mode 100644 index 00000000..a3192ba4 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetDomainCacheTTLResponse.java @@ -0,0 +1,52 @@ +/* + * 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; + +/** + * @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/GetDomainConfigRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainConfigRequest.java new file mode 100644 index 00000000..0fb8e8cb --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +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 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/cdn/model/GetDomainConfigResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainConfigResponse.java new file mode 100644 index 00000000..5f9db581 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetDomainConfigResponse.java @@ -0,0 +1,204 @@ +/* + * 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.Date; +import java.util.List; + +/** + * @author yixing + * + */ +public class GetDomainConfigResponse extends CdnResponse { + private String domain; + private String cname; + private String status; + private Date createTime; + private Date lastModifyTime; + private boolean isBan; + private boolean cacheFullUrl; + private List origin; + private RefererACL refererACL; + private IpACL ipACL; + private List cacheTTL; + private Integer limitRate; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return cname + */ + public String getCname() { + return cname; + } + + /** + * @param cname + */ + public void setCname(String cname) { + this.cname = cname; + } + + /** + * @return status + */ + public String getStatus() { + return status; + } + + /** + * @param status + */ + public void setStatus(String status) { + this.status = status; + } + + /** + * @return createTime + */ + public Date getCreateTime() { + return createTime; + } + + /** + * @param createTime + */ + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + /** + * @return lastModifyTime + */ + public Date getLastModifyTime() { + return lastModifyTime; + } + + /** + * @param lastModifyTime + */ + public void setLastModifyTime(Date lastModifyTime) { + this.lastModifyTime = lastModifyTime; + } + + /** + * @return if is baned + */ + public boolean isBan() { + return isBan; + } + + /** + * @param isBan + */ + public void setBan(boolean isBan) { + this.isBan = isBan; + } + + /** + * @return if cache full url + */ + public boolean isCacheFullUrl() { + return cacheFullUrl; + } + + /** + * @param cacheFullUrl + */ + public void setCacheFullUrl(boolean cacheFullUrl) { + this.cacheFullUrl = cacheFullUrl; + } + + /** + * @return origin + */ + public List getOrigin() { + return origin; + } + + /** + * @param origin + */ + public void setOrigin(List origin) { + this.origin = origin; + } + + /** + * @return ipACL + */ + public IpACL getIpACL() { + return ipACL; + } + + /** + * @param ipACL + */ + public void setIpACL(IpACL ipACL) { + this.ipACL = ipACL; + } + + /** + * @return refererACL + */ + public RefererACL getRefererACL() { + return refererACL; + } + + /** + * @param refererACL + */ + public void setRefererACL(RefererACL refererACL) { + this.refererACL = refererACL; + } + + /** + * @return cacheTTL + */ + public List getCacheTTL() { + return cacheTTL; + } + + /** + * @param cacheTTL + */ + public void setCacheTTL(List cacheTTL) { + this.cacheTTL = cacheTTL; + } + + /** + * @return limitRate + */ + public Integer getLimitRate() { + return limitRate; + } + + /** + * @param limitRate + */ + public void setLimitRate(Integer limitRate) { + this.limitRate = limitRate; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetDomainLogRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainLogRequest.java new file mode 100644 index 00000000..d453734e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetDomainLogRequest.java @@ -0,0 +1,108 @@ +/* + * 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.Date; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetDomainLogRequest extends AbstractBceRequest { + private String domain; + private Date startTime; + private Date endTime; + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetDomainLogRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetDomainLogRequest withEndTime(Date 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; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetDomainLogRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetDomainLogResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetDomainLogResponse.java new file mode 100644 index 00000000..3dbecc6a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetDomainLogResponse.java @@ -0,0 +1,41 @@ +/* + * 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 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/GetPrefetchStatusRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java index 62ab0617..ba62d20a 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusRequest.java @@ -19,6 +19,10 @@ import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +/** + * @author yixing + * + */ public class GetPrefetchStatusRequest extends AbstractBceRequest { private String marker; private String id; @@ -27,77 +31,126 @@ 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; } + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override public GetPrefetchStatusRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see java.lang.Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java index 304516f3..9f8123e9 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPrefetchStatusResponse.java @@ -18,6 +18,10 @@ import com.fasterxml.jackson.annotation.JsonProperty; +/** + * @author yixing + * + */ public class GetPrefetchStatusResponse extends CdnResponse { private String marker; private String nextMarker; @@ -25,30 +29,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/GetPurgeStatusRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java index a805f40b..ccf98751 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusRequest.java @@ -19,6 +19,10 @@ import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +/** + * @author yixing + * + */ public class GetPurgeStatusRequest extends AbstractBceRequest { private String marker; private String id; @@ -27,30 +31,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 +84,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 java.lang.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..003a87ee 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetPurgeStatusResponse.java @@ -18,28 +18,47 @@ 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/GetStatAvgSpeedRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedRequest.java new file mode 100644 index 00000000..b1be8eaa --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedRequest.java @@ -0,0 +1,147 @@ +/* + * 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.Date; +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 GetStatAvgSpeedRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatAvgSpeedRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatAvgSpeedRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatAvgSpeedRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatAvgSpeedRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatAvgSpeedRequest 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/cdn/model/GetStatAvgSpeedResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedResponse.java new file mode 100644 index 00000000..b0793cef --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatAvgSpeedResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatAvgSpeedResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java index ba5cea9f..8f364eab 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatFlowRequest.java @@ -19,73 +19,133 @@ import com.baidubce.util.JsonUtils; import com.fasterxml.jackson.core.JsonProcessingException; +/** + * @author yixing + * + */ public class GetStatFlowRequest extends AbstractBceRequest { - private String domain; - private Date endTime; private Date startTime; private Integer period; + private boolean withRegion; + /** + * @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 GetStatFlowRequest withDomain(String domain) { setDomain(domain); return this; } - - public void setEndTime(Date t) { - this.endTime = t; - } - + + /** + * @return endTime + */ public Date getEndTime() { return endTime; } - - public void setStartTime(Date t) { - this.startTime = t; + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; } + public GetStatFlowRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ public Date getStartTime() { return startTime; } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + /** + * @param startTime + * @return returns this object + */ public GetStatFlowRequest withStartTime(Date startTime) { - this.setStartTime(startTime); + setStartTime(startTime); return this; } - public GetStatFlowRequest withEndTime(Date endTime) { - this.setEndTime(endTime); - System.out.println(this.endTime); - return this; + /** + * @return withRegion + */ + public boolean isWithRegion() { + return withRegion; } - + + /** + * @param withRegion + */ + public void setWithRegion(boolean withRegion) { + this.withRegion = withRegion; + } + + /** + * @return period + */ public Integer getPeriod() { return period; } - public void setPeriod(int period) { + /** + * @param period + */ + public void setPeriod(Integer period) { this.period = period; } - - public GetStatFlowRequest withPeriod(int period) { - this.setPeriod(period); + + /** + * @param period + * @return returns this object + */ + public GetStatFlowRequest withPeriod(Integer period) { + setPeriod(period); return this; } + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ @Override public GetStatFlowRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see java.lang.Object#toString() + */ @Override public String toString() { try { diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java index 7c0c6ec8..a9e5b996 100644 --- a/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatFlowResponse.java @@ -16,14 +16,24 @@ import java.util.ArrayList; import java.util.List; +/** + * @author yixing + * + */ public class GetStatFlowResponse extends CdnResponse { private List details = new ArrayList(); + /** + * @param details + */ public void setDetails(List details) { this.details = details; } + /** + * @return details + */ public List getDetails() { return details; } diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateRequest.java new file mode 100644 index 00000000..56825efb --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateRequest.java @@ -0,0 +1,131 @@ +/* + * 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.Date; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetStatHitRateRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatHitRateRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatHitRateRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatHitRateRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatHitRateRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatHitRateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateResponse.java new file mode 100644 index 00000000..167921cf --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatHitRateResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatHitRateResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeRequest.java new file mode 100644 index 00000000..79462bed --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeRequest.java @@ -0,0 +1,146 @@ +/* + * 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.Date; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetStatHttpCodeRequest extends AbstractBceRequest { + private String domain; + private Date endTime; + private Date startTime; + private Integer period; + private boolean withRegion; + + /** + * @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 GetStatHttpCodeRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatHttpCodeRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatHttpCodeRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatHttpCodeRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * @return withRegion + */ + public boolean isWithRegion() { + return withRegion; + } + + /** + * @param withRegion + */ + public void setWithRegion(boolean withRegion) { + this.withRegion = withRegion; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatHttpCodeRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeResponse.java new file mode 100644 index 00000000..093ce2e2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatHttpCodeResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatHttpCodeResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatPvRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatPvRequest.java new file mode 100644 index 00000000..9c3d3506 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatPvRequest.java @@ -0,0 +1,161 @@ +/* + * 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.Date; +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 GetStatPvRequest extends AbstractBceRequest { + private String domain; + private Date endTime; + private Date startTime; + private Integer period; + private boolean withRegion; + + /** + * @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 GetStatPvRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatPvRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatPvRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return withRegion + */ + public boolean isWithRegion() { + return withRegion; + } + + /** + * @param withRegion + */ + public void setWithRegion(boolean withRegion) { + this.withRegion = withRegion; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatPvRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatPvRequest 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/cdn/model/GetStatPvResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatPvResponse.java new file mode 100644 index 00000000..ab8a5133 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatPvResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatPvResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowRequest.java new file mode 100644 index 00000000..39cf058c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowRequest.java @@ -0,0 +1,131 @@ +/* + * 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.Date; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetStatSrcFlowRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatSrcFlowRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatSrcFlowRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatSrcFlowRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatSrcFlowRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatSrcFlowRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowResponse.java new file mode 100644 index 00000000..55fae131 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatSrcFlowResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatSrcFlowResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererRequest.java new file mode 100644 index 00000000..163e2324 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererRequest.java @@ -0,0 +1,132 @@ +/* + * 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.Date; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetStatTopRefererRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatTopRefererRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatTopRefererRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatTopRefererRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatTopRefererRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatTopRefererRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} + diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererResponse.java new file mode 100644 index 00000000..23c8880f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatTopRefererResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatTopRefererResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlRequest.java new file mode 100644 index 00000000..25f049a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlRequest.java @@ -0,0 +1,131 @@ +/* + * 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.Date; +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * @author yixing + * + */ +public class GetStatTopUrlRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatTopUrlRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatTopUrlRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatTopUrlRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatTopUrlRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatTopUrlRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlResponse.java new file mode 100644 index 00000000..515510a2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatTopUrlResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatTopUrlResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/GetStatUvRequest.java b/src/main/java/com/baidubce/services/cdn/model/GetStatUvRequest.java new file mode 100644 index 00000000..e57b6bb5 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatUvRequest.java @@ -0,0 +1,146 @@ +/* + * 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.Date; +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 GetStatUvRequest extends AbstractBceRequest { + private String domain; + 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; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public GetStatUvRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return endTime + */ + public Date getEndTime() { + return endTime; + } + + /** + * @param endTime + */ + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + /** + * @param endTime + * @return returns this object + */ + public GetStatUvRequest withEndTime(Date endTime) { + setEndTime(endTime); + return this; + } + + /** + * @return startTime + */ + public Date getStartTime() { + return startTime; + } + + /** + * @param startTime + */ + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + /** + * @param startTime + * @return returns this object + */ + public GetStatUvRequest withStartTime(Date startTime) { + setStartTime(startTime); + return this; + } + + /** + * @return period + */ + public Integer getPeriod() { + return period; + } + + /** + * @param period + */ + public void setPeriod(Integer period) { + this.period = period; + } + + /** + * @param period + * @return returns this object + */ + public GetStatUvRequest withPeriod(Integer period) { + setPeriod(period); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public GetStatUvRequest 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/cdn/model/GetStatUvResponse.java b/src/main/java/com/baidubce/services/cdn/model/GetStatUvResponse.java new file mode 100644 index 00000000..0a89e609 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/GetStatUvResponse.java @@ -0,0 +1,40 @@ +/* + * 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 GetStatUvResponse extends CdnResponse { + + private List details = new ArrayList(); + + /** + * @param details + */ + public void setDetails(List details) { + this.details = details; + } + + /** + * @return details + */ + public List getDetails() { + return details; + } +} 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..7967f621 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 java.lang.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..462b89b4 100644 --- a/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/ListDomainsRequest.java @@ -24,32 +24,46 @@ public class ListDomainsRequest extends AbstractBceRequest { private String marker; + /** + * @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; } + /** + * (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 java.lang.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/LogEntry.java b/src/main/java/com/baidubce/services/cdn/model/LogEntry.java new file mode 100644 index 00000000..356bb0e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/LogEntry.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; + +import java.util.Date; + +/** + * @author yixing + * + */ +public class LogEntry { + private String url; + private String name; + private Long size; + private Date startTime; + private Date endTime; + + /** + * @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; + } +} 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..95ec4a17 100644 --- a/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java +++ b/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java @@ -13,28 +13,57 @@ package com.baidubce.services.cdn.model; -public class OriginPeer { - private String peer = null; +/** + * @author yixing + * + */ +public class OriginPeer extends JsonObject { + private String peer; + private String host; + /** + * @param peer + * @return returns this object + */ public OriginPeer withPeer(String peer) { this.peer = peer; return this; } + + /** + * @param host + * @return returns this object + */ + public OriginPeer withHost(String host) { + this.host = host; + return this; + } + /** + * @return peer + */ public String getPeer() { return peer; } + /** + * @param peer + */ public void setPeer(String peer) { this.peer = peer; } + + /** + * @return host + */ + public String getHost() { + return host; + } - @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(); + /** + * @param host + */ + public void setHost(String host) { + this.host = host; } } 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..b79f46c0 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java +++ b/src/main/java/com/baidubce/services/cdn/model/PrefetchRequest.java @@ -22,32 +22,62 @@ import java.util.ArrayList; +/** + * @author yixing + * + */ public class PrefetchRequest extends AbstractBceRequest { 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; } + /** + * @param task + * @return returns this object + */ + public PrefetchRequest addTask(PrefetchTask 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 PrefetchRequest withRequestCredentials(BceCredentials credentials) { this.setRequestCredentials(credentials); return this; } + /** + * (non-Javadoc) + * @see java.lang.Object#toString() + */ @Override public String toString() { try { 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/PrefetchStatus.java b/src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java index b4d2ce03..d4710b6e 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java +++ b/src/main/java/com/baidubce/services/cdn/model/PrefetchStatus.java @@ -15,50 +15,83 @@ import java.util.Date; +/** + * @author yixing + * + */ public class PrefetchStatus extends JsonObject { private String status; private PrefetchTask task; - private Date createdAt; 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(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/PrefetchTask.java b/src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java index f2700c9b..49f5459f 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java +++ b/src/main/java/com/baidubce/services/cdn/model/PrefetchTask.java @@ -13,17 +13,31 @@ package com.baidubce.services.cdn.model; +/** + * @author yixing + * + */ public class PrefetchTask extends JsonObject { private String url; + /** + * @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; 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..31357eba 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,69 @@ package com.baidubce.services.cdn.model; +import java.util.ArrayList; 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; +/** + * @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 java.lang.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..c518af79 100644 --- a/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java +++ b/src/main/java/com/baidubce/services/cdn/model/PurgeTask.java @@ -13,6 +13,10 @@ 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"; @@ -20,28 +24,48 @@ public class PurgeTask extends JsonObject { private String url; 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/PvRegionData.java b/src/main/java/com/baidubce/services/cdn/model/PvRegionData.java new file mode 100644 index 00000000..ec3992cd --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/PvRegionData.java @@ -0,0 +1,75 @@ +/* + * 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 PvRegionData extends JsonObject { + + private String location; + private String isp; + private Long pv; + private Long qps; + + /** + * @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 pv + */ + public Long getPv() { + return pv; + } + /** + * @param pv + */ + public void setPv(Long pv) { + this.pv = pv; + } + /** + * @return qps + */ + public Long getQps() { + return qps; + } + /** + * @param qps + */ + public void setQps(Long qps) { + this.qps = qps; + } +} 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..a6d4a105 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/RefererACL.java @@ -0,0 +1,95 @@ +/* + * 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 { + + List blackList; + List whiteList; + 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; + } + +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlRequest.java new file mode 100644 index 00000000..af7877a9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlRequest.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; + +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 SetDomainCacheFullUrlRequest 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 SetDomainCacheFullUrlRequest withDomain(String domain) { + this.domain = domain; + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public SetDomainCacheFullUrlRequest 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/cdn/model/SetDomainCacheFullUrlResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlResponse.java new file mode 100644 index 00000000..0ede851d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheFullUrlResponse.java @@ -0,0 +1,20 @@ +/* + * 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 SetDomainCacheFullUrlResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLRequest.java new file mode 100644 index 00000000..accb4a5e --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/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; + +import java.util.ArrayList; +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; + +/** + * @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 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/cdn/model/SetDomainCacheTTLResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLResponse.java new file mode 100644 index 00000000..63d8a76f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainCacheTTLResponse.java @@ -0,0 +1,20 @@ +/* + * 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 SetDomainCacheTTLResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLRequest.java new file mode 100644 index 00000000..4c4ef778 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLRequest.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; + +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 SetDomainIpACLRequest extends AbstractBceRequest { + private String domain; + private IpACL ipACL; + + /** + * @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 SetDomainIpACLRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @return returns this object + */ + public IpACL getIpACL() { + return ipACL; + } + + /** + * @param ipACL + */ + public void setIpACL(IpACL ipACL) { + this.ipACL = ipACL; + } + + /** + * @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 SetDomainIpACLRequest 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/cdn/model/SetDomainIpACLResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLResponse.java new file mode 100644 index 00000000..9f9cb520 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainIpACLResponse.java @@ -0,0 +1,20 @@ +/* + * 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 SetDomainIpACLResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateRequest.java new file mode 100644 index 00000000..5c8d5ef2 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateRequest.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; + +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 SetDomainLimitRateRequest extends AbstractBceRequest { + private String domain; + private int limitRate; + + /** + * @return domain + */ + public String getDomain() { + return domain; + } + + /** + * @param domain the domain name + */ + public void setDomain(String domain) { + this.domain = domain; + } + + /** + * @return limitRate + */ + public int getLimitRate() { + return limitRate; + } + + /** + * @param limitRate + */ + public void setLimitRate(int limitRate) { + this.limitRate = limitRate; + } + + /** + * @param domain the domain name + * @return returns this object + */ + public SetDomainLimitRateRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + /** + * @param limitRate + * @return returns this object + */ + public SetDomainLimitRateRequest withLimitRate(int limitRate) { + setLimitRate(limitRate); + return this; + } + + /** + * (non-Javadoc) + * @see com.baidubce.model.AbstractBceRequest#withRequestCredentials(com.baidubce.auth.BceCredentials) + */ + @Override + public SetDomainLimitRateRequest 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/cdn/model/SetDomainLimitRateResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateResponse.java new file mode 100644 index 00000000..3f64662a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainLimitRateResponse.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; + +/** + * @author yixing + * + */ +public class SetDomainLimitRateResponse extends CdnResponse { + +} 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..f34807f0 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginRequest.java @@ -0,0 +1,99 @@ +/* + * 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 + * + */ +public class SetDomainOriginRequest extends AbstractBceRequest { + + private List origin; + private String domain; + + /** + * @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 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/cdn/model/SetDomainOriginResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginResponse.java new file mode 100644 index 00000000..5896c800 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainOriginResponse.java @@ -0,0 +1,20 @@ +/* + * 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 SetDomainOriginResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLRequest.java new file mode 100644 index 00000000..6a21fe4a --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLRequest.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; + +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 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 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/cdn/model/SetDomainRefererACLResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLResponse.java new file mode 100644 index 00000000..c5df2463 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetDomainRefererACLResponse.java @@ -0,0 +1,20 @@ +/* + * 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 SetDomainRefererACLResponse extends CdnResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatAvgSpeedDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatAvgSpeedDetails.java new file mode 100644 index 00000000..ac396e6c --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatAvgSpeedDetails.java @@ -0,0 +1,50 @@ +/* + * 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.Date; + +/** + * @author yixing + * + */ +public class StatAvgSpeedDetails { + private Date timestamp; + private Long avgspeed; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @return avgspeed + */ + public Long getAvgspeed() { + return avgspeed; + } + /** + * @param avgspeed + */ + public void setAvgspeed(Long avgspeed) { + this.avgspeed = avgspeed; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java index 34616f1e..bad9cb5a 100644 --- a/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java +++ b/src/main/java/com/baidubce/services/cdn/model/StatFlowDetails.java @@ -14,33 +14,64 @@ package com.baidubce.services.cdn.model; import java.util.Date; +import java.util.List; +/** + * @author yixing + * + */ public class StatFlowDetails extends JsonObject { private Date timestamp; - private Integer flow; - private Integer bps; - + private Long flow; + private Long bps; + private List regions; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ public void setTimestamp(Date timestamp) { this.timestamp = timestamp; } - - public Date getTimestamp() { - return timestamp; + /** + * @return flow + */ + public Long getFlow() { + return flow; } - - public void setFlow(Integer flow) { + /** + * @param flow + */ + public void setFlow(Long flow) { this.flow = flow; } - - public Integer getFlow() { - return flow; + /** + * @return bps + */ + public Long getBps() { + return bps; } - - public void setBps(Integer bps) { + /** + * @param bps + */ + public void setBps(Long bps) { this.bps = bps; } - - public Integer getBps() { - return bps; + /** + * @return regions + */ + public List getRegions() { + return regions; + } + /** + * @param regions + */ + public void setRegions(List regions) { + this.regions = regions; } } diff --git a/src/main/java/com/baidubce/services/cdn/model/StatHitRateDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatHitRateDetails.java new file mode 100644 index 00000000..e2e708d3 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatHitRateDetails.java @@ -0,0 +1,50 @@ +/* + * 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.Date; + +/** + * @author yixing + * + */ +public class StatHitRateDetails { + private Date timestamp; + private Double hitrate; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @return hitrate + */ + public Double getHitrate() { + return hitrate; + } + /** + * @param hitrate + */ + public void setHitrate(Double hitrate) { + this.hitrate = hitrate; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatHttpCodeDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatHttpCodeDetails.java new file mode 100644 index 00000000..af8cfe2b --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatHttpCodeDetails.java @@ -0,0 +1,64 @@ +/* + * 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.Date; +import java.util.List; + +/** + * @author yixing + * + */ +public class StatHttpCodeDetails { + private Date timestamp; + private List counters; + private List regions; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @return counters + */ + public List getCounters() { + return counters; + } + /** + * @param counters + */ + public void setCounters(List counters) { + this.counters = counters; + } + /** + * @return regions + */ + public List getRegions() { + return regions; + } + /** + * @param regions + */ + public void setRegions(List regions) { + this.regions = regions; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatPvDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatPvDetails.java new file mode 100644 index 00000000..c7604def --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatPvDetails.java @@ -0,0 +1,77 @@ +/* + * 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.Date; +import java.util.List; + +/** + * @author yixing + * + */ +public class StatPvDetails extends JsonObject { + private Date timestamp; + private Integer pv; + private Integer qps; + private List regions; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @return pv + */ + public Integer getPv() { + return pv; + } + /** + * @param pv + */ + public void setPv(Integer pv) { + this.pv = pv; + } + /** + * @return qps + */ + public Integer getQps() { + return qps; + } + /** + * @param qps + */ + public void setQps(Integer qps) { + this.qps = qps; + } + /** + * @return regions + */ + public List getRegions() { + return regions; + } + /** + * @param regions + */ + public void setRegions(List regions) { + this.regions = regions; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/StatTopRefererDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatTopRefererDetails.java new file mode 100644 index 00000000..f7d83e51 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatTopRefererDetails.java @@ -0,0 +1,52 @@ +/* + * 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.Date; +import java.util.List; + +/** + * @author yixing + * + */ +public class StatTopRefererDetails { + private Date timestamp; + private List counters; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @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/StatTopUrlDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatTopUrlDetails.java new file mode 100644 index 00000000..67d5dd75 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatTopUrlDetails.java @@ -0,0 +1,52 @@ +/* + * 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.Date; +import java.util.List; + +/** + * @author yixing + * + */ +public class StatTopUrlDetails { + private Date timestamp; + private List counters; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @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/StatUvDetails.java b/src/main/java/com/baidubce/services/cdn/model/StatUvDetails.java new file mode 100644 index 00000000..eafac30d --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/StatUvDetails.java @@ -0,0 +1,50 @@ +/* + * 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.Date; + +/** + * @author yixing + * + */ +public class StatUvDetails extends JsonObject { + private Date timestamp; + private Integer uv; + + /** + * @return timestamp + */ + public Date getTimestamp() { + return timestamp; + } + /** + * @param timestamp + */ + public void setTimestamp(Date timestamp) { + this.timestamp = timestamp; + } + /** + * @return uv + */ + public Integer getUv() { + return uv; + } + /** + * @param uv + */ + public void setUv(Integer uv) { + this.uv = uv; + } +} diff --git a/src/main/java/com/baidubce/services/doc/DocClient.java b/src/main/java/com/baidubce/services/doc/DocClient.java index ae805306..183cb2ac 100644 --- a/src/main/java/com/baidubce/services/doc/DocClient.java +++ b/src/main/java/com/baidubce/services/doc/DocClient.java @@ -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) { @@ -793,7 +824,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 +836,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 +879,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 +891,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/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..24195a56 100644 --- a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java @@ -37,8 +37,10 @@ class IotDmClientHelper { private static final String VERSION = "v1"; + private static final String VERSION_V2 = "v2"; private static final String IOT = "iot"; private static final String MANAGEMENT = "management"; + private static final String ENDPOINT = "endpoint"; private static final String[] HEADERS_TO_SIGN = { Headers.HOST, Headers.BCE_DATE }; private static final String CONTENT_TYPE = "application/json;charset=UTF-8"; @@ -50,7 +52,7 @@ 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)); @@ -77,6 +79,33 @@ static InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodNa return request; } + 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)); + 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)); 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/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/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/iothub/IotHubClient.java b/src/main/java/com/baidubce/services/iothub/IotHubClient.java index 3779e6b7..f674ee30 100644 --- a/src/main/java/com/baidubce/services/iothub/IotHubClient.java +++ b/src/main/java/com/baidubce/services/iothub/IotHubClient.java @@ -66,6 +66,7 @@ */ 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 THING = "thing"; @@ -90,7 +91,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() { diff --git a/src/main/java/com/baidubce/services/lss/LssClient.java b/src/main/java/com/baidubce/services/lss/LssClient.java index 401e76cb..38d5549f 100644 --- 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,6 +43,7 @@ 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.GetAllDomainsPlayCountResponse; @@ -118,6 +120,11 @@ 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; @@ -259,7 +266,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 +276,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 +322,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 +353,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 +390,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 +403,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 +416,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 +430,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 +441,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 +464,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 +487,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 +514,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 +541,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 +553,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 +569,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 +581,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 +705,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 +718,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 +731,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 +744,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 +757,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 +771,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 +783,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 +796,7 @@ public GetAppResponse queryApp(GetAppRequest request) { /** * list all your apps - * + * @return this object */ public ListAppResponse listApp() { ListAppRequest request = new ListAppRequest(); @@ -805,8 +806,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 +818,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 +832,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 +847,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 +862,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 +875,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 +891,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 +905,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 +921,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 +934,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 +948,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 +962,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 +978,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 +991,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 +1005,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 +1017,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 +1033,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 +1048,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 +1062,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) { @@ -1073,10 +1075,10 @@ public GetSessionSourceInfoResponse getSessionSourceInfo(String sessionId) { /** * 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. - * + * @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 +1090,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 +1107,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) { @@ -1146,8 +1146,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 +1159,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 +1172,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 +1185,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 +1198,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 +1212,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 +1240,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 +1253,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 +1268,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 +1285,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 +1300,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 +1344,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 +1365,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 +1379,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."); @@ -1391,6 +1408,7 @@ public ListStreamResponse listStream(ListStreamRequest request) { * 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 +1421,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 +1437,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 +1449,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 +1471,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(); @@ -1462,6 +1484,7 @@ public GetStreamResponse getStream(String domain, String app, String stream) { * 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 +1507,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 +1519,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 +1542,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 +1550,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 +1793,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 +1806,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 +1826,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 +1839,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 +1861,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 +1885,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 +1907,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 +1930,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 +1952,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."); @@ -1725,6 +1975,7 @@ public GetOneDomainTrafficResponse getOneDomainTraffic(GetOneDomainStatisticsReq * 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 +2004,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 +2043,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."); @@ -1815,7 +2068,6 @@ public GetStreamStatisticsResponse getStreamStatistics(GetStreamStatisticsReques } - /** * Creates and initializes a new request object for the specified resource. * This method is responsible for determining HTTP method, URI path, @@ -1823,18 +2075,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(); diff --git a/src/main/java/com/baidubce/services/lss/model/AntiLeech.java b/src/main/java/com/baidubce/services/lss/model/AntiLeech.java index f631a0a9..2394508a 100644 --- 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,67 @@ package com.baidubce.services.lss.model; +/** + * Reprsents the anti-leech settings. Currently only refer & single ip restriction are supported. + */ public class AntiLeech { 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 index 22457913..1d34d04b 100644 --- a/src/main/java/com/baidubce/services/lss/model/Audio.java +++ b/src/main/java/com/baidubce/services/lss/model/Audio.java @@ -14,55 +14,94 @@ package com.baidubce.services.lss.model; public class Audio { - private Integer bitRateInBps = null; + 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 index d3db94be..d6714d23 100644 --- 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 index 683d5a19..da480277 100644 --- a/src/main/java/com/baidubce/services/lss/model/AuthInfo.java +++ b/src/main/java/com/baidubce/services/lss/model/AuthInfo.java @@ -13,6 +13,9 @@ package com.baidubce.services.lss.model; +/** + * Represents the authentication settings. + */ public class AuthInfo { private Boolean push = null; @@ -20,40 +23,88 @@ public class AuthInfo { 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 index f6032c4b..57a79d86 100644 --- 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,67 @@ package com.baidubce.services.lss.model; +/** + * Represents the BOS information + */ public class Bos { 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/CodecOptions.java b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java index 7de98260..bc79b5b9 100644 --- a/src/main/java/com/baidubce/services/lss/model/CodecOptions.java +++ b/src/main/java/com/baidubce/services/lss/model/CodecOptions.java @@ -17,16 +17,29 @@ public class CodecOptions { 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 index 6cbe3b31..e23cf790 100644 --- 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/GetStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java index 999cddeb..dbeef64b 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetStreamResponse.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,9 +18,10 @@ 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; @@ -49,183 +62,380 @@ public class GetStreamResponse extends AbstractBceResponse { 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; } + /** + * Returns streamStatus + * @return streamStatus + */ public String getStreamStatus() { return streamStatus; } + /** + * Sets streamStatus + * @param streamStatus + */ public void setStreamStatus(String streamStatus) { this.streamStatus = streamStatus; } + /** + * 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; } + /** + * 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 { 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; } @@ -264,6 +474,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/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/media/MediaClient.java b/src/main/java/com/baidubce/services/media/MediaClient.java index 1f26d101..371ded2a 100644 --- a/src/main/java/com/baidubce/services/media/MediaClient.java +++ b/src/main/java/com/baidubce/services/media/MediaClient.java @@ -197,7 +197,7 @@ 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) { @@ -240,7 +240,7 @@ 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) { @@ -273,7 +273,7 @@ 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) { 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..1ceed36a --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/ModbusClient.java @@ -0,0 +1,428 @@ +/* + * 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.Gateway; +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 (Gateway 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 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 100755 index 00000000..ad156c72 --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java @@ -0,0 +1,126 @@ +package com.baidubce.services.modbus.model.gateway; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +@JsonIgnoreProperties(ignoreUnknown = true) +public class 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 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 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/GatewayResponse.java b/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java new file mode 100755 index 00000000..6756484b --- /dev/null +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java @@ -0,0 +1,128 @@ +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 { + + 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 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 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..32aaee74 --- /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 index 2e61f121..a9f7d197 100644 --- 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 index e0b387b7..db407a5f 100644 --- 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 index e3c51d48..28bfe862 100644 --- 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 index a022d372..9336e852 100644 --- 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 index 255ecedd..12ad65c6 100644 --- 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 index d6c14abb..3c95a3c4 100644 --- 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 index c6fe34a4..ea3ff895 100644 --- 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 index 5eef9c89..d5162cca 100644 --- 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 index 191237fd..0c77a2a6 100644 --- 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 index acdd9414..09be0a66 100644 --- 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 index 7bfdaa82..a3d78d5e 100644 --- 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 index 2f48853b..8e0734bc 100644 --- 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 index f5c33fdb..79919752 100644 --- 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 index 02941c99..f25bf935 100644 --- 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 index 89bf8bd5..eb80b114 100644 --- 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 index 0b592ebc..283b491a 100644 --- 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/ruleengine/RuleEngineClient.java b/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java index 1666e00e..11925126 100644 --- a/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java +++ b/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java @@ -47,7 +47,7 @@ public class RuleEngineClient extends AbstractBceClient { private static final String BATCH = "batch"; private static final String DELETE = "delete"; private static final String DESTINATIONS = "destinations"; - private static final String ENDPOINT = "http://re.iot.gz.baidubce.com"; + private static final String ENDPOINT = "re.iot.gz.baidubce.com"; /** * Responsible for handling HttpResponse from all Tsdb service calls. @@ -56,6 +56,7 @@ public class RuleEngineClient extends AbstractBceClient { new BceMetadataResponseHandler(), new BceErrorResponseHandler(), new BceJsonResponseHandler() }; public RuleEngineClient(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT) : config, HANDLERS); } diff --git a/src/main/java/com/baidubce/services/ruleengine/model/Destination.java b/src/main/java/com/baidubce/services/ruleengine/model/Destination.java index 77b62fa9..cdcaa4b2 100644 --- a/src/main/java/com/baidubce/services/ruleengine/model/Destination.java +++ b/src/main/java/com/baidubce/services/ruleengine/model/Destination.java @@ -11,7 +11,7 @@ public class Destination extends GenericAccountRequest { private String uuid; private String ruleUuid; private String value; - private DestinationKind kind; + private String kind; private String status; public String getUuid() { @@ -38,11 +38,11 @@ public void setValue(String value) { this.value = value; } - public DestinationKind getKind() { + public String getKind() { return kind; } - public void setKind(DestinationKind kind) { + public void setKind(String kind) { this.kind = kind; } diff --git a/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java b/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java index 16496e56..08019345 100644 --- a/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java +++ b/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java @@ -1,10 +1,21 @@ +/* + * 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.ruleengine.model; -/** - * Created by yuanyoujun on 2016/10/9. - */ -public enum DestinationKind { - MQTT, - KAFKA, - TSDB +public class DestinationKind { + public static final String MQTT = "MQTT"; + public static final String TSDB = "TSDB"; + public static final String KAFKA = "KAFKA"; + public static final String BOS = "BOS"; + public static final String MQTT_DYNAMIC = "MQTT_DYNAMIC"; } diff --git a/src/main/java/com/baidubce/services/ses/SesClientSupport.java b/src/main/java/com/baidubce/services/ses/SesClientSupport.java index 51823486..d4120792 100644 --- a/src/main/java/com/baidubce/services/ses/SesClientSupport.java +++ b/src/main/java/com/baidubce/services/ses/SesClientSupport.java @@ -44,8 +44,8 @@ import com.baidubce.util.HttpUtils; /** - * This class is abstract. It contains all common methods which the {@link com.baidubce.services.ses.SesClient} class - * should need + * This class is abstract. It contains all common methods which the {@link com.baidubce.services.ses.SesClient} class + * should need. */ public abstract class SesClientSupport extends AbstractBceClient { protected final Logger logger = LoggerFactory.getLogger(this.getClass()); diff --git a/src/main/java/com/baidubce/services/sms/SmsClient.java b/src/main/java/com/baidubce/services/sms/SmsClient.java index f2304278..36872585 100644 --- a/src/main/java/com/baidubce/services/sms/SmsClient.java +++ b/src/main/java/com/baidubce/services/sms/SmsClient.java @@ -38,9 +38,9 @@ /** * The entrance class for all client access to the API of SMS(Baidu message Service). - *

+ *

* All of the API method of SMS is included in this class. - *

+ *

*/ public class SmsClient extends SmsClientSupport { /** @@ -54,8 +54,7 @@ public SmsClient() { * Constructs a new SmsClient instance with the specified configuration. * * @param config the specified configuration, default inherit super class - * com.baidubce.BceClientConfiguration - * + * com.baidubce.BceClientConfiguration * @see com.baidubce.services.sms.SmsClientConfiguration */ public SmsClient(SmsClientConfiguration config) { @@ -64,17 +63,15 @@ public SmsClient(SmsClientConfiguration config) { /** * Send message - *

+ *

* To send message, you have to specify a template which is built by system, or created by yourself which is audited * by BCE administrator. - *

+ *

* One or more receiver can be specified while sending message. - *

+ *

* * @param request The request object which includes the content to send and one or more receiver - * * @return The response object which includes the id of message and the statistics of sending result - * * @see com.baidubce.services.sms.model.SendMessageRequest * @see com.baidubce.services.sms.model.SendMessageResponse */ @@ -122,10 +119,8 @@ public SendMessageV2Response sendMessage(SendMessageV2Request request) { * Query message detail * * @param request The request object which includes the id of message to query - * * @return The response object which includes all the detail result, for example id, * content, receiver, sendTime etc - * * @see com.baidubce.services.sms.model.QueryMessageDetailRequest * @see com.baidubce.services.sms.model.QueryMessageDetailResponse */ @@ -140,14 +135,12 @@ public QueryMessageDetailResponse queryMessageDetail(QueryMessageDetailRequest r /** * Create message template - *

+ *

* The template which is created will have a unique id. after audited by BCE administrator, it can be used normally. - *

+ *

* * @param request The request object which includes the name and content of template which is ready to be created - * * @return The response object which includes the id of template which is created - * * @see com.baidubce.services.sms.model.CreateTemplateRequest * @see com.baidubce.services.sms.model.CreateTemplateResponse */ @@ -178,7 +171,6 @@ public CreateTemplateResponse createTemplate(CreateTemplateRequest request) { * Delete message template * * @param request The request object which includes the id of template which is ready to be deleted - * * @see com.baidubce.services.sms.model.DeleteTemplateRequest */ public void deleteTemplate(DeleteTemplateRequest request) { @@ -194,10 +186,8 @@ public void deleteTemplate(DeleteTemplateRequest request) { * Get the detail of message template * * @param request The request object which includes the id of template which is ready to be get - * * @return The response object which includes all of the detail of message template, refer to * com.baidubce.services.sms.model.GetTemplateDetailResponse - * * @see com.baidubce.services.sms.model.GetTemplateDetailRequest * @see com.baidubce.services.sms.model.GetTemplateDetailResponse */ @@ -214,10 +204,8 @@ public GetTemplateDetailResponse getTemplateDetail(GetTemplateDetailRequest requ * Get the list of message template * * @param request The request object which is empty - * * @return The response object which includes all of the detail of message template,refer to * com.baidubce.services.sms.model.ListTemplateResponse - * * @see com.baidubce.services.sms.model.ListTemplateResponse */ public ListTemplateResponse listTemplate(SmsRequest request) { @@ -231,10 +219,8 @@ public ListTemplateResponse listTemplate(SmsRequest request) { * Query the sending quota * * @param request The request object which is empty - * * @return The response object which includes the detail of sending quota, refer to * com.baidubce.services.sms.model.QueryQuotaResponse - * * @see com.baidubce.services.sms.model.QueryQuotaResponse */ public QueryQuotaResponse queryQuota(SmsRequest request) { @@ -248,9 +234,7 @@ public QueryQuotaResponse queryQuota(SmsRequest request) { * Get the statistics about receiving message * * @param request refer to com.baidubce.services.sms.model.StatReceiverRequest - * * @return refer to com.baidubce.services.sms.model.StatReceiverResponse - * * @see com.baidubce.services.sms.model.StatReceiverRequest * @see com.baidubce.services.sms.model.StatReceiverResponse */ diff --git a/src/main/java/com/baidubce/services/sms/SmsClientSupport.java b/src/main/java/com/baidubce/services/sms/SmsClientSupport.java index 0829171e..acc07e79 100644 --- a/src/main/java/com/baidubce/services/sms/SmsClientSupport.java +++ b/src/main/java/com/baidubce/services/sms/SmsClientSupport.java @@ -36,8 +36,8 @@ import com.baidubce.util.HttpUtils; /** - * This class is abstract. It contains all common methods which the {@link com.baidubce.services.sms.SmsClient} class - * should need + * This class is abstract. It contains all common methods which the {@link com.baidubce.services.sms.SmsClient} class + * should need */ public abstract class SmsClientSupport extends AbstractBceClient { protected static final HttpResponseHandler[] SMS_HANDLERS = new HttpResponseHandler[] { diff --git a/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java b/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java index bb5b2280..d9cf4973 100644 --- a/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java +++ b/src/main/java/com/baidubce/services/sms/model/TemplateStatus.java @@ -15,7 +15,7 @@ /** * The status of message template *

- * This class is a ENUM class + * This class is a Enum class */ public enum TemplateStatus { diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbAdminClient.java b/src/main/java/com/baidubce/services/tsdb/TsdbAdminClient.java index 859c8ad7..ce062bb7 100644 --- a/src/main/java/com/baidubce/services/tsdb/TsdbAdminClient.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbAdminClient.java @@ -19,11 +19,12 @@ */ public class TsdbAdminClient extends AbstractTsdbBceClient { + private static final String ENDPOINT_HOST = "tsdb.iot.gz.baidubce.com"; private static final String DATABASE = "database"; private static final String CLIENT_TOKEN = "clientToken"; public TsdbAdminClient(BceClientConfiguration config) { - super(config, TSDB_HANDLERS); + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, TSDB_HANDLERS); } public CreateDatabaseResponse createDatabase(CreateDatabaseRequest createDatabaseRequest, String clientToken) { diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbClient.java b/src/main/java/com/baidubce/services/tsdb/TsdbClient.java index a1c57d53..2131f2f1 100644 --- a/src/main/java/com/baidubce/services/tsdb/TsdbClient.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbClient.java @@ -13,6 +13,8 @@ import com.baidubce.http.HttpMethodName; import com.baidubce.internal.InternalRequest; import com.baidubce.services.tsdb.model.Datapoint; +import com.baidubce.services.tsdb.model.GetFieldsRequest; +import com.baidubce.services.tsdb.model.GetFieldsResponse; import com.baidubce.services.tsdb.model.GetMetricsRequest; import com.baidubce.services.tsdb.model.GetMetricsResponse; import com.baidubce.services.tsdb.model.GetTagsRequest; @@ -31,15 +33,22 @@ */ public class TsdbClient extends AbstractTsdbBceClient { + private static final String ENDPOINT_HOST = ".tsdb.iot.gz.baidubce.com"; private static final String DATAPOINT = "datapoint"; private static final String METRIC = "metric"; private static final String TAG = "tag"; + private static final String FIELD = "field"; private static final String QUERY = "query"; public TsdbClient(BceClientConfiguration config) { super(config, TSDB_HANDLERS); } + public TsdbClient(BceClientConfiguration config, String database) { + super(config.getEndpoint() == null ? config.withEndpoint(database + ENDPOINT_HOST) : config, + TSDB_HANDLERS); + } + public WriteDatapointsResponse writeDatapoints(List datapoints) { return writeDatapoints(new WriteDatapointsRequest().withDatapoints(datapoints)); } @@ -97,6 +106,17 @@ public GetTagsResponse getTags(GetTagsRequest getTagsRequest) { return this.invokeHttpClient(internalRequest, GetTagsResponse.class); } + public GetFieldsResponse getFields(String metric) { + return getFields(new GetFieldsRequest().withMetric(metric)); + } + + public GetFieldsResponse getFields(GetFieldsRequest getFieldsRequest) { + checkNotNull(getFieldsRequest, "request should not be null."); + InternalRequest internalRequest = + createRequest(getFieldsRequest, HttpMethodName.GET, METRIC, getFieldsRequest.getMetric(), FIELD); + return this.invokeHttpClient(internalRequest, GetFieldsResponse.class); + } + public QueryDatapointsResponse queryDatapoints(List queries) { return queryDatapoints(new QueryDatapointsRequest().withQueries(queries)); } diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java index ed0b2b7a..2b5a2b5f 100644 --- a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java @@ -20,6 +20,7 @@ public class TsdbConstants { public static final String AGGREGATOR_NAME_DIFF = "Diff"; public static final String AGGREGATOR_NAME_DIV = "Div"; public static final String AGGREGATOR_NAME_SCALE = "Scale"; + public static final String AGGREGATOR_NAME_RATE = "Rate"; // GroupInfo name. public static final String GROUP_INFO_NAME_TYPE = "Type"; @@ -48,4 +49,15 @@ public class TsdbConstants { // Date format. public static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss'Z'"; + + // Time unit. + public static final String TIME_UNIT_MILLISECOND = "millisecond"; + public static final String TIME_UNIT_SECOND = "second"; + public static final String TIME_UNIT_MINUTE = "minute"; + public static final String TIME_UNIT_HOUR = "hour"; + public static final String TIME_UNIT_DAY = "day"; + public static final String TIME_UNIT_WEEK = "week"; + public static final String TIME_UNIT_MONTH = "month"; + public static final String TIME_UNIT_YEAR = "year"; + } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java b/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java index bc429d3e..c06a9566 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Aggregator.java @@ -1,5 +1,7 @@ package com.baidubce.services.tsdb.model; +import com.baidubce.services.tsdb.TsdbConstants; + /** * Represent the Aggregator for querying datapoints from Tsdb. */ @@ -7,13 +9,12 @@ public class Aggregator { /** * Required. - * Represent the name of the aggregator. + * Represent the name of the aggregator. eg: "Avg" or "Sum", see aggregator name in {@link TsdbConstants}. */ private String name; /** - * Required when name is Avg, Dev, Count, First, Gaps, Last, LeastSquares, Max, Min, Percentile, Sum, - * Rate, or Sampler. + * Required when name is Avg, Dev, Count, First, Last, LeastSquares, Max, Min, Percentile or Sum. * Represent the length of sampling time. eg: "1 minutes" or "2 hours". */ private String sampling; @@ -36,6 +37,12 @@ public class Aggregator { */ private Double factor; + /** + * Required when name is Rate. + * Represent the time unit of the Scale. eg: "minute" or "hour", see time unit in {@link TsdbConstants}. + */ + private String timeUnit; + public String getName() { return name; } @@ -44,7 +51,8 @@ public String getName() { * Set the name of this aggregator. * The available aggregator names are in {@code TsdbConstants} * - * @param name should be one of the Avg, Dev, Count, First, Last, LeastSquares, Max, Min, Percentile, Sum, Diff, Div and Scale. + * @param name should be one of the Avg, Dev, Count, First, Last, LeastSquares, Max, Min, + * Percentile, Sum, Diff, Div, Scale and Rate. */ public void setName(String name) { this.name = name; @@ -82,6 +90,14 @@ public void setFactor(Double factor) { this.factor = factor; } + public String getTimeUnit() { + return timeUnit; + } + + public void setTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + } + public Aggregator withName(String name) { this.name = name; return this; @@ -106,4 +122,9 @@ public Aggregator withFactor(double factor) { this.factor = factor; return this; } + + public Aggregator withTimeUnit(String timeUnit) { + this.timeUnit = timeUnit; + return this; + } } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java b/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java index e1b7ddbe..f26cff09 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Datapoint.java @@ -23,6 +23,12 @@ public class Datapoint { */ private String metric; + /** + * Optional. + * Represent the field of the datapoint(s). + */ + private String field; + /** * Required. * Represent the tags which the datapoint(s) has/have. @@ -51,6 +57,14 @@ public void setMetric(String metric) { this.metric = metric; } + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + public Map getTags() { return tags; } @@ -76,6 +90,11 @@ public Datapoint withMetric(String metric) { return this; } + public Datapoint withField(String field) { + this.field = field; + return this; + } + public Datapoint withTags(Map tags) { this.tags = tags; return this; diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetFieldsRequest.java b/src/main/java/com/baidubce/services/tsdb/model/GetFieldsRequest.java new file mode 100644 index 00000000..886e4b84 --- /dev/null +++ b/src/main/java/com/baidubce/services/tsdb/model/GetFieldsRequest.java @@ -0,0 +1,31 @@ +package com.baidubce.services.tsdb.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Represent the request for getting fields from Tsdb. + */ +public class GetFieldsRequest extends AbstractBceRequest { + + private String metric; + + public String getMetric() { + return metric; + } + + public void setMetric(String metric) { + this.metric = metric; + } + + public GetFieldsRequest withMetric(String metric) { + this.metric = metric; + return this; + } + + @Override + public GetFieldsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/tsdb/model/GetFieldsResponse.java b/src/main/java/com/baidubce/services/tsdb/model/GetFieldsResponse.java new file mode 100644 index 00000000..3cad6220 --- /dev/null +++ b/src/main/java/com/baidubce/services/tsdb/model/GetFieldsResponse.java @@ -0,0 +1,34 @@ +package com.baidubce.services.tsdb.model; + +import java.util.Map; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the response for getting fields from Tsdb. + */ +public class GetFieldsResponse extends AbstractBceResponse { + + private Map fields; + + public Map getFields() { + return fields; + } + + public void setFields(Map fields) { + this.fields = fields; + } + + public static class FieldInfo { + private String type; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + } + +} diff --git a/src/main/java/com/baidubce/services/tsdb/model/Group.java b/src/main/java/com/baidubce/services/tsdb/model/Group.java index d1b2a1d0..dc5e53e9 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Group.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Group.java @@ -98,12 +98,12 @@ public void setValue(JsonNode value) { @JsonIgnore public boolean isLong() { - return value.isLong(); + return value.isIntegralNumber(); } @JsonIgnore public boolean isDouble() { - return value.isDouble(); + return value.isFloatingPointNumber(); } @JsonIgnore diff --git a/src/main/java/com/baidubce/services/tsdb/model/Query.java b/src/main/java/com/baidubce/services/tsdb/model/Query.java index 188a315b..264ffe81 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Query.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Query.java @@ -15,6 +15,12 @@ public class Query { */ private String metric; + /** + * Optional. + * The field name. + */ + private String field; + /** * Required. * The filters. @@ -54,6 +60,14 @@ public void setMetric(String metric) { this.metric = metric; } + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + public Filters getFilters() { return filters; } @@ -98,7 +112,12 @@ public Query withMetric(String metric) { this.metric = metric; return this; } - + + public Query withField(String field) { + this.field = field; + return this; + } + public Query withFilters(Filters filters) { this.filters = filters; return this; diff --git a/src/main/java/com/baidubce/services/tsdb/model/Result.java b/src/main/java/com/baidubce/services/tsdb/model/Result.java index d8caaa1e..f8ecbbc7 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Result.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Result.java @@ -8,7 +8,9 @@ public class Result { private String metric; - + + private String field; + private long rawCount; private List groups; @@ -21,6 +23,14 @@ public void setMetric(String metric) { this.metric = metric; } + public String getField() { + return field; + } + + public void setField(String field) { + this.field = field; + } + public long getRawCount() { return rawCount; } diff --git a/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java b/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java index 55dee0fb..fa5cbfd9 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java +++ b/src/main/java/com/baidubce/services/tsdb/model/ValueFilter.java @@ -72,7 +72,7 @@ public static ValueFilter createValueFilter(String operation, String value) { /** * Create value filter for Double type. * - * @param operation Operation for comparing which support =, !=, >, <, >= and <=. + * @param operation Operation for comparing which support =, !=, >, <, >= and <=. * @param value Value for comparing with. * @return ValueFilter */ @@ -86,7 +86,7 @@ public static ValueFilter createValueFilter(String operation, Double value) { /** * Create value filter for Long type. * - * @param operation Operation for comparing which support =, !=, >, <, >= and <=. + * @param operation Operation for comparing which support =, !=, >, <, >= and <=. * @param value Value for comparing with. * @return ValueFilter */ diff --git a/src/main/java/com/baidubce/services/vod/VodClient.java b/src/main/java/com/baidubce/services/vod/VodClient.java index 4a9e5593..a752ac4f 100644 --- a/src/main/java/com/baidubce/services/vod/VodClient.java +++ b/src/main/java/com/baidubce/services/vod/VodClient.java @@ -198,6 +198,7 @@ public VodClient(BceClientConfiguration vodConfig) { * @param description media description. * @param file The file containing the data to be uploaded to VOD. * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own task * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. * @throws FileNotFoundException */ @@ -205,7 +206,8 @@ public CreateMediaResourceResponse createMediaResource( String title, String description, File file, - String transcodingPresetGroupName) + String transcodingPresetGroupName, + int priority) throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The media file " + file.getAbsolutePath() + " doesn't exist!"); @@ -234,7 +236,8 @@ public CreateMediaResourceResponse createMediaResource( .withTitle(title) .withDescription(description) .withSourceExtension(sourceExtension) - .withTranscodingPresetGroupName(transcodingPresetGroupName); + .withTranscodingPresetGroupName(transcodingPresetGroupName) + .withPriority(priority); InternalCreateMediaResponse internalResponse = processMedia(request); response.setMediaId(internalResponse.getMediaId()); } @@ -251,15 +254,16 @@ public CreateMediaResourceResponse createMediaResource( * @param title The title string of the media resource * @param description The description string of the media resource * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own jobs * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. - * @throws FileNotFoundException */ public CreateMediaResourceResponse createMediaResource( String sourceBucket, String sourceKey, String title, String description, - String transcodingPresetGroupName) { + String transcodingPresetGroupName, + int priority) { checkStringNotEmpty(sourceBucket, "sourceBucket should not be null or empty!"); checkStringNotEmpty(sourceKey, "key should not be null or empty!"); @@ -288,7 +292,8 @@ public CreateMediaResourceResponse createMediaResource( .withTitle(title) .withDescription(description) .withSourceExtension(sourceExtension) - .withTranscodingPresetGroupName(transcodingPresetGroupName); + .withTranscodingPresetGroupName(transcodingPresetGroupName) + .withPriority(priority); InternalCreateMediaResponse internalResponse = processMedia(request); CreateMediaResourceResponse response = new CreateMediaResourceResponse(); @@ -352,9 +357,9 @@ public GetMediaResourceResponse getMediaResource(GetMediaResourceRequest request *

* The caller must authenticate with a valid BCE Access Key / Private Key pair. * - * @param pageNo The pageNo need to list, must >0 + * @param pageNo The pageNo need to list, must be greater than 0 * @param pageSize The pageSize ,must in range [LIST_MIN_PAGESIZE,LIST_MAX_PAGESIZE] - * @pagam status The media status, can be null + * @param status The media status, can be null * @param begin The media create date after begin * @param end The media create date before end * @param title The media title, use prefix search @@ -420,7 +425,7 @@ public ListMediaResourceResponse listMediaResources(ListMediaResourceRequest req * * @param marker The marker labels the query begining; first query use NULL. * @param maxSize The maxSize returned ,must in range [LIST_MIN_PAGESIZE,LIST_MAX_PAGESIZE] - * @pagam status The media status, can be null + * @param status The media status, can be null * @param begin The media create date after begin * @param end The media create date before end * @param title The media title, use prefix search @@ -679,7 +684,7 @@ public GenerateMediaPlayerCodeResponse generateMediaPlayerCode(GenerateMediaPlay * * @param startTime, query media start time, default:2016-04-30T16:00:00Z * @param endTime, query media end time, default:now - * @pagam aggregate, if need aggregate, default: true + * @param aggregate, if need aggregate, default: true * @return The media statistic info */ public GetMediaStatisticResponse getMediaStatistic( diff --git a/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java b/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java index 1cd4584d..7897a3b0 100644 --- a/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java +++ b/src/main/java/com/baidubce/services/vod/model/InternalCreateMediaRequest.java @@ -17,6 +17,10 @@ import com.baidubce.model.AbstractBceRequest; import com.fasterxml.jackson.annotation.JsonIgnore; +/** + * InternalCreateMediaRequest class used to construct a internal createMedia request, + * and send to API server. + */ public class InternalCreateMediaRequest extends AbstractBceRequest { /* @@ -40,8 +44,16 @@ public class InternalCreateMediaRequest extends AbstractBceRequest { */ private String sourceExtension; + /* + * The media transcoding preset group name + */ private String transcodingPresetGroupName; + /* + * The transcoding priority + */ + private int priority; + @Override public String toString() { StringBuilder sb = new StringBuilder("InternalCreateMediaRequest { \n"); @@ -53,72 +65,180 @@ public String toString() { return sb.toString(); } + /** + * get media id + * + * @return the media id + */ public String getMediaId() { return mediaId; } + /** + * set media id + * + * @param mediaId the media id + */ public void setMediaId(String mediaId) { this.mediaId = mediaId; } + /** + * set the media id + * + * @param mediaId the media id + * @return InternalCreateMediaRequest after set mediaId + */ public InternalCreateMediaRequest withMediaId(String mediaId) { this.mediaId = mediaId; return this; } + /** + * get media title + * + * @return the media title + */ public String getTitle() { return title; } + /** + * set media title + * + * @param title the media title + */ public void setTitle(String title) { this.title = title; } - + /** + * set the media title + * + * @param title the media title + * @return InternalCreateMediaRequest after set title + */ public InternalCreateMediaRequest withTitle(String title) { this.title = title; return this; } + /** + * get media transcoding preset group name + * + * @return the media transcoding preset group name + */ public String getTranscodingPresetGroupName() { return transcodingPresetGroupName; } + /** + * set media transcoding preset group name + * + * @param transcodingPresetGroupName the media transcoding preset group name + */ public void setTranscodingPresetGroupName(String transcodingPresetGroupName) { this.transcodingPresetGroupName = transcodingPresetGroupName; } + /** + * set media transcoding preset group name + * + * @param transcodingPresetGroupName the media transcoding preset group name + * @return InternalCreateMediaRequest with media transcoding preset group name + */ public InternalCreateMediaRequest withTranscodingPresetGroupName(String transcodingPresetGroupName) { this.transcodingPresetGroupName = transcodingPresetGroupName; return this; } + /** + * get media description + * + * @return the media description + */ public String getDescription() { return description; } + /** + * set media description + * + * @param description the media description + */ public void setDescription(String description) { this.description = description; } + /** + * set media description + * + * @param description the media description + * @return InternalCreateMediaRequest with media description + */ public InternalCreateMediaRequest withDescription(String description) { this.description = description; return this; } + /** + * get media source extension + * + * @return the media source extension + */ public String getSourceExtension() { return sourceExtension; } + /** + * set media source extension + * + * @param sourceExtension the media source extension + */ public void setSourceExtension(String sourceExtension) { this.sourceExtension = sourceExtension; } + /** + * set media source extension + * + * @param sourceExtension the media source extension + * @return InternalCreateMediaRequest with media source extension + */ public InternalCreateMediaRequest withSourceExtension(String sourceExtension) { this.sourceExtension = sourceExtension; return this; } + /** + * get media transcoding priority + * + * @return the media transcoding priority + */ + public int getPriority() { + return priority; + } + + /** + * set media transcoding priority + * + * @param priority the media transcoding priority + */ + public void setPriority(int priority) { + this.priority = priority; + } + + /** + * set media transcoding priority + * + * @param priority the media transcoding priority + * @return InternalCreateMediaRequest with media transcoding priority + */ + public InternalCreateMediaRequest withPriority(int priority) { + this.priority = priority; + return this; + } + @Override public AbstractBceRequest withRequestCredentials(BceCredentials credentials) { setRequestCredentials(credentials); diff --git a/src/main/java/com/baidubce/util/HttpUtils.java b/src/main/java/com/baidubce/util/HttpUtils.java index 008778d1..27be6896 100644 --- a/src/main/java/com/baidubce/util/HttpUtils.java +++ b/src/main/java/com/baidubce/util/HttpUtils.java @@ -112,7 +112,6 @@ public static String normalizePath(String path) { * * @param value the string to normalize. * @return the normalized string. - * @throws UnsupportedEncodingException */ public static String normalize(String value) { try { diff --git a/src/main/java/com/baidubce/util/Mimetypes.java b/src/main/java/com/baidubce/util/Mimetypes.java index 10bbce95..da032cbc 100644 --- a/src/main/java/com/baidubce/util/Mimetypes.java +++ b/src/main/java/com/baidubce/util/Mimetypes.java @@ -22,15 +22,14 @@ /** * Utility class that maintains a listing of known Mimetypes, and determines the * mimetype of files based on file extensions. - * *

* This class is obtained with the {#link {@link #getInstance()} method that * recognizes loaded mime types from the file mime.types if this * file is available at the root of the classpath. The mime.types file format, * and most of the content, is taken from the Apache HTTP server's mime.types - * file. *

- *

The format for mime type setting documents is: - * mimetype + extension (+ extension)*. Any + * file. + *

The format for mime type setting documents is: + * mimetype <Space | Tab>+ extension (<Space|Tab>+ extension)*. Any * blank lines in the file are ignored, as are lines starting with * # which are considered comments. Lines that have a mimetype but * no associated extensions are also ignored. @@ -132,7 +131,6 @@ public void loadAndReplaceMimetypes(InputStream is) throws IOException { * no extension, or the extension is not available in the listing contained * in this class, the default mimetype application/octet-stream * is returned. - * *

* A file extension is one or more characters that occur after the last * period (.) in the file's name. If a file has no extension, Guesses the @@ -171,7 +169,6 @@ public String getMimetype(String fileName) { * to find the corresponding mime type. If the file has no extension, or the extension is not * available in the listing contained in this class, the default mimetype * application/octet-stream is returned. - * *

* A file extension is one or more characters that occur after the last period (.) in the file's name. * If a file has no extension, @@ -179,7 +176,7 @@ public String getMimetype(String fileName) { * * @param file the file whose extension may match a known mimetype. * @return the file's mimetype based on its extension, or a default value of - * application/octet-stream if a mime type value cannot be found. + * application/octet-stream if a mime type value cannot be found. */ public String getMimetype(File file) { return getMimetype(file.getName()); From 5003556a6193f32662717114e02dd39e8033efeb Mon Sep 17 00:00:00 2001 From: jianhengyi Date: Thu, 20 Jul 2017 14:33:02 +0800 Subject: [PATCH 02/53] 0.10.20 --- pom.xml | 2 +- .../com/baidubce/BceClientConfiguration.java | 2 - src/main/java/com/baidubce/BceConstants.java | 2 +- .../services/iotalarm/IotAlarmClient.java | 144 ++++++++++++ .../services/iotalarm/model/Alarm.java | 207 +++++++++++++++++ .../services/iotalarm/model/AlarmKind.java | 8 + .../iotalarm/model/AlarmSeverity.java | 10 + .../services/iotalarm/model/AlarmTrigger.java | 16 ++ .../iotalarm/model/CommonResponse.java | 18 ++ .../iotalarm/model/CreateAlarmRequest.java | 126 ++++++++++ .../iotalarm/model/ListAlarmRequest.java | 29 +++ .../iotalarm/model/ListAlarmResponse.java | 49 ++++ .../iotalarm/model/UpdateAlarmRequest.java | 110 +++++++++ .../services/iotalarm/model/UuidResponse.java | 29 +++ .../services/iotdm/IotDmClientHelper.java | 38 ++- .../services/iotdm/IotDmV3Client.java | 217 ++++++++++++++++++ .../services/iotdm/model/DeviceProfile.java | 2 +- .../model/v3/device/CreateDeviceRequest.java | 59 +++++ .../v3/device/DeviceAccessDetailResponse.java | 62 +++++ .../model/v3/device/DeviceAttributes.java | 86 +++++++ .../v3/device/DeviceBasicInfoResponse.java | 112 +++++++++ .../model/v3/device/DeviceListRequest.java | 41 ++++ .../model/v3/device/DeviceListResponse.java | 34 +++ .../iotdm/model/v3/device/DeviceProfile.java | 132 +++++++++++ .../v3/device/DeviceProfileListResponse.java | 65 ++++++ .../v3/device/DeviceProfileResponse.java | 41 ++++ .../model/v3/device/DeviceViewResponse.java | 139 +++++++++++ .../v3/device/UpdateDeviceProfileRequest.java | 50 ++++ .../device/UpdateDeviceRegistryRequest.java | 59 +++++ .../v3/device/UpdateDeviceViewRequest.java | 60 +++++ .../iotdm/model/v3/schema/Schema.java | 84 +++++++ .../model/v3/schema/SchemaBaseResponse.java | 46 ++++ .../model/v3/schema/SchemaCreateRequest.java | 61 +++++ .../model/v3/schema/SchemaCreateResponse.java | 30 +++ .../model/v3/schema/SchemaListResponse.java | 65 ++++++ .../iotdm/model/v3/schema/SchemaProperty.java | 89 +++++++ .../iotdm/model/v3/schema/SchemaResponse.java | 85 +++++++ .../model/v3/schema/SchemaUpdateRequest.java | 51 ++++ .../baidubce/services/tsdb/TsdbConstants.java | 3 + .../services/tsdb/model/FieldFilter.java | 77 +++++++ .../baidubce/services/tsdb/model/Fill.java | 69 ++++++ .../baidubce/services/tsdb/model/Filters.java | 65 +++++- .../baidubce/services/tsdb/model/Group.java | 97 +++++--- .../baidubce/services/tsdb/model/Query.java | 59 ++++- .../baidubce/services/tsdb/model/Result.java | 20 ++ 45 files changed, 2793 insertions(+), 57 deletions(-) create mode 100644 src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/Alarm.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/AlarmKind.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/AlarmSeverity.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/AlarmTrigger.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/CommonResponse.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/ListAlarmResponse.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/UuidResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAccessDetailResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceBasicInfoResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfile.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileListResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfileResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceViewResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceProfileRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceRegistryRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceViewRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/Schema.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaBaseResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateRequest.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaListResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaProperty.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaResponse.java create mode 100644 src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaUpdateRequest.java create mode 100644 src/main/java/com/baidubce/services/tsdb/model/FieldFilter.java create mode 100644 src/main/java/com/baidubce/services/tsdb/model/Fill.java diff --git a/pom.xml b/pom.xml index 5d8c03c0..0d0bec7e 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.19 + 0.10.20 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html diff --git a/src/main/java/com/baidubce/BceClientConfiguration.java b/src/main/java/com/baidubce/BceClientConfiguration.java index 54608f1f..015d26d7 100644 --- 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. diff --git a/src/main/java/com/baidubce/BceConstants.java b/src/main/java/com/baidubce/BceConstants.java index db6c5f45..1efb1e03 100644 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -16,5 +16,5 @@ * Common constants used by the whole SDK. */ public class BceConstants { - public static final String VERSION = "0.10.19"; + public static final String VERSION = "0.10.20"; } 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..3fa2372d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java @@ -0,0 +1,144 @@ +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.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 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); + 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 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); + } + + 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..e4e98538 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java @@ -0,0 +1,207 @@ +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"; + + 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 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 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/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/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..9ae5497e --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java @@ -0,0 +1,126 @@ +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 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 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..8d1ddcbd --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java @@ -0,0 +1,29 @@ +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; + + 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/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..0aae39b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java @@ -0,0 +1,110 @@ +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 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 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/IotDmClientHelper.java b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java index 24195a56..79eba0aa 100644 --- a/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmClientHelper.java @@ -38,6 +38,7 @@ 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"; @@ -56,33 +57,28 @@ static InternalRequest createRequestForV1(AbstractBceRequest bceRequest, HttpMet URI endpoint, SignOptions signOptions, String... pathVariables) { List path = new ArrayList(); path.addAll(Arrays.asList(VERSION, IOT, MANAGEMENT)); - 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; + return createRequest(bceRequest, httpMethod, endpoint, signOptions, path, pathVariables); } static InternalRequest createRequestForV2(AbstractBceRequest bceRequest, HttpMethodName httpMethod, - URI endpoint, SignOptions signOptions, String... pathVariables) { + 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); + } + + 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/IotDmV3Client.java b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java new file mode 100644 index 00000000..e6eec906 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java @@ -0,0 +1,217 @@ +/* + * 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.schema.SchemaBaseResponse; +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; + +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 ACCESS_DETAIL = "accessDetail"; + private static final String REMOVE = "remove"; + private static final String RESET = "reset"; + 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_REQUEST = "request should not be null."; + private static final String NULL_SCHEMA_ID = "schema id should not be null."; + + public IotDmV3Client(BceClientConfiguration config) { + super(config.getEndpoint() == null ? config.withEndpoint(ENDPOINT_HOST) : config, + IotDmClientHelper.IOT_DM_HANDLERS); + } + + 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 SchemaBaseResponse updateSchema(String schemaId, + SchemaUpdateRequest schemaUpdateRequest) { + return this.doOperation(schemaUpdateRequest, SchemaBaseResponse.class, null, SCHEMA, schemaId); + } + + public SchemaBaseResponse deleteSchema(String schemaId) { + Preconditions.checkNotNull(schemaId, NULL_SCHEMA_ID); + InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, + SCHEMA, schemaId); + return this.invokeHttpClient(internalRequest, SchemaBaseResponse.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 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 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/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/v3/device/CreateDeviceRequest.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java new file mode 100644 index 00000000..efea0bf2 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/CreateDeviceRequest.java @@ -0,0 +1,59 @@ +/* + * 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 String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + @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..c3a4a39d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAccessDetailResponse.java @@ -0,0 +1,62 @@ +/* + * 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 getting the access detail of a device. + */ +public class DeviceAccessDetailResponse extends AbstractBceResponse { + + private String tcpEndpoint; + + private String sslEndpoint; + + private String username; + + 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 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/v3/device/DeviceAttributes.java b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java new file mode 100644 index 00000000..e7bffcbb --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceAttributes.java @@ -0,0 +1,86 @@ +/* + * 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 JsonNode getDesired() { + return desired; + } + + public void setDesired(JsonNode desired) { + this.desired = desired; + } + + public int getProfileVersion() { + return profileVersion; + } + + public void setProfileVersion(int profileVersion) { + this.profileVersion = profileVersion; + } + + 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..98de5a64 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceListRequest.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.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 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..ceaeb777 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/DeviceProfile.java @@ -0,0 +1,132 @@ +/* + * 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 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; + + private JsonNode attributes; + + private DeviceAttributes device; + + 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; + } + + 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..e73c7301 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceProfileRequest.java @@ -0,0 +1,50 @@ +/* + * 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 DeviceAttributes getDevice() { + return device; + } + + public void setDevice(DeviceAttributes device) { + this.device = device; + } + + @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..d4e9bcc4 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceRegistryRequest.java @@ -0,0 +1,59 @@ +/* + * 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 String getSchemaId() { + return schemaId; + } + + public void setSchemaId(String schemaId) { + this.schemaId = schemaId; + } + + public Boolean getFavourite() { + return favourite; + } + + public void setFavourite(Boolean favourite) { + this.favourite = favourite; + } + + @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..a744cdd1 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/device/UpdateDeviceViewRequest.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 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 JsonNode getDesired() { + return desired; + } + + public void setDesired(JsonNode desired) { + this.desired = desired; + } + + 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/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/SchemaBaseResponse.java b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaBaseResponse.java new file mode 100644 index 00000000..fa7e9dae --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaBaseResponse.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.schema; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Represent the basic response of Schema POST/PUT/DELETE operations. + */ +public class SchemaBaseResponse extends AbstractBceResponse { + + public static String OK = "ok"; + + public static String FAILED = "failed"; + + private String result; + + private String error; + + public String getResult() { + return result; + } + + public void setResult(String result) { + this.result = result; + } + + public String getError() { + return error; + } + + public void setError(String error) { + this.error = error; + } + +} 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..5d8dc1a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateRequest.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 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 String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + @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..780f92b3 --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaCreateResponse.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.schema; + +/** + * Represent the response of creating a schema. + */ +public class SchemaCreateResponse extends SchemaBaseResponse { + + 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..7148a92a --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaProperty.java @@ -0,0 +1,89 @@ +/* + * 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 PropertyType getType() { + return type; + } + + public void setType(PropertyType type) { + this.type = type; + } + + public String getDisplayName() { + return displayName; + } + + public void setDisplayName(String displayName) { + this.displayName = displayName; + } + + public String getDefaultValue() { + return defaultValue; + } + + public void setDefaultValue(String defaultValue) { + this.defaultValue = defaultValue; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public enum PropertyType { + STRING("string"), + NUMBER("number"), + BOOL("bool"); + + 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..fb63a39d --- /dev/null +++ b/src/main/java/com/baidubce/services/iotdm/model/v3/schema/SchemaUpdateRequest.java @@ -0,0 +1,51 @@ +/* + * 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 List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + + @Override + public SchemaUpdateRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java index 2b5a2b5f..2f19efd5 100644 --- a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java @@ -60,4 +60,7 @@ public class TsdbConstants { public static final String TIME_UNIT_MONTH = "month"; public static final String TIME_UNIT_YEAR = "year"; + // Fill type. + public static final String FILL_TYPE_LINEAR = "Linear"; + public static final String FILL_TYPE_PREVIOUS = "Previous"; } diff --git a/src/main/java/com/baidubce/services/tsdb/model/FieldFilter.java b/src/main/java/com/baidubce/services/tsdb/model/FieldFilter.java new file mode 100644 index 00000000..ae41c250 --- /dev/null +++ b/src/main/java/com/baidubce/services/tsdb/model/FieldFilter.java @@ -0,0 +1,77 @@ +package com.baidubce.services.tsdb.model; + +/** + * Field filter. Support filter by value in query. + * + * @author Zhu Hongwei(zhuhongwei@baidu.com) + */ +public class FieldFilter { + + /** + * The field name for field filter. + */ + private String field; + + /** + * Optional. + * The value filter. It contains two parts. The first part is a operation such as <, <=, =, !=, > and >=. + * The second part is a value which can be a long type number, a double type number or a string surrounding by + * single quotations. + * Long or double value support <, <=, =, !=, > and >= operations. + * String value only support =, !=. + * Example: "= 111", "> 1.1", "!= 'abc'". + */ + private String value; + + public FieldFilter(String field, String value) { + this.field = field; + this.value = value; + } + + public FieldFilter(String field, ValueFilter valueFilter) { + this.field = field; + this.value = valueFilter.getOperation() + " " + valueFilter.getValue(); + } + + public String getField() { + return field; + } + + public String getValue() { + return value; + } + + /** + * Set field for field filter. + * + * @param field The field for field filter + * @return FieldFilter + */ + public FieldFilter withField(String field) { + this.field = field; + return this; + } + + /** + * Set value for field filter. + * + * @param value The value for field filter + * @return FieldFilter + */ + public FieldFilter withValue(String value) { + this.value = value; + return this; + } + + /** + * Set value for field filter. + * + * @param value The value for field filter. + * @return Filters + */ + public FieldFilter withValue(ValueFilter value) { + this.value = value.getOperation() + " " + value.getValue(); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/tsdb/model/Fill.java b/src/main/java/com/baidubce/services/tsdb/model/Fill.java new file mode 100644 index 00000000..6fb868b9 --- /dev/null +++ b/src/main/java/com/baidubce/services/tsdb/model/Fill.java @@ -0,0 +1,69 @@ +package com.baidubce.services.tsdb.model; + +/** + * Represent the fill in query. + * + * @author linpengxiang + */ +public class Fill { + + /** + * Required. + * The type of interpolation which can be "Linear" or "Previous". + */ + private String type; + + /** + * Required. + * The interval for interpolation. eg: "1 minute" or "5 hours". + * It will Interpolate a value when there are not value in the interval. + */ + private String interval; + + /** + * Optional. + * The maximum write interval for data points. eg: "1 minute", or "5 hours". + * It will consider data points in [start - maxWriteInterval, end + maxWriteInterval] for interpolation. + */ + private String maxWriteInterval; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getInterval() { + return interval; + } + + public void setInterval(String interval) { + this.interval = interval; + } + + public String getMaxWriteInterval() { + return maxWriteInterval; + } + + public void setMaxWriteInterval(String maxWriteInterval) { + this.maxWriteInterval = maxWriteInterval; + } + + public Fill withType(String type) { + setType(type); + return this; + } + + public Fill withInterval(String interval) { + setInterval(interval); + return this; + } + + public Fill withMaxWriteInterval(String maxWriteInterval) { + setMaxWriteInterval(maxWriteInterval); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/tsdb/model/Filters.java b/src/main/java/com/baidubce/services/tsdb/model/Filters.java index 90a95950..7cabc9d1 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Filters.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Filters.java @@ -1,5 +1,6 @@ package com.baidubce.services.tsdb.model; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -36,15 +37,25 @@ public class Filters { /** * Optional. - * The value filter. It contains two parts. The first part is a operation such as <, <=, =, !=, > and >=. - * The second part is a value which can be a long type number, a double type number or a string surronding by + * The value filter for single field or all multiple fields. + * It contains two parts. The first part is a operation such as <, <=, =, !=, > and >=. + * The second part is a value which can be a long type number, a double type number or a string surrounding by * single quotations. * Long or double value support <, <=, =, !=, > and >= operations. * String value only support =, !=. * Example: "= 111", "> 1.1", "!= 'abc'". + * Conflict with fields parameter. + * */ private String value; + /** + * Optional. + * The value filter for each multiple fields. + * Conflict with value parameter. + */ + private List fields; + public JsonNode getStart() { return start; } @@ -77,6 +88,14 @@ public void setValue(String value) { this.value = value; } + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + /** * Set value for filter. * @@ -99,6 +118,17 @@ public Filters withValue(String value) { return this; } + /** + * Set field filters. + * + * @param fields The field filters list. + * @return Filters + */ + public Filters withFields(List fields) { + this.fields = fields; + return this; + } + /** * Set absolute start time. * @@ -148,6 +178,31 @@ public Filters withTags(Map> tags) { return this; } + /** + * Add field filter to fields which just append not replace. + * + * @param field The field filter + * @return Filters + */ + public Filters addField(FieldFilter field) { + initialFields(); + fields.add(field); + return this; + } + + /** + * Add field filter to fields which just append not replace. + * + * @param field The field name for filter + * @param value The value filter + * @return Filters + */ + public Filters addField(String field, String value) { + initialFields(); + fields.add(new FieldFilter(field, value)); + return this; + } + /** * Add tag to tags which just append not replace. * @@ -197,4 +252,10 @@ private void initialTags() { tags = Maps.newHashMap(); } } + + private void initialFields() { + if (fields == null) { + fields = new ArrayList(); + } + } } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Group.java b/src/main/java/com/baidubce/services/tsdb/model/Group.java index dc5e53e9..01b3b129 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Group.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Group.java @@ -1,13 +1,12 @@ package com.baidubce.services.tsdb.model; import java.io.IOException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; -import com.baidubce.services.tsdb.TsdbConstants; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.node.BinaryNode; import com.google.common.collect.Lists; /** @@ -48,23 +47,14 @@ public List getTimeAndValueList() throws IOException { return Collections.emptyList(); } - boolean isBytes = false; - for (GroupInfo groupInfo : groupInfos) { - if (groupInfo.getName().equals(TsdbConstants.GROUP_INFO_NAME_TYPE) - && groupInfo.getType().equals(TsdbConstants.TYPE_BYTES)) { - isBytes = true; - break; - } - } - List list = Lists.newArrayList(); for (List nodeList : values) { - if (isBytes && nodeList.get(1).isTextual()) { - list.add(new TimeAndValue(nodeList.get(0).asLong(), - new BinaryNode(nodeList.get(1).binaryValue()))); - } else { - list.add(new TimeAndValue(nodeList.get(0).asLong(), nodeList.get(1))); + long timestamp = nodeList.get(0).asLong(); + List values = new ArrayList(); + for (int index = 1; index < nodeList.size(); index++) { + values.add(nodeList.get(index)); } + list.add(new TimeAndValue(timestamp, values)); } return list; } @@ -73,11 +63,20 @@ public static class TimeAndValue { private long time; - private JsonNode value; + private List value; public TimeAndValue(long time, JsonNode value) { this.time = time; - this.value = value; + this.value = Collections.singletonList(value); + } + + public TimeAndValue(long time, List values) { + this.time = time; + this.value = values; + } + + public int getValueLength() { + return value.size(); } public long getTime() { @@ -89,51 +88,93 @@ public void setTime(long time) { } public JsonNode getValue() { - return value; + return value.get(0); } public void setValue(JsonNode value) { - this.value = value; + this.value = Collections.singletonList(value); } @JsonIgnore public boolean isLong() { - return value.isIntegralNumber(); + return value.get(0).isIntegralNumber(); + } + + @JsonIgnore + public boolean isLong(int index) { + return value.get(index).isIntegralNumber(); } @JsonIgnore public boolean isDouble() { - return value.isFloatingPointNumber(); + return value.get(0).isFloatingPointNumber(); + } + + @JsonIgnore + public boolean isDouble(int index) { + return value.get(index).isFloatingPointNumber(); } + @Deprecated @JsonIgnore public boolean isString() { - return value.isTextual(); + throw new RuntimeException("Interface is deprecated"); } + @Deprecated @JsonIgnore public boolean isBytes() { - return value.isBinary(); + throw new RuntimeException("Interface is deprecated"); } @JsonIgnore public long getLongValue() { - return value.asLong(); + return value.get(0).asLong(); + } + + @JsonIgnore + public long getLongValue(int index) { + return value.get(index).asLong(); } @JsonIgnore public double getDoubleValue() { - return value.asDouble(); + return value.get(0).asDouble(); + } + + @JsonIgnore + public double getDoubleValue(int index) { + return value.get(index).asDouble(); } @JsonIgnore public String getStringValue() { - return value.asText(); + return value.get(0).asText(); + } + + @JsonIgnore + public String getStringValue(int index) { + return value.get(index).asText(); } @JsonIgnore public byte[] getBytesValue() throws IOException { - return value.binaryValue(); + return value.get(0).binaryValue(); + } + + @JsonIgnore + public byte[] getBytesValue(int index) throws IOException { + return value.get(index).binaryValue(); + } + + @JsonIgnore + public boolean isNull() { + return value.get(0).isNull(); + } + + @JsonIgnore + public boolean isNull(int index) { + return value.get(index).isNull(); } } } \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/tsdb/model/Query.java b/src/main/java/com/baidubce/services/tsdb/model/Query.java index 264ffe81..97d6963f 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Query.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Query.java @@ -17,10 +17,22 @@ public class Query { /** * Optional. - * The field name. + * The field name, conflict with fields parameter. */ private String field; + /** + * Optional. + * The field names, conflict with field parameter. + */ + private List fields; + + /** + * Optional. + * The tag keys. + */ + private List tags; + /** * Required. * The filters. @@ -52,6 +64,20 @@ public class Query { */ private String order; + /** + * Optional. + * The fill for interpolation. + */ + private Fill fill; + + public Fill getFill() { + return fill; + } + + public void setFill(Fill fill) { + this.fill = fill; + } + public String getMetric() { return metric; } @@ -68,6 +94,22 @@ public void setField(String field) { this.field = field; } + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + public Filters getFilters() { return filters; } @@ -108,6 +150,11 @@ public void setOrder(String order) { this.order = order; } + public Query withFill(Fill fill) { + this.fill = fill; + return this; + } + public Query withMetric(String metric) { this.metric = metric; return this; @@ -118,6 +165,16 @@ public Query withField(String field) { return this; } + public Query withFields(List fields) { + this.fields = fields; + return this; + } + + public Query withTags(List tags) { + this.tags = tags; + return this; + } + public Query withFilters(Filters filters) { this.filters = filters; return this; diff --git a/src/main/java/com/baidubce/services/tsdb/model/Result.java b/src/main/java/com/baidubce/services/tsdb/model/Result.java index f8ecbbc7..8bf2817f 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Result.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Result.java @@ -11,6 +11,10 @@ public class Result { private String field; + private List fields; + + private List tags; + private long rawCount; private List groups; @@ -31,6 +35,22 @@ public void setField(String field) { this.field = field; } + public List getFields() { + return fields; + } + + public void setFields(List fields) { + this.fields = fields; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + public long getRawCount() { return rawCount; } From f29cd157ca86cdf17337a1107df2ae3bf4ea36ed Mon Sep 17 00:00:00 2001 From: jianhengyi Date: Wed, 2 Aug 2017 10:59:47 +0800 Subject: [PATCH 03/53] 0.10.21 --- pom.xml | 2 +- src/main/java/com/baidubce/BceConstants.java | 2 +- .../com/baidubce/services/bos/BosClient.java | 6 +- .../services/bos/BosClientConfiguration.java | 31 +++++ .../bos/model/GenericBucketRequest.java | 5 +- .../services/iotalarm/IotAlarmClient.java | 19 +++ .../services/iotalarm/model/Alarm.java | 9 ++ .../iotalarm/model/AlarmNoticeMsgType.java | 11 ++ .../services/iotalarm/model/BatchIds.java | 20 +++ .../iotalarm/model/CreateAlarmRequest.java | 9 ++ .../iotalarm/model/UpdateAlarmRequest.java | 9 ++ .../services/iotdm/IotDmV3Client.java | 9 +- .../model/v3/device/CreateDeviceRequest.java | 15 ++ .../model/v3/device/DeviceAttributes.java | 15 ++ .../model/v3/device/DeviceListRequest.java | 5 + .../v3/device/UpdateDeviceProfileRequest.java | 10 ++ .../device/UpdateDeviceRegistryRequest.java | 15 ++ .../v3/device/UpdateDeviceViewRequest.java | 10 ++ .../model/v3/schema/SchemaCreateRequest.java | 15 ++ .../model/v3/schema/SchemaCreateResponse.java | 4 +- .../iotdm/model/v3/schema/SchemaProperty.java | 25 ++++ .../model/v3/schema/SchemaUpdateRequest.java | 10 ++ .../services/modbus/ModbusClient.java | 11 +- .../modbus/model/gateway/Gateway.java | 128 ++++-------------- .../modbus/model/gateway/GatewayResponse.java | 12 +- .../model/gateway/ListGatewayResponse.java | 6 +- .../com/baidubce/services/vod/VodClient.java | 77 ++++++++++- .../services/vod/model/MediaMeta.java | 13 +- 28 files changed, 382 insertions(+), 121 deletions(-) create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/AlarmNoticeMsgType.java create mode 100644 src/main/java/com/baidubce/services/iotalarm/model/BatchIds.java diff --git a/pom.xml b/pom.xml index 0d0bec7e..277d243d 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.20 + 0.10.21 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html diff --git a/src/main/java/com/baidubce/BceConstants.java b/src/main/java/com/baidubce/BceConstants.java index 1efb1e03..df3db726 100644 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -16,5 +16,5 @@ * Common constants used by the whole SDK. */ public class BceConstants { - public static final String VERSION = "0.10.20"; + public static final String VERSION = "0.10.21"; } diff --git a/src/main/java/com/baidubce/services/bos/BosClient.java b/src/main/java/com/baidubce/services/bos/BosClient.java index 1d05e673..926cfe5c 100644 --- a/src/main/java/com/baidubce/services/bos/BosClient.java +++ b/src/main/java/com/baidubce/services/bos/BosClient.java @@ -497,8 +497,9 @@ public URL generatePresignedUrl(GeneratePresignedUrlRequest request) { // 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(); InternalRequest internalRequest = new InternalRequest(httpMethod, HttpUtils - .appendUri(this.getEndpoint(), URL_PREFIX, request.getBucketName(), request.getKey())); + .appendUri(this.getEndpoint(), URL_PREFIX, bucketName, request.getKey())); internalRequest.setCredentials(request.getRequestCredentials()); SignOptions options = new SignOptions(); options.setExpirationInSeconds(request.getExpiration()); @@ -1393,7 +1394,8 @@ private static void populateRequestMetadata(InternalRequest request, ObjectMetad private InternalRequest createRequest(AbstractBceRequest bceRequest, HttpMethodName httpMethod) { String bucketName = null; String key = null; - if (bceRequest instanceof GenericBucketRequest) { + // when custom_endpoint, bucketName should be null when set up InternalRequest. + if (bceRequest instanceof GenericBucketRequest && !((BosClientConfiguration)this.config).isCnameEnabled()) { bucketName = ((GenericBucketRequest) bceRequest).getBucketName(); } if (bceRequest instanceof GenericObjectRequest) { diff --git a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java index 675f26b5..c54efb3f 100644 --- a/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java +++ b/src/main/java/com/baidubce/services/bos/BosClientConfiguration.java @@ -26,6 +26,12 @@ public class BosClientConfiguration extends BceClientConfiguration { public static final int DEFAULT_STREAM_BUFFER_SIZE = 5 * 1024 * 1024; private int streamBufferSize = DEFAULT_STREAM_BUFFER_SIZE; + /** + * 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; + public int getStreamBufferSize() { return this.streamBufferSize; } @@ -52,6 +58,30 @@ 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; + } + @Override public BosClientConfiguration withProtocol(Protocol protocol) { this.setProtocol(protocol); @@ -160,4 +190,5 @@ public BosClientConfiguration withCredentials(BceCredentials credentials) { this.setCredentials(credentials); return this; } + } 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/iotalarm/IotAlarmClient.java b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java index 3fa2372d..21cfe19d 100644 --- a/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java +++ b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java @@ -15,6 +15,7 @@ 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; @@ -40,6 +41,8 @@ public class IotAlarmClient extends AbstractBceClient { 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() }; @@ -79,6 +82,14 @@ public CommonResponse deleteAlarm(String 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); @@ -103,6 +114,14 @@ public CommonResponse recoverAlarm(String alarmId) { 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(); diff --git a/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java index e4e98538..2d14c30d 100644 --- a/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java +++ b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java @@ -28,6 +28,7 @@ public class Alarm extends AbstractBceResponse { private String smsReceiver; private String smsVars; private String smsMsgType; + private String mqttMsgType; private String destTopic; private String alarmState; private long startTime; @@ -148,6 +149,14 @@ 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; } 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/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/CreateAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java index 9ae5497e..ffb17838 100644 --- a/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java +++ b/src/main/java/com/baidubce/services/iotalarm/model/CreateAlarmRequest.java @@ -18,6 +18,7 @@ public class CreateAlarmRequest extends GenericAccountRequest { private String smsReceiver; private String smsVars; private String smsMsgType; + private String mqttMsgType; private String destTopic; public String getName() { @@ -116,6 +117,14 @@ 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; } diff --git a/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java index 0aae39b5..a57091b9 100644 --- a/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java +++ b/src/main/java/com/baidubce/services/iotalarm/model/UpdateAlarmRequest.java @@ -18,6 +18,7 @@ public class UpdateAlarmRequest extends GenericAccountRequest { private String smsReceiver; private String smsVars; private String smsMsgType; + private String mqttMsgType; private String destTopic; public String getName() { @@ -100,6 +101,14 @@ 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; } diff --git a/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java index e6eec906..93666c0b 100644 --- a/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java +++ b/src/main/java/com/baidubce/services/iotdm/IotDmV3Client.java @@ -29,7 +29,6 @@ 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.schema.SchemaBaseResponse; 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; @@ -143,16 +142,16 @@ public SchemaListResponse getSchemas(int pageNo, int pageSize, String orderBy, S return this.invokeHttpClient(internalRequest, SchemaListResponse.class); } - public SchemaBaseResponse updateSchema(String schemaId, + public void updateSchema(String schemaId, SchemaUpdateRequest schemaUpdateRequest) { - return this.doOperation(schemaUpdateRequest, SchemaBaseResponse.class, null, SCHEMA, schemaId); + this.doOperation(schemaUpdateRequest, AbstractBceResponse.class, null, SCHEMA, schemaId); } - public SchemaBaseResponse deleteSchema(String schemaId) { + public void deleteSchema(String schemaId) { Preconditions.checkNotNull(schemaId, NULL_SCHEMA_ID); InternalRequest internalRequest = createRequest(new GenericAccountRequest(), HttpMethodName.DELETE, SCHEMA, schemaId); - return this.invokeHttpClient(internalRequest, SchemaBaseResponse.class); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); } 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 index efea0bf2..4146bb42 100644 --- 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 @@ -34,6 +34,11 @@ public void setDeviceName(String deviceName) { this.deviceName = deviceName; } + public CreateDeviceRequest withDeviceName(String deviceName) { + setDeviceName(deviceName); + return this; + } + public String getDescription() { return description; } @@ -42,6 +47,11 @@ public void setDescription(String description) { this.description = description; } + public CreateDeviceRequest withDescription(String description) { + setDescription(description); + return this; + } + public String getSchemaId() { return schemaId; } @@ -50,6 +60,11 @@ 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); 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 index e7bffcbb..835acc8f 100644 --- 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 @@ -35,6 +35,11 @@ public void setReported(JsonNode reported) { this.reported = reported; } + public DeviceAttributes withReported(JsonNode reported) { + setReported(reported); + return this; + } + public JsonNode getDesired() { return desired; } @@ -43,6 +48,11 @@ public void setDesired(JsonNode desired) { this.desired = desired; } + public DeviceAttributes withDesired(JsonNode desired) { + setDesired(desired); + return this; + } + public int getProfileVersion() { return profileVersion; } @@ -51,6 +61,11 @@ public void setProfileVersion(int profileVersion) { this.profileVersion = profileVersion; } + public DeviceAttributes withProfileVersion(int profileVersion) { + setProfileVersion(profileVersion); + return this; + } + public TimeAttributes getLastUpdatedTime() { return lastUpdatedTime; } 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 index 98de5a64..d4c803bb 100644 --- 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 @@ -28,6 +28,11 @@ public List getDevices() { return devices; } + public DeviceListRequest withDevices(List devices) { + setDevices(devices); + return this; + } + public void setDevices(List devices) { this.devices = devices; } 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 index e73c7301..d5415696 100644 --- 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 @@ -33,6 +33,11 @@ public void setAttributes(JsonNode attributes) { this.attributes = attributes; } + public UpdateDeviceProfileRequest withAttributes(JsonNode attributes) { + setAttributes(attributes); + return this; + } + public DeviceAttributes getDevice() { return device; } @@ -41,6 +46,11 @@ 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); 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 index d4e9bcc4..9e68adfa 100644 --- 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 @@ -34,6 +34,11 @@ public void setDescription(String description) { this.description = description; } + public UpdateDeviceRegistryRequest withDescription(String description) { + setDescription(description); + return this; + } + public String getSchemaId() { return schemaId; } @@ -42,6 +47,11 @@ public void setSchemaId(String schemaId) { this.schemaId = schemaId; } + public UpdateDeviceRegistryRequest withSchemaId(String schemaId) { + setSchemaId(schemaId); + return this; + } + public Boolean getFavourite() { return favourite; } @@ -50,6 +60,11 @@ 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); 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 index a744cdd1..45bda0c1 100644 --- 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 @@ -35,6 +35,11 @@ public void setReported(JsonNode reported) { this.reported = reported; } + public UpdateDeviceViewRequest withReported(JsonNode reported) { + setReported(reported); + return this; + } + public JsonNode getDesired() { return desired; } @@ -43,6 +48,11 @@ public void setDesired(JsonNode desired) { this.desired = desired; } + public UpdateDeviceViewRequest withDesired(JsonNode desired) { + setDesired(desired); + return this; + } + public int getProfileVersion() { return profileVersion; } 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 index 5d8dc1a8..a96b0e77 100644 --- 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 @@ -36,6 +36,11 @@ public void setName(String name) { this.name = name; } + public SchemaCreateRequest withName(String name) { + setName(name); + return this; + } + public String getDescription() { return description; } @@ -44,6 +49,11 @@ public void setDescription(String description) { this.description = description; } + public SchemaCreateRequest withDescription(String description) { + setDescription(description); + return this; + } + public List getProperties() { return properties; } @@ -52,6 +62,11 @@ 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); 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 index 780f92b3..359e044f 100644 --- 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 @@ -12,10 +12,12 @@ */ package com.baidubce.services.iotdm.model.v3.schema; +import com.baidubce.model.AbstractBceResponse; + /** * Represent the response of creating a schema. */ -public class SchemaCreateResponse extends SchemaBaseResponse { +public class SchemaCreateResponse extends AbstractBceResponse { private String schemaId; 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 index 7148a92a..20561edd 100644 --- 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 @@ -37,6 +37,11 @@ public void setName(String name) { this.name = name; } + public SchemaProperty withName(String name) { + setName(name); + return this; + } + public PropertyType getType() { return type; } @@ -45,6 +50,11 @@ public void setType(PropertyType type) { this.type = type; } + public SchemaProperty withType(PropertyType type) { + setType(type); + return this; + } + public String getDisplayName() { return displayName; } @@ -53,6 +63,11 @@ public void setDisplayName(String displayName) { this.displayName = displayName; } + public SchemaProperty withDisplayName(String displayName) { + setDisplayName(displayName); + return this; + } + public String getDefaultValue() { return defaultValue; } @@ -61,6 +76,11 @@ public void setDefaultValue(String defaultValue) { this.defaultValue = defaultValue; } + public SchemaProperty withDefaultValue(String defaultValue) { + setDefaultValue(defaultValue); + return this; + } + public String getUnit() { return unit; } @@ -69,6 +89,11 @@ public void setUnit(String unit) { this.unit = unit; } + public SchemaProperty withUnit(String unit) { + setUnit(unit); + return this; + } + public enum PropertyType { STRING("string"), NUMBER("number"), 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 index fb63a39d..ca8cb06e 100644 --- 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 @@ -34,6 +34,11 @@ public void setDescription(String description) { this.description = description; } + public SchemaUpdateRequest withDescription(String description) { + setDescription(description); + return this; + } + public List getProperties() { return properties; } @@ -42,6 +47,11 @@ 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); diff --git a/src/main/java/com/baidubce/services/modbus/ModbusClient.java b/src/main/java/com/baidubce/services/modbus/ModbusClient.java index 1ceed36a..59bbfa01 100755 --- a/src/main/java/com/baidubce/services/modbus/ModbusClient.java +++ b/src/main/java/com/baidubce/services/modbus/ModbusClient.java @@ -36,7 +36,6 @@ 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.Gateway; import com.baidubce.services.modbus.model.gateway.GatewayResponse; import com.baidubce.services.modbus.model.gateway.ListGatewayRequest; import com.baidubce.services.modbus.model.gateway.ListGatewayResponse; @@ -100,7 +99,7 @@ public ListGatewayResponse listGateway(ListGatewayRequest request) { request.getPageNo(), request.getPageSize()); ListGatewayResponse response = this.invokeHttpClient(internalRequest, ListGatewayResponse.class); - for (Gateway gateway : response.getResult()) { + for (GatewayResponse gateway : response.getResult()) { gateway.setDeviceNum(getDeviceNumByGatewayUuid(gateway.getUuid())); } return response; @@ -351,6 +350,14 @@ public void deployGateway() { 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."); 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 index ad156c72..72f549b0 100755 --- a/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/Gateway.java @@ -1,126 +1,54 @@ package com.baidubce.services.modbus.model.gateway; -import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +/** + * Created by yuanyoujun on 2017/7/31. + */ +public interface Gateway { + public String getUuid(); -@JsonIgnoreProperties(ignoreUnknown = true) -public class Gateway { - public String getUuid() { - return uuid; - } + public void setUuid(String uuid); - public void setUuid(String uuid) { - this.uuid = uuid; - } + public boolean isUseSsl(); - public boolean isUseSsl() { - return useSsl; - } + public void setUseSsl(boolean useSsl); - public void setUseSsl(boolean useSsl) { - this.useSsl = useSsl; - } + public String getUsername(); - public String getUsername() { - return username; - } + public void setUsername(String username); - public void setUsername(String username) { - this.username = username; - } + public String getPassword(); - public String getPassword() { - return password; - } + public void setPassword(String password); - public void setPassword(String password) { - this.password = password; - } + public String getHost(); - public String getHost() { - return host; - } + public void setHost(String host); - public void setHost(String host) { - this.host = host; - } + public String getCommandTopic(); - public String getCommandTopic() { - return commandTopic; - } + public void setCommandTopic(String commandTopic); - public void setCommandTopic(String commandTopic) { - this.commandTopic = commandTopic; - } + public String getState(); - public String getState() { - return state; - } + public void setState(String state); - public void setState(String state) { - this.state = state; - } + public String getDescription(); - public String getDescription() { - return description; - } + public void setDescription(String description); - public void setDescription(String description) { - this.description = description; - } + public String getCode(); - public String getCode() { - return code; - } + public void setCode(String code); - public void setCode(String code) { - this.code = code; - } + public String getCreateTime(); - public String getCreateTime() { - return createTime; - } + public void setCreateTime(String createTime); - public void setCreateTime(String createTime) { - this.createTime = createTime; - } + public String getUpdateTime(); - public String getUpdateTime() { - return updateTime; - } + public void setUpdateTime(String updateTime); - public void setUpdateTime(String updateTime) { - this.updateTime = updateTime; - } + public int getDeviceNum(); - 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 state; // ENABLED, DISABLED - - private String description; // 网关描述 - - private String code; - - private String createTime; - - private String updateTime; - - private int deviceNum; + 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 index 6756484b..d299e9d0 100755 --- a/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/GatewayResponse.java @@ -4,7 +4,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; @JsonIgnoreProperties(ignoreUnknown = true) -public class GatewayResponse extends AbstractBceResponse { +public class GatewayResponse extends AbstractBceResponse implements Gateway { public String getUuid() { return uuid; @@ -54,6 +54,14 @@ 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; } @@ -114,6 +122,8 @@ public void setDeviceNum(int deviceNum) { private String commandTopic; + private String backControlTopic; + private String state; // ENABLED, DISABLED private String description; // 网关描述 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 index 32aaee74..369d4bf8 100755 --- a/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java +++ b/src/main/java/com/baidubce/services/modbus/model/gateway/ListGatewayResponse.java @@ -9,7 +9,7 @@ public class ListGatewayResponse extends AbstractBceResponse { private int totalCount; - private List result; + private List result; private String order; @@ -35,11 +35,11 @@ public void setTotalCount(int totalCount) { this.totalCount = totalCount; } - public List getResult() { + public List getResult() { return result; } - public void setResult(List result) { + public void setResult(List result) { this.result = result; } diff --git a/src/main/java/com/baidubce/services/vod/VodClient.java b/src/main/java/com/baidubce/services/vod/VodClient.java index a752ac4f..ef726036 100644 --- a/src/main/java/com/baidubce/services/vod/VodClient.java +++ b/src/main/java/com/baidubce/services/vod/VodClient.java @@ -126,6 +126,7 @@ public class VodClient extends AbstractBceClient { private static final String PARA_AUTO_START_NEW = "autostart"; private static final String PARA_ATTRIBUTES = "attributes"; private static final String PARA_APPLY = "apply"; + private static final String PARA_APPLY_MODE = "mode"; private static final String PARA_PROCESS = "process"; private static final String PARA_GENDELIVERY = "delivery"; private static final String PARA_GENCODE = "code"; @@ -194,7 +195,7 @@ public VodClient(BceClientConfiguration vodConfig) { /** * Uploads the specified file to Bos under the specified bucket and key name. * - * @param title media titile. + * @param title media title. * @param description media description. * @param file The file containing the data to be uploaded to VOD. * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default @@ -209,6 +210,30 @@ public CreateMediaResourceResponse createMediaResource( String transcodingPresetGroupName, int priority) throws FileNotFoundException { + return createMediaResource(title, description, file, transcodingPresetGroupName, priority, null); + } + + + /** + * Uploads the specified file to Bos under the specified bucket and key name. + * + * @param title media title. + * @param description media description. + * @param file The file containing the data to be uploaded to VOD. + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own task + * @param mode the mode of the media resource + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + * @throws FileNotFoundException + */ + public CreateMediaResourceResponse createMediaResource( + String title, + String description, + File file, + String transcodingPresetGroupName, + int priority, + String mode) + throws FileNotFoundException { if (!file.exists()) { throw new FileNotFoundException("The media file " + file.getAbsolutePath() + " doesn't exist!"); } @@ -217,7 +242,12 @@ public CreateMediaResourceResponse createMediaResource( String filename = file.getName(); sourceExtension = getFileExtension(filename); // get a BOS bucket and extract mediaId from it - GenerateMediaIdResponse generateMediaIdresponse = applyMedia(); + GenerateMediaIdResponse generateMediaIdresponse; + if (mode == null) { + generateMediaIdresponse = applyMedia(); + } else { + generateMediaIdresponse = applyMedia(mode); + } String bosKey = generateMediaIdresponse.getSourceKey(); String mediaId = generateMediaIdresponse.getMediaId(); String bucket = generateMediaIdresponse.getSourceBucket(); @@ -264,6 +294,30 @@ public CreateMediaResourceResponse createMediaResource( String description, String transcodingPresetGroupName, int priority) { + return createMediaResource( + sourceBucket, sourceKey, title, description, transcodingPresetGroupName, priority, null); + } + + /** + * Load a media resource from BOS to VOD. + * + * @param sourceBucket The bucket name of the media resource in BOS + * @param sourceKey The key name of the media resource in BOS + * @param title The title string of the media resource + * @param description The description string of the media resource + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own jobs + * @param mode the mode of the media resource + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public CreateMediaResourceResponse createMediaResource( + String sourceBucket, + String sourceKey, + String title, + String description, + String transcodingPresetGroupName, + int priority, + String mode) { checkStringNotEmpty(sourceBucket, "sourceBucket should not be null or empty!"); checkStringNotEmpty(sourceKey, "key should not be null or empty!"); @@ -277,7 +331,12 @@ public CreateMediaResourceResponse createMediaResource( String sourceExtension = null; sourceExtension = getFileExtension(sourceKey); // generate media Id - GenerateMediaIdResponse generateMediaIdresponse = applyMedia(); + GenerateMediaIdResponse generateMediaIdresponse; + if (mode == null) { + generateMediaIdresponse = applyMedia(); + } else { + generateMediaIdresponse = applyMedia(mode); + } String mediaId = generateMediaIdresponse.getMediaId(); String targetBucket = generateMediaIdresponse.getSourceBucket(); String targetKey = generateMediaIdresponse.getSourceKey(); @@ -319,6 +378,18 @@ public GenerateMediaIdResponse applyMedia() { return invokeHttpClient(internalRequest, GenerateMediaIdResponse.class); } + + public GenerateMediaIdResponse applyMedia(String mode) { + GenerateMediaIdRequest request = new GenerateMediaIdRequest(); + InternalRequest internalRequest = + createRequest(HttpMethodName.POST, request, PATH_MEDIA); + internalRequest.addParameter(PARA_APPLY, null); + internalRequest.addParameter(PARA_APPLY_MODE, mode); + + return invokeHttpClient(internalRequest, GenerateMediaIdResponse.class); + } + + /** * Gets the properties of specific media resource managed by VOD service. * diff --git a/src/main/java/com/baidubce/services/vod/model/MediaMeta.java b/src/main/java/com/baidubce/services/vod/model/MediaMeta.java index d40af7d9..dc7b8f11 100644 --- a/src/main/java/com/baidubce/services/vod/model/MediaMeta.java +++ b/src/main/java/com/baidubce/services/vod/model/MediaMeta.java @@ -1,10 +1,21 @@ package com.baidubce.services.vod.model; public class MediaMeta { + + private Long sourceSizeInBytes; + private Long sizeInBytes; private Long durationInSeconds; + public Long getSourceSizeInBytes() { + return sourceSizeInBytes; + } + + public void setSourceSizeInBytes(Long sourceSizeInBytes) { + this.sourceSizeInBytes = sourceSizeInBytes; + } + public Long getSizeInBytes() { return sizeInBytes; } @@ -27,10 +38,10 @@ public MediaMeta() { @Override public String toString() { StringBuilder sb = new StringBuilder("MediaMeta { \n"); + sb.append(" sourceSizeInBytes = ").append(sourceSizeInBytes).append("\n"); sb.append(" sizeInBytes = ").append(sizeInBytes).append("\n"); sb.append(" durationInSeconds = ").append(durationInSeconds).append("\n"); sb.append(" }"); return sb.toString(); } - } From a3dc3a1cf1669fc5b9fc85f78e38d12641f8b011 Mon Sep 17 00:00:00 2001 From: jianhengyi Date: Mon, 30 Oct 2017 12:15:52 +0800 Subject: [PATCH 04/53] 0.10.22 --- pom.xml | 2 +- src/main/java/com/baidubce/BceConstants.java | 2 +- src/main/java/com/baidubce/http/Headers.java | 4 + .../java/com/baidubce/model/ListRequest.java | 100 + .../java/com/baidubce/model/ListResponse.java | 130 ++ .../services/bacnet/BacnetClient.java | 242 +++ .../services/bacnet/model/BacnetDevice.java | 121 ++ .../services/bacnet/model/BacnetGateway.java | 130 ++ .../bacnet/model/BacnetGatewayCredential.java | 56 + .../services/bacnet/model/BacnetObject.java | 76 + .../services/bacnet/model/BacnetObjectId.java | 34 + .../model/BacnetObjectPresentValue.java | 46 + .../model/CreateBacnetGatewayRequest.java | 100 + .../services/bacnet/model/IdResponse.java | 20 + .../model/ListBacnetDeviceResponse.java | 49 + .../model/ListBacnetGatewayResponse.java | 49 + .../model/ListBacnetObjectResponse.java | 49 + .../model/ListObjectPresentValueRequest.java | 20 + .../model/ListObjectPresentValueResponse.java | 22 + .../services/bacnet/model/ListRequest.java | 28 + .../bacnet/model/SubBacnetObjectRequest.java | 29 + .../model/UpdateBacnetGatewayRequest.java | 91 + ...UpdateBacnetObjectPresentValueRequest.java | 20 + .../bacnet/model/UpdateDestTopicsRequest.java | 18 + .../com/baidubce/services/bcc/BccClient.java | 1625 +++++++++++++++++ .../services/bcc/BccClientConfiguration.java | 22 + .../baidubce/services/bcc/model/Billing.java | 77 + .../services/bcc/model/CreateCdsModel.java | 103 ++ .../services/bcc/model/ImageModel.java | 183 ++ .../services/bcc/model/InstanceModel.java | 277 +++ .../services/bcc/model/InstanceTypeModel.java | 98 + .../services/bcc/model/Reservation.java | 77 + .../bcc/model/SecurityGroupModel.java | 98 + .../bcc/model/SecurityGroupRuleModel.java | 223 +++ .../services/bcc/model/SnapshotModel.java | 143 ++ .../bcc/model/VolumeAttachmentModel.java | 67 + .../services/bcc/model/VolumeModel.java | 201 ++ .../bcc/model/image/CreateImageRequest.java | 150 ++ .../bcc/model/image/CreateImageResponse.java | 35 + .../bcc/model/image/DeleteImageRequest.java | 57 + .../bcc/model/image/GetImageRequest.java | 57 + .../bcc/model/image/GetImageResponse.java | 36 + .../bcc/model/image/ListImagesRequest.java | 85 + .../bcc/model/image/ListImagesResponse.java | 37 + .../instance/BindSecurityGroupRequest.java | 83 + .../model/instance/CreateInstanceRequest.java | 450 +++++ .../instance/CreateInstanceResponse.java | 42 + .../model/instance/GetInstanceRequest.java | 58 + .../model/instance/GetInstanceResponse.java | 34 + .../model/instance/GetInstanceVncRequest.java | 57 + .../instance/GetInstanceVncResponse.java | 35 + .../bcc/model/instance/InstanceAction.java | 68 + .../bcc/model/instance/InstanceType.java | 35 + .../instance/ListInstanceSpecsRequest.java | 34 + .../instance/ListInstanceSpecsResponse.java | 44 + .../model/instance/ListInstancesRequest.java | 119 ++ .../model/instance/ListInstancesResponse.java | 38 + .../ModifyInstanceAttributesRequest.java | 85 + .../ModifyInstancePasswordRequest.java | 99 + .../PurchaseReservedInstanceRequeset.java | 116 ++ .../model/instance/RebootInstanceRequest.java | 89 + .../instance/RebuildInstanceRequest.java | 118 ++ .../instance/ReleaseInstanceRequest.java | 57 + .../model/instance/ResizeInstanceRequest.java | 142 ++ .../model/instance/StartInstanceRequest.java | 60 + .../model/instance/StopInstanceRequest.java | 89 + .../instance/UnbindSecurityGroupRequest.java | 82 + .../CreateSecurityGroupRequest.java | 161 ++ .../CreateSecurityGroupResponse.java | 41 + .../DeleteSecurityGroupRequest.java | 58 + .../ListSecurityGroupsRequest.java | 102 ++ .../ListSecurityGroupsResponse.java | 37 + .../SecurityGroupRuleOperateRequest.java | 92 + .../model/snapshot/CreateSnapshotRequest.java | 145 ++ .../snapshot/CreateSnapshotResponse.java | 40 + .../model/snapshot/DeleteSnapshotRequest.java | 58 + .../model/snapshot/GetSnapshotRequest.java | 57 + .../model/snapshot/GetSnapshotResponse.java | 42 + .../model/snapshot/ListSnapshotsRequest.java | 83 + .../model/snapshot/ListSnapshotsResponse.java | 37 + .../bcc/model/volume/AttachVolumeRequest.java | 81 + .../model/volume/AttachVolumeResponse.java | 42 + .../bcc/model/volume/CreateVolumeRequest.java | 217 +++ .../model/volume/CreateVolumeResponse.java | 42 + .../bcc/model/volume/DetachVolumeRequest.java | 84 + .../bcc/model/volume/EphemeralDisk.java | 68 + .../bcc/model/volume/GetVolumeRequest.java | 58 + .../bcc/model/volume/GetVolumeResponse.java | 42 + .../bcc/model/volume/ListVolumesRequest.java | 102 ++ .../bcc/model/volume/ListVolumesResponse.java | 37 + .../volume/PurchaseReservedVolumeRequest.java | 119 ++ .../model/volume/ReleaseVolumeRequest.java | 52 + .../bcc/model/volume/ResizeVolumeRequest.java | 118 ++ .../model/volume/RollbackVolumeRequest.java | 88 + .../bcc/model/volume/VolumeAction.java | 44 + .../bcc/model/zone/ListZonesResponse.java | 35 + .../services/bcc/model/zone/ZoneModel.java | 38 + .../binaryparser/BinaryParserClient.java | 127 ++ .../binaryparser/model/BinaryParser.java | 63 + .../model/CreateBinaryParserRequest.java | 54 + .../model/ListBinaryParserRequest.java | 28 + .../model/ListBinaryParserResponse.java | 48 + .../model/UpdateBinaryParserRequest.java | 45 + .../com/baidubce/services/bmr/BmrClient.java | 49 + .../services/bmr/model/GetStepResponse.java | 9 + .../bmr/model/ModifyInstanceGroupConfig.java | 28 + .../model/ModifyInstanceGroupsRequest.java | 104 ++ .../services/bmr/model/SparkStepConfig.java | 78 + .../com/baidubce/services/bmr/model/Step.java | 9 + .../com/baidubce/services/bos/BosClient.java | 52 + .../bos/model/FetchObjectRequest.java | 190 ++ .../bos/model/FetchObjectResponse.java | 114 ++ .../com/baidubce/services/cdn/CdnClient.java | 103 +- .../services/cdn/model/DescribeIpRequest.java | 65 + .../cdn/model/DescribeIpResponse.java | 44 + .../services/cdn/model/HttpsConfig.java | 87 + .../services/cdn/model/OriginPeer.java | 52 +- .../services/cdn/model/RequestAuth.java | 121 ++ .../cdn/model/SetHttpsConfigRequest.java | 65 + .../cdn/model/SetHttpsConfigResponse.java | 19 + .../cdn/model/SetRequestAuthRequest.java | 65 + .../cdn/model/SetRequestAuthResponse.java | 19 + .../com/baidubce/services/dcc/DccClient.java | 148 ++ .../dcc/model/DedicatedHostModel.java | 168 ++ .../services/dcc/model/EphemeralDisk.java | 59 + .../dcc/model/GetDedicatedHostRequest.java | 51 + .../dcc/model/GetDedicatedHostResponse.java | 33 + .../dcc/model/ListDedicatedHostsRequest.java | 36 + .../dcc/model/ListDedicatedHostsResponse.java | 33 + .../services/dcc/model/ListRequest.java | 60 + .../services/dcc/model/ListResponse.java | 112 ++ .../services/dcc/model/ResourceUsage.java | 96 + .../com/baidubce/services/eip/EipClient.java | 400 ++++ .../baidubce/services/eip/model/Billing.java | 108 ++ .../services/eip/model/BindEipRequest.java | 92 + .../services/eip/model/CreateEipRequest.java | 91 + .../services/eip/model/CreateEipResponse.java | 21 + .../services/eip/model/ListEipsRequest.java | 61 + .../services/eip/model/ListEipsResponse.java | 148 ++ .../services/eip/model/ListRequest.java | 60 + .../services/eip/model/ListResponse.java | 112 ++ .../eip/model/PurchaseReservedEipRequest.java | 76 + .../services/eip/model/ReleaseEipRequest.java | 55 + .../services/eip/model/ResizeEipRequest.java | 75 + .../services/eip/model/UnbindEipRequest.java | 55 + .../services/iotalarm/IotAlarmClient.java | 11 + .../services/iotalarm/model/Alarm.java | 3 + .../iotalarm/model/ListAlarmRequest.java | 27 + .../services/iothub/IotHubClient.java | 63 + .../iothub/model/AccountMqttUsageRequest.java | 27 + .../BatchGetMqttClientStatusRequest.java | 16 + .../BatchGetMqttClientStatusResponse.java | 18 + .../services/iothub/model/DailyMqttUsage.java | 42 + .../iothub/model/MqttClientStatus.java | 14 + .../iothub/model/MqttClientStatusRequest.java | 19 + .../model/MqttClientStatusResponse.java | 16 + .../services/iothub/model/MqttUsage.java | 28 + .../iothub/model/MqttUsageResponse.java | 30 + .../QueryEndpointDailyMqttUsageRequest.java | 26 + .../QueryEndpointDailyMqttUsageResponse.java | 18 + .../iotsmsreceiver/IotSmsReceiverClient.java | 130 ++ .../model/CreateIotSmsReceiverRequest.java | 47 + .../iotsmsreceiver/model/IotSmsReceiver.java | 65 + .../model/ListIotSmsReceiverRequest.java | 29 + .../model/ListIotSmsReceiverResponse.java | 47 + .../model/UpdateIotSmsReceiverRequest.java | 47 + .../com/baidubce/services/lss/LssClient.java | 93 +- .../ListRealtimeStreamStatisticsRequest.java | 64 + .../ListRealtimeStreamStatisticsResponse.java | 29 + .../lss/model/RealTimeStreamStatistics.java | 67 + .../baidubce/services/route/RouteClient.java | 240 +++ .../route/RouteClientConfiguration.java | 9 + .../route/model/CreateRouteRequest.java | 227 +++ .../route/model/CreateRouteResponse.java | 30 + .../route/model/DeleteRouteRequest.java | 95 + .../services/route/model/GetRouteRequest.java | 97 + .../route/model/GetRouteResponse.java | 54 + .../services/route/model/NetworkAction.java | 12 + .../services/route/model/RouteRule.java | 117 ++ .../services/ruleengine/RuleEngineClient.java | 6 + .../ruleengine/model/DestinationKind.java | 1 + .../services/subnet/SubnetClient.java | 306 ++++ .../subnet/SubnetClientConfiguration.java | 22 + .../subnet/model/CreateSubnetRequest.java | 209 +++ .../subnet/model/CreateSubnetResponse.java | 28 + .../subnet/model/DeleteSubnetRequest.java | 82 + .../subnet/model/GetSubnetRequest.java | 46 + .../subnet/model/GetSubnetResponse.java | 22 + .../subnet/model/ListSubnetsRequest.java | 125 ++ .../subnet/model/ListSubnetsResponse.java | 24 + .../model/ModifySubnetAttributesRequest.java | 130 ++ .../services/subnet/model/NetworkAction.java | 12 + .../services/subnet/model/Subnet.java | 116 ++ .../baidubce/services/tsdb/TsdbConstants.java | 14 + .../baidubce/services/tsdb/model/Fill.java | 41 + .../baidubce/services/tsdb/model/GroupBy.java | 20 +- .../services/tsdb/model/GroupInfo.java | 22 +- .../baidubce/services/tsdb/model/Query.java | 20 + .../baidubce/services/tsdb/model/Result.java | 20 + .../com/baidubce/services/vod/VodClient.java | 70 + .../services/vodpro/AdaptorClient.java | 181 ++ .../baidubce/services/vodpro/Constants.java | 31 + .../services/vodpro/VodproClient.java | 219 +++ .../vodpro/model/adaptor/RequestType.java | 10 + .../adaptor/request/QueryVcaRequest.java | 28 + .../adaptor/request/QueryVcrRequest.java | 28 + .../adaptor/request/TaskStartRequest.java | 55 + .../model/adaptor/response/Constants.java | 48 + .../model/adaptor/response/Evidence.java | 67 + .../model/adaptor/response/HSVcrResult.java | 89 + .../vodpro/model/adaptor/response/Label.java | 58 + .../adaptor/response/QueryVcaResponse.java | 211 +++ .../adaptor/response/QueryVcrResponse.java | 50 + .../adaptor/response/TaskStartResponse.java | 17 + .../services/vodpro/model/common/Audio.java | 39 + .../vodpro/model/common/BaseMedia.java | 29 + .../vodpro/model/common/MediaMeta.java | 22 + .../services/vodpro/model/common/Path.java | 129 ++ .../services/vodpro/model/common/Tag.java | 42 + .../vodpro/model/common/TriggerStatus.java | 18 + .../services/vodpro/model/common/UtcTime.java | 21 + .../services/vodpro/model/common/Video.java | 40 + .../model/request/CreateMediaRequest.java | 70 + .../vodpro/model/request/GetMediaRequest.java | 69 + .../model/response/GetVcaResultResponse.java | 208 +++ .../model/response/GetVcrResultResponse.java | 253 +++ .../vodpro/model/response/MediaResponse.java | 139 ++ .../com/baidubce/services/vpc/VpcClient.java | 300 +++ .../services/vpc/VpcClientConfiguration.java | 22 + .../services/vpc/model/CreateVpcRequest.java | 114 ++ .../services/vpc/model/CreateVpcResponse.java | 28 + .../services/vpc/model/DeleteVpcRequest.java | 82 + .../services/vpc/model/GetVpcRequest.java | 46 + .../services/vpc/model/GetVpcResponse.java | 22 + .../services/vpc/model/ListVpcsRequest.java | 75 + .../services/vpc/model/ListVpcsResponse.java | 24 + .../vpc/model/ModifyVpcAttributesRequest.java | 130 ++ .../services/vpc/model/NetworkAction.java | 12 + .../services/vpc/model/ShowVpcModel.java | 100 + .../com/baidubce/services/vpc/model/Vpc.java | 85 + 240 files changed, 19485 insertions(+), 50 deletions(-) create mode 100644 src/main/java/com/baidubce/model/ListRequest.java create mode 100644 src/main/java/com/baidubce/model/ListResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/BacnetClient.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetDevice.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetGateway.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetGatewayCredential.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetObject.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetObjectId.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/BacnetObjectPresentValue.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/CreateBacnetGatewayRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/IdResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListBacnetDeviceResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListBacnetGatewayResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListBacnetObjectResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListObjectPresentValueResponse.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/ListRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/SubBacnetObjectRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetGatewayRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetObjectPresentValueRequest.java create mode 100644 src/main/java/com/baidubce/services/bacnet/model/UpdateDestTopicsRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/BccClient.java create mode 100644 src/main/java/com/baidubce/services/bcc/BccClientConfiguration.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/Billing.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/CreateCdsModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/ImageModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/InstanceModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/InstanceTypeModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/Reservation.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/SecurityGroupRuleModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/SnapshotModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/VolumeAttachmentModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/VolumeModel.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/CreateImageRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/CreateImageResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/DeleteImageRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/GetImageResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/image/ListImagesResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/BindSecurityGroupRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceVncResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/InstanceType.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ListInstanceSpecsResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstancePasswordRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/RebootInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ReleaseInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/StartInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/StopInstanceRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/instance/UnbindSecurityGroupRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/DeleteSecurityGroupRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/securitygroup/SecurityGroupRuleOperateRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/CreateSnapshotResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/DeleteSnapshotRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/GetSnapshotResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/snapshot/ListSnapshotsResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/DetachVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/EphemeralDisk.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/GetVolumeResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/ListVolumesResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/PurchaseReservedVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/ReleaseVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/RollbackVolumeRequest.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/volume/VolumeAction.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/zone/ListZonesResponse.java create mode 100644 src/main/java/com/baidubce/services/bcc/model/zone/ZoneModel.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/model/BinaryParser.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/model/CreateBinaryParserRequest.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserResponse.java create mode 100644 src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java create mode 100644 src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupConfig.java create mode 100644 src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupsRequest.java create mode 100644 src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java create mode 100644 src/main/java/com/baidubce/services/bos/model/FetchObjectRequest.java create mode 100644 src/main/java/com/baidubce/services/bos/model/FetchObjectResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DescribeIpRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/HttpsConfig.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/RequestAuth.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigResponse.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetRequestAuthRequest.java create mode 100644 src/main/java/com/baidubce/services/cdn/model/SetRequestAuthResponse.java create mode 100644 src/main/java/com/baidubce/services/dcc/DccClient.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/DedicatedHostModel.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/EphemeralDisk.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostRequest.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostResponse.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsRequest.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsResponse.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/ListRequest.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/ListResponse.java create mode 100644 src/main/java/com/baidubce/services/dcc/model/ResourceUsage.java create mode 100644 src/main/java/com/baidubce/services/eip/EipClient.java create mode 100644 src/main/java/com/baidubce/services/eip/model/Billing.java create mode 100644 src/main/java/com/baidubce/services/eip/model/BindEipRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/CreateEipRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/CreateEipResponse.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ListEipsRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ListEipsResponse.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ListRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ListResponse.java create mode 100644 src/main/java/com/baidubce/services/eip/model/PurchaseReservedEipRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ReleaseEipRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/ResizeEipRequest.java create mode 100644 src/main/java/com/baidubce/services/eip/model/UnbindEipRequest.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/AccountMqttUsageRequest.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusRequest.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/BatchGetMqttClientStatusResponse.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/DailyMqttUsage.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/MqttClientStatus.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/MqttClientStatusRequest.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/MqttClientStatusResponse.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/MqttUsage.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/MqttUsageResponse.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageRequest.java create mode 100644 src/main/java/com/baidubce/services/iothub/model/QueryEndpointDailyMqttUsageResponse.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/IotSmsReceiverClient.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/model/CreateIotSmsReceiverRequest.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/model/IotSmsReceiver.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverRequest.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/model/ListIotSmsReceiverResponse.java create mode 100644 src/main/java/com/baidubce/services/iotsmsreceiver/model/UpdateIotSmsReceiverRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsRequest.java create mode 100644 src/main/java/com/baidubce/services/lss/model/ListRealtimeStreamStatisticsResponse.java create mode 100644 src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java create mode 100644 src/main/java/com/baidubce/services/route/RouteClient.java create mode 100644 src/main/java/com/baidubce/services/route/RouteClientConfiguration.java create mode 100644 src/main/java/com/baidubce/services/route/model/CreateRouteRequest.java create mode 100644 src/main/java/com/baidubce/services/route/model/CreateRouteResponse.java create mode 100644 src/main/java/com/baidubce/services/route/model/DeleteRouteRequest.java create mode 100644 src/main/java/com/baidubce/services/route/model/GetRouteRequest.java create mode 100644 src/main/java/com/baidubce/services/route/model/GetRouteResponse.java create mode 100644 src/main/java/com/baidubce/services/route/model/NetworkAction.java create mode 100644 src/main/java/com/baidubce/services/route/model/RouteRule.java create mode 100644 src/main/java/com/baidubce/services/subnet/SubnetClient.java create mode 100644 src/main/java/com/baidubce/services/subnet/SubnetClientConfiguration.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/CreateSubnetRequest.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/CreateSubnetResponse.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/DeleteSubnetRequest.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/GetSubnetRequest.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/GetSubnetResponse.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/ListSubnetsRequest.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/ListSubnetsResponse.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/ModifySubnetAttributesRequest.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/NetworkAction.java create mode 100644 src/main/java/com/baidubce/services/subnet/model/Subnet.java create mode 100644 src/main/java/com/baidubce/services/vodpro/AdaptorClient.java create mode 100644 src/main/java/com/baidubce/services/vodpro/Constants.java create mode 100644 src/main/java/com/baidubce/services/vodpro/VodproClient.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/RequestType.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcaRequest.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcrRequest.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/request/TaskStartRequest.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Constants.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Evidence.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/HSVcrResult.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Label.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/QueryVcaResponse.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/QueryVcrResponse.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/adaptor/response/TaskStartResponse.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/Audio.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/BaseMedia.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/MediaMeta.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/Path.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/Tag.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/TriggerStatus.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/UtcTime.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/common/Video.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/request/CreateMediaRequest.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/request/GetMediaRequest.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/response/GetVcaResultResponse.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/response/GetVcrResultResponse.java create mode 100644 src/main/java/com/baidubce/services/vodpro/model/response/MediaResponse.java create mode 100644 src/main/java/com/baidubce/services/vpc/VpcClient.java create mode 100644 src/main/java/com/baidubce/services/vpc/VpcClientConfiguration.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/CreateVpcRequest.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/CreateVpcResponse.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/DeleteVpcRequest.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/GetVpcRequest.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/GetVpcResponse.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/ListVpcsRequest.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/ListVpcsResponse.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/ModifyVpcAttributesRequest.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/NetworkAction.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/ShowVpcModel.java create mode 100644 src/main/java/com/baidubce/services/vpc/model/Vpc.java diff --git a/pom.xml b/pom.xml index 277d243d..971256bb 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.21 + 0.10.22 bce-sdk-java The BCE SDK for Java provides Java APIs for all of BCE services. http://bce.baidu.com/sdk/index.html diff --git a/src/main/java/com/baidubce/BceConstants.java b/src/main/java/com/baidubce/BceConstants.java index df3db726..2b1a6943 100644 --- a/src/main/java/com/baidubce/BceConstants.java +++ b/src/main/java/com/baidubce/BceConstants.java @@ -16,5 +16,5 @@ * Common constants used by the whole SDK. */ public class BceConstants { - public static final String VERSION = "0.10.21"; + public static final String VERSION = "0.10.22"; } diff --git a/src/main/java/com/baidubce/http/Headers.java b/src/main/java/com/baidubce/http/Headers.java index 43ff887a..e8e35c6a 100644 --- a/src/main/java/com/baidubce/http/Headers.java +++ b/src/main/java/com/baidubce/http/Headers.java @@ -92,6 +92,10 @@ public interface Headers { 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"; 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/services/bacnet/BacnetClient.java b/src/main/java/com/baidubce/services/bacnet/BacnetClient.java new file mode 100644 index 00000000..e1205e96 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/BacnetClient.java @@ -0,0 +1,242 @@ +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 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); + } + + 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..f4d6e59b --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/BacnetGateway.java @@ -0,0 +1,130 @@ +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 subscribeDuration; + private Date lastActiveTime; + 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; + } +} 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..af44404b --- /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 double 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 double getPresentValue() { + return presentValue; + } + + public void setPresentValue(double 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..9258599f --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/CreateBacnetGatewayRequest.java @@ -0,0 +1,100 @@ +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 subscribeDuration; + 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; + } +} 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..f038db75 --- /dev/null +++ b/src/main/java/com/baidubce/services/bacnet/model/UpdateBacnetGatewayRequest.java @@ -0,0 +1,91 @@ +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 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; + } + +} 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/bcc/BccClient.java b/src/main/java/com/baidubce/services/bcc/BccClient.java new file mode 100644 index 00000000..0f24ad48 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/BccClient.java @@ -0,0 +1,1625 @@ +/* + * 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 static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; +import static com.google.common.base.Preconditions.checkState; + +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 javax.crypto.Cipher; +import javax.crypto.spec.SecretKeySpec; + +import org.apache.commons.codec.binary.Hex; +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.bcc.model.Billing; +import com.baidubce.services.bcc.model.Reservation; +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.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.BindSecurityGroupRequest; +import com.baidubce.services.bcc.model.instance.CreateInstanceRequest; +import com.baidubce.services.bcc.model.instance.CreateInstanceResponse; +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.InstanceAction; +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.ModifyInstanceAttributesRequest; +import com.baidubce.services.bcc.model.instance.ModifyInstancePasswordRequest; +import com.baidubce.services.bcc.model.instance.PurchaseReservedInstanceRequeset; +import com.baidubce.services.bcc.model.instance.RebootInstanceRequest; +import com.baidubce.services.bcc.model.instance.RebuildInstanceRequest; +import com.baidubce.services.bcc.model.instance.ReleaseInstanceRequest; +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.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.ListSecurityGroupsRequest; +import com.baidubce.services.bcc.model.securitygroup.ListSecurityGroupsResponse; +import com.baidubce.services.bcc.model.securitygroup.SecurityGroupRuleOperateRequest; +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.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.CreateVolumeRequest; +import com.baidubce.services.bcc.model.volume.CreateVolumeResponse; +import com.baidubce.services.bcc.model.volume.DetachVolumeRequest; +import com.baidubce.services.bcc.model.volume.GetVolumeRequest; +import com.baidubce.services.bcc.model.volume.GetVolumeResponse; +import com.baidubce.services.bcc.model.volume.ListVolumesRequest; +import com.baidubce.services.bcc.model.volume.ListVolumesResponse; +import com.baidubce.services.bcc.model.volume.PurchaseReservedVolumeRequest; +import com.baidubce.services.bcc.model.volume.ReleaseVolumeRequest; +import com.baidubce.services.bcc.model.volume.ResizeVolumeRequest; +import com.baidubce.services.bcc.model.volume.RollbackVolumeRequest; +import com.baidubce.services.bcc.model.volume.VolumeAction; +import com.baidubce.services.bcc.model.zone.ListZonesResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import com.google.common.base.Strings; + +/** + * 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 INSTANCE_PREFIX = "instance"; + private static final String VOLUME_PREFIX = "volume"; + private static final String IMAGE_PREFIX = "image"; + private static final String SECURITYGROUP_PREFIX = "securityGroup"; + private static final String SNAPSHOT_PREFIX = "snapshot"; + private static final String ZONE = "zone"; + + /** + * 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); + 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 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 CreateInstanceResponse createInstance(CreateInstanceRequest request) + throws BceClientException { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBilling()); + } + checkStringNotEmpty(request.getImageId(), "imageId should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, INSTANCE_PREFIX); + internalRequest.addParameter("clientToken", 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); + } + + /** + * 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 own's bcc Instance. + * @return The response containing a list of instances owned by the authenticated user. + */ + public ListInstancesResponse listInstances(ListInstancesRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, INSTANCE_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInternalIp())) { + internalRequest.addParameter("internalIp", request.getInternalIp()); + } + if (!Strings.isNullOrEmpty(request.getDedicatedHostId())) { + internalRequest.addParameter("dedicatedHostId", request.getDedicatedHostId()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter("zoneName", 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 should not be null."); + checkNotNull(request.getInstanceId(), "request instanceId should not be null."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.GET, INSTANCE_PREFIX, request.getInstanceId()); + return this.invokeHttpClient(internalRequest, GetInstanceResponse.class); + } + + /** + * Starting the 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 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'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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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's 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)); + } + + /** + * Stopping the 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 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)); + } + + /** + * Stopping the 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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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 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 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's 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'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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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's 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'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 modifying the instance password. + * @throws BceClientException + */ + public void modifyInstancePassword(ModifyInstancePasswordRequest request) throws BceClientException { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + checkStringNotEmpty(request.getAdminPass(), "request adminPass should not be empty."); + 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); + } + + /** + * 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 modifyInstanceAttributes(ModifyInstanceAttributesRequest request) { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + checkStringNotEmpty(request.getName(), "request name should not be empty."); + 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); + } + + + /** + * Rebuilding the 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 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 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 rebuildInstance(RebuildInstanceRequest request) throws BceClientException { + checkNotNull(request, "request should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + checkStringNotEmpty(request.getImageId(), "request imageId should not be empty."); + checkStringNotEmpty(request.getAdminPass(), "request adminPass should not be empty."); + 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 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. + */ + public void releaseInstance(String instanceId) { + this.releaseInstance(new ReleaseInstanceRequest().withInstanceId(instanceId)); + } + + /** + * 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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.DELETE, INSTANCE_PREFIX, request.getInstanceId()); + 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 should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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("clientToken", 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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + checkStringNotEmpty(request.getSecurityGroupId(), "request securityGroupId should not be empty."); + 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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + checkStringNotEmpty(request.getSecurityGroupId(), "request securityGroupId should not be empty."); + 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); + } + + + /** + * 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 should not be null."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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. + */ + public void purchaseReservedInstance(String instanceId, int reservationLength, String reservationTimeUnit) { + this.purchaseReservedInstance(new PurchaseReservedInstanceRequeset() + .withInstanceId(instanceId) + .withBilling(new Billing().withReservation(new Reservation() + .withReservationLength(reservationLength) + .withReservationTimeUnit(reservationTimeUnit)))); + } + + /** + * 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. + */ + public void purchaseReservedInstance(PurchaseReservedInstanceRequeset request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBillingWithReservation()); + } + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + InternalRequest internalRequest = this.createRequest( + request, HttpMethodName.PUT, INSTANCE_PREFIX, request.getInstanceId()); + internalRequest.addParameter(InstanceAction.purchaseReserved.name(), null); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + this.invokeHttpClient(internalRequest, AbstractBceResponse.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. + */ + 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. + */ + 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 should not be null."); + 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("clientToken", 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("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter("instanceId", request.getInstanceId()); + } + if (!Strings.isNullOrEmpty(request.getZoneName())) { + internalRequest.addParameter("zoneName", 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 should not be null."); + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + 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 should not be null."); + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + 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 should not be null."); + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + checkStringNotEmpty(request.getInstanceId(), "request instanceId should not be empty."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.detach.name(), null); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.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 should not be null."); + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, VOLUME_PREFIX, request.getVolumeId()); + 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 void resizeVolume(String volumeId, int newCdsSizeInGB) { + 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 void resizeVolume(ResizeVolumeRequest request) { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + 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("clientToken", request.getClientToken()); + fillPayload(internalRequest, request); + invokeHttpClient(internalRequest, AbstractBceResponse.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 should not be null."); + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + checkStringNotEmpty(request.getSnapshotId(), "request snapshotId should not be empty."); + 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 should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + if (null == request.getBilling()) { + request.setBilling(generateDefaultBillingWithReservation()); + } + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.PUT, VOLUME_PREFIX, request.getVolumeId()); + internalRequest.addParameter(VolumeAction.purchaseReserved.name(), null); + fillPayload(internalRequest, request); + 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)); + } + + /** + * 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 should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getImageName(), "request imageName should not be empty."); + 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("clientToken", 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 should not be null."); + 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("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getImageType())) { + internalRequest.addParameter("imageType", request.getImageType()); + } + 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 should not be null."); + checkStringNotEmpty(request.getImageId(), "request imageId should not be empty."); + 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 should not be null."); + checkStringNotEmpty(request.getImageId(), "request imageId should not be empty."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, IMAGE_PREFIX, request.getImageId()); + invokeHttpClient(internalRequest, AbstractBceResponse.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 should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getVolumeId(), "request volumeId should not be empty."); + checkStringNotEmpty(request.getSnapshotName(), "request snapshotName should not be empty."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SNAPSHOT_PREFIX); + internalRequest.addParameter("clientToken", 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 should not be null."); + 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("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getVolumeId())) { + internalRequest.addParameter("volumeId", 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 should not be null."); + checkStringNotEmpty(request.getSnapshotId(), "request snapshotId should no be empty."); + 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 should not be null."); + checkStringNotEmpty(request.getSnapshotId(), "request snapshotId should no be empty."); + InternalRequest internalRequest = + this.createRequest(request, HttpMethodName.DELETE, SNAPSHOT_PREFIX, request.getSnapshotId()); + 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 should not be null."); + 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("maxKeys", String.valueOf(request.getMaxKeys())); + } + if (!Strings.isNullOrEmpty(request.getInstanceId())) { + internalRequest.addParameter("instanceId", request.getInstanceId()); + } + if (!Strings.isNullOrEmpty(request.getVpcId())) { + internalRequest.addParameter("vpcId", request.getVpcId()); + } + return invokeHttpClient(internalRequest, ListSecurityGroupsResponse.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 should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), "request name should not be empty."); + 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("clientToken", 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 should not be null."); + checkStringNotEmpty(request.getSecurityGroupId(), "securityGroupId should not be empty."); + 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("authorizeRule", null); + internalRequest.addParameter("clientToken", 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 should not be null."); + checkStringNotEmpty(request.getSecurityGroupId(), "securityGroupId should not be empty."); + 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("revokeRule", null); + internalRequest.addParameter("clientToken", 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 should not be null."); + checkStringNotEmpty(request.getSecurityGroupId(), "request securityGroupId should not be empty."); + 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); + } +} 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/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..177937e0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/CreateCdsModel.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.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; + + 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; + } + + @Override + public String toString() { + return "CreateCdsModel{" + + "cdsSizeInGB=" + cdsSizeInGB + + ", storageType='" + storageType + '\'' + + ", snapshotId='" + snapshotId + '\'' + + '}'; + } +} 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..1761f978 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/ImageModel.java @@ -0,0 +1,183 @@ +/* + * 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; + +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; + + 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; + } + + @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 + '\'' + + '}'; + } +} 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..9163c50f --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/InstanceModel.java @@ -0,0 +1,277 @@ +/* + * 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; + +import java.util.Date; + +/** + * instance detail info model + */ +public class InstanceModel { + + /** + * The identified id of the instance + */ + private String id; + + /** + * The name of the instance. + */ + private String name; + + /** + * 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 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; + + 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 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; + } + + @Override + public String toString() { + return "InstanceModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", status='" + status + '\'' + + ", desc='" + desc + '\'' + + ", paymentTiming='" + paymentTiming + '\'' + + ", createTime='" + createTime + '\'' + + ", expireTime='" + expireTime + '\'' + + ", internalIp='" + internalIp + '\'' + + ", publicIp='" + publicIp + '\'' + + ", cpuCount=" + cpuCount + + ", memoryCapacityInGB=" + memoryCapacityInGB + + ", localDiskSizeInGB=" + localDiskSizeInGB + + ", imageId='" + imageId + '\'' + + ", networkCapacityInMbps=" + networkCapacityInMbps + + ", placementPolicy='" + placementPolicy + '\'' + + ", zoneName='" + zoneName + '\'' + + ", subnetId='" + subnetId + '\'' + + ", vpcId='" + vpcId + '\'' + + '}'; + } +} 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..ea2c4d6d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/InstanceTypeModel.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.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/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/SecurityGroupModel.java b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.java new file mode 100644 index 00000000..05228529 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupModel.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.bcc.model; + +import java.util.List; + +/** + * The detail model for describing SecurityGroup. + */ +public class SecurityGroupModel { + + /** + * 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; + + /** + * List of rules which describe how the SecurityGroup works. + */ + private List rules; + + + 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 List getRules() { + return rules; + } + + public void setRules(List rules) { + this.rules = rules; + } + + @Override + public String toString() { + return "SecurityGroupModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", vpcId='" + vpcId + '\'' + + ", desc='" + desc + '\'' + + ", rules=" + rules + + '}'; + } +} 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..05c7fc73 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SecurityGroupRuleModel.java @@ -0,0 +1,223 @@ +/* + * 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; + + 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 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 + '\'' + + '}'; + } +} 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..897ebfae --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/SnapshotModel.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.bcc.model; + +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; + + 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; + } + + @Override + public String toString() { + return "SnapshotModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", sizeInGB=" + sizeInGB + + ", createTime='" + createTime + '\'' + + ", status='" + status + '\'' + + ", createMethod='" + createMethod + '\'' + + ", volumeId='" + volumeId + '\'' + + ", desc='" + desc + '\'' + + '}'; + } +} 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..fb38a7c0 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VolumeAttachmentModel.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.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; + + 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; + } + + @Override + public String toString() { + return "VolumeAttachmentModel{" + + "volumeId='" + volumeId + '\'' + + ", instanceId='" + instanceId + '\'' + + ", device='" + device + '\'' + + '}'; + } +} 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..b085af70 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/VolumeModel.java @@ -0,0 +1,201 @@ +/* + * 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; + +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; + + 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; + } + + @Override + public String toString() { + return "VolumeModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", diskSizeInGB=" + diskSizeInGB + + ", paymentTiming='" + paymentTiming + '\'' + + ", createTime='" + createTime + '\'' + + ", expireTime='" + expireTime + '\'' + + ", status='" + status + '\'' + + ", type='" + type + '\'' + + ", desc='" + desc + '\'' + + ", attachments=" + attachments + + ", zoneName='" + zoneName + '\'' + + '}'; + } +} 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..43881c79 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/CreateImageRequest.java @@ -0,0 +1,150 @@ +/* + * 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; +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; + + 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; + } + + /** + * 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/GetImageRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.java new file mode 100644 index 00000000..619b60e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/GetImageRequest.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 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/ListImagesRequest.java b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.java new file mode 100644 index 00000000..1528782e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/image/ListImagesRequest.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.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; + + 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; + } +} 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..5a3c992c --- /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.services.bcc.model.ImageModel; +import com.baidubce.model.ListResponse; + +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/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/CreateInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java new file mode 100644 index 00000000..755b0351 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceRequest.java @@ -0,0 +1,450 @@ +/* + * 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.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 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 InstanceType} + */ + private String instanceType; + + /** + * 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 optional parameter to specify the ephemeral disk list + * When creating the storage optimized instance, one ephemeral disk must be created together. + */ + 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. + */ + 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 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; + + /** + * 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; + + /** + * 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 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 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; + } + + + public int getLocalDiskSizeInGB() { + return localDiskSizeInGB; + } + + 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 + */ + 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; + } + + /** + * 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 CreateInstanceRequest withDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + return this; + } + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + public CreateInstanceRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public CreateInstanceRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + public CreateInstanceRequest withSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + return this; + } + + public String getSecurityGroupId() { + return securityGroupId; + } + + public void setSecurityGroupId(String securityGroupId) { + this.securityGroupId = securityGroupId; + } + + /** + * 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; + } +} 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..fc12a9aa --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/CreateInstanceResponse.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.instance; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * The response for CreateInstanceRequest. + */ +public class CreateInstanceResponse extends AbstractBceResponse { + /** + * List of id of instances created. + */ + private List instanceIds; + + 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/GetInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.java new file mode 100644 index 00000000..1c42057e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/GetInstanceRequest.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.instance; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting instance detail + */ +public class GetInstanceRequest extends AbstractBceRequest { + + /** + * The id of instance. + */ + 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/InstanceAction.java b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.java new file mode 100644 index 00000000..eb1468a8 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceAction.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.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 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 +} 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..7343c494 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/InstanceType.java @@ -0,0 +1,35 @@ +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 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 +} 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..12a35096 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesRequest.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.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; + + 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; + } + + /** + * 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..d674a9b4 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ListInstancesResponse.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.instance; + +import com.baidubce.services.bcc.model.InstanceModel; +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * response model for query instance list + */ +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/ModifyInstanceAttributesRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.java new file mode 100644 index 00000000..389c1f00 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ModifyInstanceAttributesRequest.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.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; + + 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; + } + + /** + * 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/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/PurchaseReservedInstanceRequeset.java b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java new file mode 100644 index 00000000..c1da9b6e --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/PurchaseReservedInstanceRequeset.java @@ -0,0 +1,116 @@ +/* + * 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.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; + + 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; + } + + /** + * 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/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/RebuildInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.java new file mode 100644 index 00000000..454f7526 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/RebuildInstanceRequest.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.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 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; + } + + /** + * 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/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/ResizeInstanceRequest.java b/src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java new file mode 100644 index 00000000..5147567a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/ResizeInstanceRequest.java @@ -0,0 +1,142 @@ +/* + * 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 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 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; + + + 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 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 credentials. + */ + 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 credentials. + */ + public ResizeInstanceRequest withMemoryCapacityInGB(int memoryCapacityInGB) { + this.memoryCapacityInGB = memoryCapacityInGB; + 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/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..d860e74a --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/instance/StopInstanceRequest.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 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; + + 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; + } + + /** + * 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/securitygroup/CreateSecurityGroupRequest.java b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java new file mode 100644 index 00000000..7214c997 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/CreateSecurityGroupRequest.java @@ -0,0 +1,161 @@ +/* + * 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; + +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; + + 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; + } + + /** + * 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/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..6d938117 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/securitygroup/ListSecurityGroupsResponse.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.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; + } +} 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/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/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/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..7fc47adf --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/AttachVolumeResponse.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.VolumeAttachmentModel; + +/** + * The response for AttachVolumeRequest. + */ +public class AttachVolumeResponse extends AbstractBceResponse { + + /** + * The detail model which describe where the volume will attach to. + */ + private VolumeAttachmentModel volumeAttachment; + + 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/CreateVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java new file mode 100644 index 00000000..916fdd83 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/CreateVolumeRequest.java @@ -0,0 +1,217 @@ +/* + * 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 creating a new volume. + */ +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. + */ + 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; + + 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; + } + + /** + * 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..d5d6ef13 --- /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 java.util.List; + +/** + * The request for creating new volume. + */ +public class CreateVolumeResponse extends AbstractBceResponse { + /** + * List of the id of volumes created. + */ + private List volumeIds; + + public List getVolumeIds() { + return volumeIds; + } + + public void setVolumeIds(List volumeIds) { + this.volumeIds = volumeIds; + } + + @Override + public String toString() { + return "CreateVolumeResponse{" + + "volumeIds=" + volumeIds + + '}'; + } +} 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/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/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/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..40be5274 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ReleaseVolumeRequest.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.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; + + public String getVolumeId() { + return volumeId; + } + + public void setVolumeId(String volumeId) { + this.volumeId = volumeId; + } + + public ReleaseVolumeRequest withVolumeId(String volumeId) { + this.volumeId = volumeId; + 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/ResizeVolumeRequest.java b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.java new file mode 100644 index 00000000..71d6efa6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/ResizeVolumeRequest.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.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; + + 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; + } + + /** + * 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/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..d380ec2d --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/volume/VolumeAction.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.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 +} 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..6082f3d6 --- /dev/null +++ b/src/main/java/com/baidubce/services/bcc/model/zone/ListZonesResponse.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.zone; + +import java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +/** + * 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; + } +} 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/binaryparser/BinaryParserClient.java b/src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java new file mode 100644 index 00000000..b8ad1a07 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/BinaryParserClient.java @@ -0,0 +1,127 @@ +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.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; + +/** + * 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 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); + } + + 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..7c372908 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/BinaryParser.java @@ -0,0 +1,63 @@ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * 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; + + 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..a2084ba5 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/CreateBinaryParserRequest.java @@ -0,0 +1,54 @@ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * 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; + + 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/ListBinaryParserRequest.java b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java new file mode 100644 index 00000000..ad3cdeb1 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * 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..152cab6d --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/ListBinaryParserResponse.java @@ -0,0 +1,48 @@ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.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/UpdateBinaryParserRequest.java b/src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java new file mode 100644 index 00000000..ec24be46 --- /dev/null +++ b/src/main/java/com/baidubce/services/binaryparser/model/UpdateBinaryParserRequest.java @@ -0,0 +1,45 @@ +package com.baidubce.services.binaryparser.model; + +import com.baidubce.model.GenericAccountRequest; + +/** + * Created by yuanyoujun on 2017/9/2. + */ +public class UpdateBinaryParserRequest extends GenericAccountRequest { + private String name; + private String inputTopic; + private String script; + private String outputTopic; + + 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/bmr/BmrClient.java b/src/main/java/com/baidubce/services/bmr/BmrClient.java index a9a537fd..cce7d782 100644 --- a/src/main/java/com/baidubce/services/bmr/BmrClient.java +++ b/src/main/java/com/baidubce/services/bmr/BmrClient.java @@ -36,6 +36,7 @@ import com.baidubce.services.bmr.model.GetStepRequest; import com.baidubce.services.bmr.model.GetStepResponse; import com.baidubce.services.bmr.model.InstanceGroupConfig; +import com.baidubce.services.bmr.model.ModifyInstanceGroupConfig; import com.baidubce.services.bmr.model.ListClustersRequest; import com.baidubce.services.bmr.model.ListClustersResponse; import com.baidubce.services.bmr.model.ListInstanceGroupsRequest; @@ -44,6 +45,7 @@ import com.baidubce.services.bmr.model.ListInstancesResponse; import com.baidubce.services.bmr.model.ListStepsRequest; import com.baidubce.services.bmr.model.ListStepsResponse; +import com.baidubce.services.bmr.model.ModifyInstanceGroupsRequest; import com.baidubce.services.bmr.model.StepConfig; import com.baidubce.services.bmr.model.TerminateClusterRequest; import com.baidubce.util.HttpUtils; @@ -281,6 +283,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. * 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..10587781 100644 --- a/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java +++ b/src/main/java/com/baidubce/services/bmr/model/GetStepResponse.java @@ -29,6 +29,7 @@ public class GetStepResponse extends AbstractBceResponse { private String type; private Map properties; private StepStatus status; + private String logUri; public String getId() { return id; @@ -77,4 +78,12 @@ public Map getProperties() { public void setProperties(Map properties) { this.properties = properties; } + + public String getLogUri() { + return this.logUri; + } + + public void setLogUri(String logUri) { + this.logUri = logUri; + } } 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..4734592b --- /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..df077881 --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/ModifyInstanceGroupsRequest.java @@ -0,0 +1,104 @@ +package com.baidubce.services.bmr.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.util.ArrayList; +import java.util.List; + +/** + * 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 + * @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/SparkStepConfig.java b/src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java new file mode 100644 index 00000000..6337ae8f --- /dev/null +++ b/src/main/java/com/baidubce/services/bmr/model/SparkStepConfig.java @@ -0,0 +1,78 @@ +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; + } +} 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..c8bad237 100644 --- a/src/main/java/com/baidubce/services/bmr/model/Step.java +++ b/src/main/java/com/baidubce/services/bmr/model/Step.java @@ -24,6 +24,7 @@ public class Step { private Map properties; private String name; private StepStatus status; + private String logUri; public String getId() { return id; @@ -72,4 +73,12 @@ 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; + } } diff --git a/src/main/java/com/baidubce/services/bos/BosClient.java b/src/main/java/com/baidubce/services/bos/BosClient.java index 926cfe5c..3e61deca 100644 --- a/src/main/java/com/baidubce/services/bos/BosClient.java +++ b/src/main/java/com/baidubce/services/bos/BosClient.java @@ -994,6 +994,58 @@ public CopyObjectResponse copyObject(CopyObjectRequest request) { 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()); + } + this.setZeroContentLength(internalRequest); + + FetchObjectResponse response = this.invokeHttpClient(internalRequest, FetchObjectResponse.class); + return response; + } + /** * Deletes the specified object in the specified bucket. * 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..a898124d --- /dev/null +++ b/src/main/java/com/baidubce/services/bos/model/FetchObjectRequest.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 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; + + /** + * 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; + } + +} 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/cdn/CdnClient.java b/src/main/java/com/baidubce/services/cdn/CdnClient.java index 57448bbe..87a77e5b 100644 --- a/src/main/java/com/baidubce/services/cdn/CdnClient.java +++ b/src/main/java/com/baidubce/services/cdn/CdnClient.java @@ -46,6 +46,7 @@ import com.baidubce.services.cdn.model.PurgeRequest; import com.baidubce.services.cdn.model.PurgeResponse; import com.baidubce.services.cdn.model.PurgeTask; +import com.baidubce.services.cdn.model.RequestAuth; import com.baidubce.services.cdn.model.SetDomainCacheFullUrlRequest; import com.baidubce.services.cdn.model.SetDomainCacheFullUrlResponse; import com.baidubce.services.cdn.model.SetDomainCacheTTLRequest; @@ -96,6 +97,13 @@ import com.baidubce.services.cdn.model.GetDomainConfigResponse; import com.baidubce.services.cdn.model.GetDomainLogRequest; import com.baidubce.services.cdn.model.GetDomainLogResponse; +import com.baidubce.services.cdn.model.HttpsConfig; +import com.baidubce.services.cdn.model.SetHttpsConfigRequest; +import com.baidubce.services.cdn.model.SetHttpsConfigResponse; +import com.baidubce.services.cdn.model.SetRequestAuthRequest; +import com.baidubce.services.cdn.model.SetRequestAuthResponse; +import com.baidubce.services.cdn.model.DescribeIpRequest; +import com.baidubce.services.cdn.model.DescribeIpResponse; import com.baidubce.util.HttpUtils; import com.baidubce.util.JsonUtils; import com.baidubce.util.DateUtils; @@ -132,6 +140,11 @@ public class CdnClient extends AbstractBceClient { */ private static final String LOG = "log"; + /** + * The common URI prefix for utils operation. + */ + private static final String UTILS = "utils"; + /** * Generate signature with specified headers. */ @@ -431,6 +444,62 @@ public SetDomainLimitRateResponse setDomainLimitRate(SetDomainLimitRateRequest r return invokeHttpClient(internalRequest, SetDomainLimitRateResponse.class); } + /** + * Set HTTPS with certain configuration. + * + * @param domain Name of the domain. + * @param https The configuration of HTTPS. + */ + public void setHttpsConfig(String domain, HttpsConfig https) { + SetHttpsConfigRequest request = new SetHttpsConfigRequest() + .withDomain(domain) + .withHttps(https); + setHttpsConfig(request); + } + + /** + * 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 SetHttpsConfigResponse setHttpsConfig(SetHttpsConfigRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("https", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetHttpsConfigResponse.class); + } + + /** + * Set the request authentication. + * + * @param domain Name of the domain. + * @param requestAuth The configuration of authentication. + */ + public void setRequestAuth(String domain, RequestAuth requestAuth) { + SetRequestAuthRequest request = new SetRequestAuthRequest() + .withDomain(domain) + .withRequestAuth(requestAuth); + setRequestAuth(request); + } + + /** + * Set the request authentication. + * + * @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 SetRequestAuthResponse setRequestAuth(SetRequestAuthRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = + createRequest(request, HttpMethodName.PUT, DOMAIN, request.getDomain(), "config"); + internalRequest.addParameter("requestAuth", ""); + this.attachRequestToBody(request, internalRequest); + return invokeHttpClient(internalRequest, SetRequestAuthResponse.class); + } + /** * Post prefetch request * @@ -820,7 +889,7 @@ public GetCacheQuotaResponse getCacheQuota() { } /** - * Get URLs of log files + * Get cache operation quota. * * @param request The request containing all the options related to the statistics. * @return Details of statistics @@ -831,13 +900,43 @@ public GetCacheQuotaResponse getCacheQuota(GetCacheQuotaRequest request) { } /** - * + * Get URLs of log files + * + * @param request The request containing all the options related to the statistics. + * @return Details of statistics */ public GetDomainLogResponse getDomainLog(GetDomainLogRequest request) { InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, LOG, request.getDomain(), "log"); return this.invokeHttpClient(internalRequest, GetDomainLogResponse.class); } + /** + * Get the description of certain IP address. + * + * @param ip IP address. + * @return Details of statistics + */ + public DescribeIpResponse describeIp(String ip) { + DescribeIpRequest request = new DescribeIpRequest() + .withIp(ip); + return describeIp(request); + } + + /** + * 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) { + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, UTILS); + checkNotNull(request.getIp()); + internalRequest.addParameter("action", request.getAction()); + internalRequest.addParameter("ip", request.getIp()); + + return this.invokeHttpClient(internalRequest, DescribeIpResponse.class); + } + /** * Creates and initializes a new request object for the specified resource. * 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..749cef6f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/DescribeIpRequest.java @@ -0,0 +1,65 @@ +/* + * 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; + +public class DescribeIpRequest extends AbstractBceRequest { + private String action = "describeIp"; + private String ip; + + 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 String getIp() { + return ip; + } + + public void setIp(String ip) { + this.ip = ip; + } + + @Override + public DescribeIpRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + 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/DescribeIpResponse.java b/src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.java new file mode 100644 index 00000000..bb57fd87 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/DescribeIpResponse.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; + +public class DescribeIpResponse extends CdnResponse { + private boolean cdnIP; + private String isp; + private String region; + + public boolean isCdnIP() { + return cdnIP; + } + + public void setCdnIP(boolean cdnIP) { + this.cdnIP = cdnIP; + } + + 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; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/HttpsConfig.java b/src/main/java/com/baidubce/services/cdn/model/HttpsConfig.java new file mode 100644 index 00000000..a57c9dd6 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/HttpsConfig.java @@ -0,0 +1,87 @@ +/* + * 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; + +public class HttpsConfig extends JsonObject { + private boolean enabled; + private String certId; + private boolean httpRedirect; + private boolean httpOrigin; + private String sllVersion; + + public HttpsConfig withEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + public HttpsConfig withCertId(String certId) { + this.certId = certId; + return this; + } + + public HttpsConfig withHttpRedirect(boolean httpRedirect) { + this.httpRedirect = httpRedirect; + return this; + } + + public HttpsConfig withHttpOrigint(boolean httpOrigin) { + this.httpOrigin = httpOrigin; + return this; + } + + public HttpsConfig withSllVersion(String sllVersion) { + this.sllVersion = sllVersion; + 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 isHttpRedirect() { + return httpRedirect; + } + + public void setHttpRedirect(boolean httpRedirect) { + this.httpRedirect = httpRedirect; + } + + public boolean isHttpOrigin() { + return httpOrigin; + } + + public void setHttpOrigin(boolean httpOrigin) { + this.httpOrigin = httpOrigin; + } + + public String getSllVersion() { + return sllVersion; + } + + public void setSllVersion(String sllVersion) { + this.sllVersion = sllVersion; + } +} 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 95ec4a17..83a4ad61 100644 --- a/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java +++ b/src/main/java/com/baidubce/services/cdn/model/OriginPeer.java @@ -20,50 +20,58 @@ public class OriginPeer extends JsonObject { private String peer; private String host; + private boolean backup; + private boolean follow302; - /** - * @param peer - * @return returns this object - */ public OriginPeer withPeer(String peer) { this.peer = peer; return this; } - /** - * @param host - * @return returns this object - */ public OriginPeer withHost(String host) { this.host = host; return this; } + + public OriginPeer withBackup(boolean backup) { + this.backup = backup; + return this; + } + + public OriginPeer withFollow302(boolean follow302) { + this.follow302 = follow302; + return this; + } - /** - * @return peer - */ public String getPeer() { return peer; } - /** - * @param peer - */ public void setPeer(String peer) { this.peer = peer; } - - /** - * @return host - */ + public String getHost() { return host; } - /** - * @param host - */ public void setHost(String host) { this.host = host; } -} + + public boolean isBackup() { + return backup; + } + + public void setBackup(boolean backup) { + this.backup = backup; + } + + public boolean isFollow302() { + return follow302; + } + + public void setFollow302(boolean follow302) { + this.follow302 = follow302; + } +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/cdn/model/RequestAuth.java b/src/main/java/com/baidubce/services/cdn/model/RequestAuth.java new file mode 100644 index 00000000..11da4d39 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/RequestAuth.java @@ -0,0 +1,121 @@ +/* + * 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; + +public class RequestAuth extends JsonObject { + private String type; + private String key1; + private String key2; + private Number timeout = 1800; + private List whiteList; + private String signArg; + private String timeArg; + + 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; + } +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigRequest.java new file mode 100644 index 00000000..0747af75 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigRequest.java @@ -0,0 +1,65 @@ +/* + * 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; + +public class SetHttpsConfigRequest extends AbstractBceRequest { + 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 SetHttpsConfigRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + public SetHttpsConfigRequest withHttps(HttpsConfig https) { + setHttps(https); + return this; + } + + @Override + public SetHttpsConfigRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + 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/SetHttpsConfigResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigResponse.java new file mode 100644 index 00000000..042a165f --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetHttpsConfigResponse.java @@ -0,0 +1,19 @@ +/* + * 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.model.AbstractBceResponse; + +public class SetHttpsConfigResponse extends AbstractBceResponse { +} diff --git a/src/main/java/com/baidubce/services/cdn/model/SetRequestAuthRequest.java b/src/main/java/com/baidubce/services/cdn/model/SetRequestAuthRequest.java new file mode 100644 index 00000000..73f12ef9 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetRequestAuthRequest.java @@ -0,0 +1,65 @@ +/* + * 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; + +public class SetRequestAuthRequest extends AbstractBceRequest { + private String domain; + private RequestAuth requestAuth; + + public String getDomain() { + return domain; + } + + public void setDomain(String domain) { + this.domain = domain; + } + + public RequestAuth getRequestAuth() { + return requestAuth; + } + + public void setRequestAuth(RequestAuth requestAuth) { + this.requestAuth = requestAuth; + } + + public SetRequestAuthRequest withDomain(String domain) { + setDomain(domain); + return this; + } + + public SetRequestAuthRequest withRequestAuth(RequestAuth requestAuth) { + setRequestAuth(requestAuth); + return this; + } + + @Override + public SetRequestAuthRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + 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/SetRequestAuthResponse.java b/src/main/java/com/baidubce/services/cdn/model/SetRequestAuthResponse.java new file mode 100644 index 00000000..cc5dc374 --- /dev/null +++ b/src/main/java/com/baidubce/services/cdn/model/SetRequestAuthResponse.java @@ -0,0 +1,19 @@ +/* + * 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.model.AbstractBceResponse; + +public class SetRequestAuthResponse extends AbstractBceResponse { +} 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..cfb74164 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/DccClient.java @@ -0,0 +1,148 @@ +/* + * 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.dcc; + +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.AbstractBceRequest; +import com.baidubce.services.dcc.model.GetDedicatedHostRequest; +import com.baidubce.services.dcc.model.GetDedicatedHostResponse; +import com.baidubce.services.dcc.model.ListDedicatedHostsRequest; +import com.baidubce.services.dcc.model.ListDedicatedHostsResponse; +import com.baidubce.util.HttpUtils; +import com.google.common.base.Strings; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Provides the client for accessing the Dedicated Cloud Compute Service(DCC). + */ +public class DccClient extends AbstractBceClient { + /** + * DCC API pathVersion + */ + private static final String VERSION = "v1"; + + private static final String PREFIX = "dedicatedHost"; + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static HttpResponseHandler[] dccHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public DccClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new InstanceClient to invoke service methods on dcc host. + * + * @param clientConfiguration The BCE client configuration options. + */ + public DccClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, dccHandlers); + } + + /** + * Get the detail information of specified dcc. + * + * @param dedicatedHostId The id of the DCC. + * @return A dcc detail model for the dedicatedHostId. + */ + public GetDedicatedHostResponse getDedicatedHost(String dedicatedHostId) { + return getDedicatedHost(new GetDedicatedHostRequest().withDedicatedHostId(dedicatedHostId)); + } + + /** + * Get the detail information of specified dcc. + * + * @param request The request containing all options for getting the instance info. + * @return A dcc detail model for the dedicatedHostId. + */ + public GetDedicatedHostResponse getDedicatedHost(GetDedicatedHostRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getDedicatedHostId(), "request dedicatedHostId should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, request.getDedicatedHostId()); + return this.invokeHttpClient(internalRequest, GetDedicatedHostResponse.class); + } + + /** + * get a list of hosts owned by the authenticated user and default conditions + * @return + */ + public ListDedicatedHostsResponse listDedicatedHosts() { + return listDedicatedHosts(new ListDedicatedHostsRequest()); + } + + /** + * get a list of hosts owned by the authenticated user and specified conditions + * + * @param request The request containing all options for query + * @return + */ + public ListDedicatedHostsResponse listDedicatedHosts(ListDedicatedHostsRequest 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.getZoneName())) { + internalRequest.addParameter("zoneName", request.getZoneName()); + } + return invokeHttpClient(internalRequest, ListDedicatedHostsResponse.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; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/DedicatedHostModel.java b/src/main/java/com/baidubce/services/dcc/model/DedicatedHostModel.java new file mode 100644 index 00000000..41a8ad8e --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/DedicatedHostModel.java @@ -0,0 +1,168 @@ +/* + * 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.dcc.model; + +import java.util.Date; + +/** + * dcc detail info model + */ +public class DedicatedHostModel { + /** + * The identified id of dcc + */ + private String id; + + /** + * The name of dcc + */ + private String name; + + /** + * The status of dcc + */ + private String status; + + /** + * The description of dcc + */ + private String desc; + + /** + * The name of flavor + */ + private String flavorName; + + /** + * dcc resource usage detail + */ + private ResourceUsage resourceUsage; + + /** + * The payment method of purchasing the dcc, + * 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 name of available zone + */ + private String zoneName; + + 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 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 getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + @Override + public String toString() { + return "DedicatedHostModel{" + + "id='" + id + '\'' + + ", name='" + name + '\'' + + ", status='" + status + '\'' + + ", desc='" + desc + '\'' + + ", flavorName='" + flavorName + '\'' + + ", resourceUsage=" + resourceUsage + + ", paymentTiming='" + paymentTiming + '\'' + + ", createTime=" + createTime + + ", expireTime=" + expireTime + + ", zoneName='" + zoneName + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/EphemeralDisk.java b/src/main/java/com/baidubce/services/dcc/model/EphemeralDisk.java new file mode 100644 index 00000000..3768642d --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/EphemeralDisk.java @@ -0,0 +1,59 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dcc.model; + +/** + * 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/dcc/model/GetDedicatedHostRequest.java b/src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostRequest.java new file mode 100644 index 00000000..131f1ff1 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostRequest.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.dcc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting DCC detail + */ +public class GetDedicatedHostRequest extends AbstractBceRequest { + /** + * the id of DCC + */ + private String dedicatedHostId; + + public String getDedicatedHostId() { + return dedicatedHostId; + } + + public void setDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + } + + public GetDedicatedHostRequest withDedicatedHostId(String dedicatedHostId) { + this.dedicatedHostId = dedicatedHostId; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetInstanceRequest with credentials. + */ + @Override + public GetDedicatedHostRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostResponse.java b/src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostResponse.java new file mode 100644 index 00000000..e443f6e8 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/GetDedicatedHostResponse.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.dcc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * response for getting dcc detail + */ +public class GetDedicatedHostResponse extends AbstractBceResponse { + /** + * dcc detail model info + */ + private DedicatedHostModel dedicatedHost; + + public DedicatedHostModel getDedicatedHost() { + return dedicatedHost; + } + + public void setDedicatedHost(DedicatedHostModel dedicatedHost) { + this.dedicatedHost = dedicatedHost; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsRequest.java b/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsRequest.java new file mode 100644 index 00000000..f3a17de5 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsRequest.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.dcc.model; + +/** + * request model to query dcc list + */ +public class ListDedicatedHostsRequest extends ListRequest { + /** + * the name of available zone + */ + private String zoneName; + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public ListDedicatedHostsRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsResponse.java b/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsResponse.java new file mode 100644 index 00000000..26e04123 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListDedicatedHostsResponse.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.dcc.model; + +import java.util.List; + +/** + * response model to query dcc list + */ +public class ListDedicatedHostsResponse extends ListResponse { + /** + * dcc model info list + */ + private List dedicatedHosts; + + public List getDedicatedHosts() { + return dedicatedHosts; + } + + public void setDedicatedHosts(List dedicatedHosts) { + this.dedicatedHosts = dedicatedHosts; + } +} diff --git a/src/main/java/com/baidubce/services/dcc/model/ListRequest.java b/src/main/java/com/baidubce/services/dcc/model/ListRequest.java new file mode 100644 index 00000000..60ae4469 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListRequest.java @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dcc.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/dcc/model/ListResponse.java b/src/main/java/com/baidubce/services/dcc/model/ListResponse.java new file mode 100644 index 00000000..f7025de7 --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ListResponse.java @@ -0,0 +1,112 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.dcc.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/dcc/model/ResourceUsage.java b/src/main/java/com/baidubce/services/dcc/model/ResourceUsage.java new file mode 100644 index 00000000..2a76aacb --- /dev/null +++ b/src/main/java/com/baidubce/services/dcc/model/ResourceUsage.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.dcc.model; + +import java.util.List; + +/** + * dcc resource usage detail info model + */ +public class ResourceUsage { + /** + * The sum count of CPU within the dcc + */ + private int cpuCount; + + /** + * The free count of CPU within the dcc + */ + private int freeCpuCount; + + /** + * The total size of memory in GB for the dcc + */ + private int memoryCapacityInGB; + + /** + * The free size of memory in GB for the dcc + */ + private int freeMemoryCapacityInGB; + + /** + * The ephemeral disk info list + */ + 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=" + ephemeralDisks + + '}'; + } +} 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..edb0997f --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/EipClient.java @@ -0,0 +1,400 @@ +/* + * 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.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.ListEipsRequest; +import com.baidubce.services.eip.model.ListEipsResponse; +import com.baidubce.services.eip.model.PurchaseReservedEipRequest; +import com.baidubce.services.eip.model.ReleaseEipRequest; +import com.baidubce.services.eip.model.ResizeEipRequest; +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); + } + + /** + * 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). + * 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); + } + + /** + * 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/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..c44d12df --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/BindEipRequest.java @@ -0,0 +1,92 @@ +/* + * 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 binding eip. + */ +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; + + 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 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 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 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..e89a4575 --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/CreateEipRequest.java @@ -0,0 +1,91 @@ +/* + * 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 creating a newly eip. + */ +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; + + 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 Integer getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(Integer bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + public Billing getBilling() { + return billing; + } + + public void setBilling(Billing billing) { + this.billing = billing; + } + + 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 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..f2c41c4a --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/CreateEipResponse.java @@ -0,0 +1,21 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by caidahai on 2016/6/23. + */ +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/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..a11688cf --- /dev/null +++ b/src/main/java/com/baidubce/services/eip/model/ListEipsResponse.java @@ -0,0 +1,148 @@ +/* + * Copyright (C) 2016 Baidu, Inc. All Rights Reserved. + */ +package com.baidubce.services.eip.model; + +import java.util.Date; +import java.util.List; + +/** + * list of eip model + */ +public class ListEipsResponse extends ListResponse { + private List eipList; + + public List getEipList() { + return eipList; + } + + public void setEipList(List eipList) { + this.eipList = eipList; + } + + public static class EipModel { + /** + * name of eip + */ + private String name; + /** + * eip address + */ + private String eip; + /** + * 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; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEip() { + return eip; + } + + public void setEip(String eip) { + this.eip = eip; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + 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 int getBandwidthInMbps() { + return bandwidthInMbps; + } + + public void setBandwidthInMbps(int bandwidthInMbps) { + this.bandwidthInMbps = bandwidthInMbps; + } + + 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 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; + } + } +} 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/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/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/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/iotalarm/IotAlarmClient.java b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java index 21cfe19d..25fa8980 100644 --- a/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java +++ b/src/main/java/com/baidubce/services/iotalarm/IotAlarmClient.java @@ -61,6 +61,17 @@ public IotAlarmClient(String accessKey, String secretKey) { 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); } diff --git a/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java index 2d14c30d..04df0c3e 100644 --- a/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java +++ b/src/main/java/com/baidubce/services/iotalarm/model/Alarm.java @@ -13,6 +13,9 @@ public class Alarm extends AbstractBceResponse { 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; diff --git a/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java index 8d1ddcbd..956aa86b 100644 --- a/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java +++ b/src/main/java/com/baidubce/services/iotalarm/model/ListAlarmRequest.java @@ -10,6 +10,9 @@ 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; @@ -26,4 +29,28 @@ public int getPageSize() { 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/iothub/IotHubClient.java b/src/main/java/com/baidubce/services/iothub/IotHubClient.java index f674ee30..65c1e5a0 100644 --- a/src/main/java/com/baidubce/services/iothub/IotHubClient.java +++ b/src/main/java/com/baidubce/services/iothub/IotHubClient.java @@ -25,10 +25,15 @@ 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.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 +42,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; @@ -52,7 +60,10 @@ 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; @@ -78,6 +89,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"; @@ -657,6 +675,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); @@ -694,12 +755,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/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/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/lss/LssClient.java b/src/main/java/com/baidubce/services/lss/LssClient.java index 38d5549f..342174cc 100644 --- a/src/main/java/com/baidubce/services/lss/LssClient.java +++ b/src/main/java/com/baidubce/services/lss/LssClient.java @@ -49,22 +49,20 @@ import com.baidubce.services.lss.model.GetAllDomainsPlayCountResponse; import com.baidubce.services.lss.model.GetAllDomainsStatisticsRequest; 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.GetOneDomainPlayCountResponse; import com.baidubce.services.lss.model.GetOneDomainStatisticsRequest; +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; @@ -75,18 +73,30 @@ 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.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; @@ -94,6 +104,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; @@ -106,10 +118,10 @@ import com.baidubce.services.lss.model.RefreshSessionResponse; 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; @@ -127,16 +139,6 @@ 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; @@ -166,6 +168,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. */ @@ -246,6 +250,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. */ @@ -2067,6 +2076,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. @@ -2125,4 +2153,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/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/RealTimeStreamStatistics.java b/src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java new file mode 100644 index 00000000..df7ee052 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/RealTimeStreamStatistics.java @@ -0,0 +1,67 @@ +package com.baidubce.services.lss.model; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +/** + * Created by zhengfeng on 17/10/17. + */ +public class RealTimeStreamStatistics { + + 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/route/RouteClient.java b/src/main/java/com/baidubce/services/route/RouteClient.java new file mode 100644 index 00000000..f97523ff --- /dev/null +++ b/src/main/java/com/baidubce/services/route/RouteClient.java @@ -0,0 +1,240 @@ +package com.baidubce.services.route; + +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.route.model.CreateRouteRequest; +import com.baidubce.services.route.model.CreateRouteResponse; +import com.baidubce.services.route.model.DeleteRouteRequest; +import com.baidubce.services.route.model.GetRouteRequest; +import com.baidubce.services.route.model.GetRouteResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +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.List; +import java.util.UUID; + +import static com.baidubce.util.Validate.checkStringNotEmpty; +import static com.google.common.base.Preconditions.checkNotNull; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class RouteClient extends AbstractBceClient { + private static final Logger LOGGER = LoggerFactory.getLogger(RouteClient.class); + + private static final String VERSION = "v1"; + private static final String ROUTE_PREFIX = "route"; + private static final String ROUTE_RULE = "rule"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] vpc_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public RouteClient() { this(new RouteClientConfiguration()); } + + /** + * 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 RouteClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, vpc_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(); + } + + +// public CreateRouteResponse createRoute(String routeTableId, String sourceAddress, String destinationAddress, +// String nexthopType, String nexthopId, String description) { +// CreateRouteRequest createRouteRequest = new CreateRouteRequest(); +// createRouteRequest.withRouteTableId(routeTableId).withSourceAddress(sourceAddress) +// .withDestinationAddress(destinationAddress).withNextHopType(nexthopType).withDescription(description); +// if (!Strings.isNullOrEmpty(nexthopId)) { +// createRouteRequest.withNextHopId(nexthopId); +// } +// return createRoute(createRouteRequest); +// +// } + /** + * Create a route 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 subnet. + * @return List of subnetId newly created + * @throws BceClientException + */ + public CreateRouteResponse createRoute(CreateRouteRequest request) + throws BceClientException { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getRouteTableId(), "routeTableId should not be empty"); + checkStringNotEmpty(request.getSourceAddress(), "source address should not be empty"); + checkStringNotEmpty(request.getDestinationAddress(), "destination address should not be empty"); + checkStringNotEmpty(request.getNexthopType(), "nexthop type should not be empty"); + checkStringNotEmpty(request.getDescription(), "description should not be empty"); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, ROUTE_PREFIX, ROUTE_RULE); + internalRequest.addParameter("clientToken", request.getClientToken()); + fillPayload(internalRequest,request); + return invokeHttpClient(internalRequest, CreateRouteResponse.class); + } + + /** + * Get the detail information of route table for specific route table or/and vpc + * @param routeTableId id of route table, routeTableId and vpcId cannot be empty at the same time + * @param vpcId vpcId, routeTableId and vpcId cannot be empty at the same time + * @return A route table detail model for the specific route table or/and vpc + */ + public GetRouteResponse getRoute(String routeTableId, String vpcId) { + GetRouteRequest request = new GetRouteRequest(); + if (Strings.isNullOrEmpty(vpcId) && Strings.isNullOrEmpty(routeTableId)) { + throw new IllegalArgumentException("routeTableId and vpcId should not be empty at the same time"); + } + else if (!Strings.isNullOrEmpty(routeTableId)) { + request.withRouteTableId(routeTableId); + } + else if (!Strings.isNullOrEmpty(vpcId)) { + request.withVpcId(vpcId); + } + return getRoutes(request); + } + + /** + *Get the detail information of route table for specific route table or/and vpc + * @param getRouteRequest + * @return A route table detail model for the specific route table or/and vp + */ + private GetRouteResponse getRoutes(GetRouteRequest getRouteRequest) { + checkNotNull(getRouteRequest, "route request should not be null"); + if (Strings.isNullOrEmpty(getRouteRequest.getRouteTableId()) + && Strings.isNullOrEmpty(getRouteRequest.getVpcId())) { + throw new IllegalArgumentException("routeTableId and vpcId cannot be empty at the same time"); + } + InternalRequest internalRequest = this.createRequest( + getRouteRequest, HttpMethodName.GET, ROUTE_PREFIX); + if (!Strings.isNullOrEmpty(getRouteRequest.getVpcId())) { + internalRequest.addParameter("vpcId", getRouteRequest.getVpcId()); + } + else if (!Strings.isNullOrEmpty(getRouteRequest.getRouteTableId())) { + internalRequest.addParameter("routeTableId", getRouteRequest.getRouteTableId()); + } + return this.invokeHttpClient(internalRequest, GetRouteResponse.class); + + } + + /** + * Delete the specific route rule + * @param routeRuleId + */ + public void deleteRouteRule(String routeRuleId) { + deleteRouteRule(new DeleteRouteRequest().withRouteRuleId(routeRuleId)); + } + + /** + * Delete the specific route rule + * @param deleteRouteRequest the request containing all options for deleting route rule. + */ + public void deleteRouteRule(DeleteRouteRequest deleteRouteRequest) { + checkNotNull(deleteRouteRequest, "request should not be null."); + checkNotNull(deleteRouteRequest.getRouteRuleId(), "request routeRuleId should not be null."); + if (Strings.isNullOrEmpty(deleteRouteRequest.getClientToken())) { + deleteRouteRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + deleteRouteRequest, HttpMethodName.DELETE, ROUTE_PREFIX, ROUTE_RULE, + deleteRouteRequest.getRouteRuleId()); + internalRequest.addParameter("clientToken", deleteRouteRequest.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + + +} diff --git a/src/main/java/com/baidubce/services/route/RouteClientConfiguration.java b/src/main/java/com/baidubce/services/route/RouteClientConfiguration.java new file mode 100644 index 00000000..57b637cd --- /dev/null +++ b/src/main/java/com/baidubce/services/route/RouteClientConfiguration.java @@ -0,0 +1,9 @@ +package com.baidubce.services.route; + +import com.baidubce.BceClientConfiguration; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class RouteClientConfiguration extends BceClientConfiguration { +} diff --git a/src/main/java/com/baidubce/services/route/model/CreateRouteRequest.java b/src/main/java/com/baidubce/services/route/model/CreateRouteRequest.java new file mode 100644 index 00000000..d0807c36 --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/CreateRouteRequest.java @@ -0,0 +1,227 @@ +package com.baidubce.services.route.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by zhangjing60 on 17/8/2. + */ + + +public class CreateRouteRequest extends AbstractBceRequest { + + /** + * The API version number + */ + private String version; + /** + * 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 + * + */ + private String clientToken; + + /** + * The id of the route table + */ + + private String routeTableId; + + /** + * The source address which can be 0.0.0.0/0, otherwise, the traffic source of the routing table must belong + * to a subnet under the VPC. When the source address is user-defined, the customer segment needs to be within + * the existing subnet segment + */ + + private String sourceAddress; + + /** + * The destination address which can be 0.0.0.0/0, otherwise, the destination address cannot be overlapped with + * this VPC's cidr (except for the destination segment or the VPC's CIDR is 0.0.0.0/0) + */ + + private String destinationAddress; + + /** + * next hop id + * when the nexthopType is "defaultGateway",this field can be empty + */ + + private String nexthopId; + + /** + * route type + * The Bcc type is "custom"; + * the VPN type is "VPN"; + * the NAT type is "NAT"; + * the local gateway type is "defaultGateway"" + */ + + private String nexthopType; + + /** + * The option param to describe the route table + */ + + private String description; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getSourceAddress() { + return sourceAddress; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + public String getNexthopId() { + return nexthopId; + } + + public void setNexthopId(String nexthopId) { + this.nexthopId = nexthopId; + } + + public String getNexthopType() { + return nexthopType; + } + + public void setNexthopType(String nexthopType) { + this.nexthopType = nexthopType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + + public String getRouteTableId() { + return routeTableId; + } + + public void setRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + } + + public CreateRouteRequest withVersion(String version) { + this.version = version; + return this; + } + + /** + * 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 + * + * @return CreateSubnetRequest with specific clientToken + */ + + public CreateRouteRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + + /** + * configure route table id for the request + * @param routeTableId the id of the route table + * @return CreateRouteRequest with routeTableId + */ + public CreateRouteRequest withRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + return this; + } + + /** + * configure source address for the request + * @param sourceAddress the source address + * @return CreateRouteRequest with source address + */ + public CreateRouteRequest withSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + return this; + } + + /** + * configure destination address for the request + * @param destinationAddress the destination address + * @return CreateRouteRequest with destination address + */ + public CreateRouteRequest withDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + return this; + } + + /** + * configure next hop id for the request + * @param nexthopId the next hop id + * @return CreateRouteRequest with the nexthopId + */ + public CreateRouteRequest withNextHopId(String nexthopId) { + this.nexthopId = nexthopId; + return this; + } + + /** + * configure next hop type for the request + * @param nexthopType the route type: BCC-"custom", VPN-"vpn", NAT-"nat" + * @return CreateRouteRequest with the nexthopType + */ + public CreateRouteRequest withNextHopType(String nexthopType) { + this.nexthopType = nexthopType; + return this; + } + + /** + * configure description for the request + * @param description the description for the route table + * @return CreateRouteRequest with the description + */ + public CreateRouteRequest withDescription(String description) { + this.description = description; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateRouteRequest with credentials. + */ + @Override + public CreateRouteRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/route/model/CreateRouteResponse.java b/src/main/java/com/baidubce/services/route/model/CreateRouteResponse.java new file mode 100644 index 00000000..7fcb184e --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/CreateRouteResponse.java @@ -0,0 +1,30 @@ +package com.baidubce.services.route.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class CreateRouteResponse extends AbstractBceResponse { + + /** + * the route rule id + */ + private String routeRuleId; + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } + + @Override + public String toString() { + return "routeRuleId{" + + "routeRuleId=" + routeRuleId + + '}'; + } + +} diff --git a/src/main/java/com/baidubce/services/route/model/DeleteRouteRequest.java b/src/main/java/com/baidubce/services/route/model/DeleteRouteRequest.java new file mode 100644 index 00000000..911e0f1c --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/DeleteRouteRequest.java @@ -0,0 +1,95 @@ +package com.baidubce.services.route.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class DeleteRouteRequest extends AbstractBceRequest { + + /** + * the API version number + */ + private String version; + + /** + * 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 + * + */ + private String clientToken; + + /** + * the route rule id + */ + private String routeRuleId; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } + + /** + * Configure the version for the request + * @param version the API version number + * @return DeleteRouteRequest with version + */ + public DeleteRouteRequest withVersion(String version) { + this.version = version; + 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. + * See more detail at + * @return DeleteRouteRequest with client token + * + */ + public DeleteRouteRequest withClientToken(String clientToken) { + this.clientToken = clientToken; + return this; + } + + /** + * Configure route rule id for the request + * @param routeRuleId the id of the route rule + * @return DeleteRouteRequest routeRuleId + */ + public DeleteRouteRequest withRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + return this; + } + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteRouteRequest with credentials. + */ + @Override + public DeleteRouteRequest withRequestCredentials(BceCredentials credentials) { + return null; + } +} diff --git a/src/main/java/com/baidubce/services/route/model/GetRouteRequest.java b/src/main/java/com/baidubce/services/route/model/GetRouteRequest.java new file mode 100644 index 00000000..f75e9b5c --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/GetRouteRequest.java @@ -0,0 +1,97 @@ +package com.baidubce.services.route.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class GetRouteRequest extends AbstractBceRequest { + + + /** + * the API's version number + */ + private String version; + /** + * The id of the route table + * there must be at least one parameter, either routeTableId or vpcId + */ + private String routeTableId; + /** + * The vpc id + * there must be at least one parameter, either routeTableId or vpcId + */ + private String vpcId; + + public String getVersion() { + return version; + } + + public void setVersion(String version) { + this.version = version; + } + + public String getRouteTableId() { + return routeTableId; + } + + public void setRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + /** + * Configure the version for the request + * @param version the API version number + * @returnGetRouteRequest with version + */ + public GetRouteRequest withVersion(String version) { + this.version = version; + return this; + } + + /** + * configure routeTableId for the request + * @param routeTableId the id of the route table + * @returnGetRouteRequest with routeTableId + */ + public GetRouteRequest withRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + return this; + } + + + /** + * configure vpcId for the request + * @param vpcId the vpcId + * @returnGetRouteRequest with vpcId + */ + public GetRouteRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetRouteRequest with credentials. + */ + @Override + public GetRouteRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + + } + +} diff --git a/src/main/java/com/baidubce/services/route/model/GetRouteResponse.java b/src/main/java/com/baidubce/services/route/model/GetRouteResponse.java new file mode 100644 index 00000000..bb4b53ab --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/GetRouteResponse.java @@ -0,0 +1,54 @@ +package com.baidubce.services.route.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class GetRouteResponse extends AbstractBceResponse { + + /** + * The id of the route table + * there must be at least one parameter, either routeTableId or vpcId + */ + private String routeTableId; + + /** + * The vpc id + * there must be at least one parameter, either routeTableId or vpcId + */ + private String vpcId; + + /** + * List of route rules + * + */ + private List routeRules; + + public String getRouteTableId() { + return routeTableId; + } + + public void setRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public List getRouteRules() { + return routeRules; + } + + public void setRouteRules(List routeRules) { + this.routeRules = routeRules; + } + +} diff --git a/src/main/java/com/baidubce/services/route/model/NetworkAction.java b/src/main/java/com/baidubce/services/route/model/NetworkAction.java new file mode 100644 index 00000000..721c93cb --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/NetworkAction.java @@ -0,0 +1,12 @@ +package com.baidubce.services.route.model; + +/** + * The action for operating. + */ +public enum NetworkAction { + + /** + * The action to modify the attribute. + */ + modifyAttribute +} diff --git a/src/main/java/com/baidubce/services/route/model/RouteRule.java b/src/main/java/com/baidubce/services/route/model/RouteRule.java new file mode 100644 index 00000000..7adc10db --- /dev/null +++ b/src/main/java/com/baidubce/services/route/model/RouteRule.java @@ -0,0 +1,117 @@ +package com.baidubce.services.route.model; + +/** + * Created by zhangjing60 on 17/8/2. + */ +public class RouteRule { + + + /** + * the id of the route rule + */ + private String routeRuleId; + + /** + * the id of the route table + */ + private String routeTableId; + + + + /** + * The source address + */ + + private String sourceAddress; + + /** + * The destination address + */ + + private String destinationAddress; + + /** + * next hop id + * when the nexthopType is "defaultGateway",this field can be empty + */ + + private String nexthopId; + + /** + * route type + * The Bcc type is "custom"; + * the VPN type is "VPN"; + * the NAT type is "NAT"; + * the local gateway type is "defaultGateway" + * the system default type is "sys" + * The system automatically generates a route rule of the given type for each subnet. + * The route rule id of this type is empty, cannot be edited, can not be deleted, nor can be added + */ + + private String nexthopType; + + /** + * The option param to describe the route table + */ + + private String description; + + public String getRouteRuleId() { + return routeRuleId; + } + + public void setRouteRuleId(String routeRuleId) { + this.routeRuleId = routeRuleId; + } + + public String getSourceAddress() { + return sourceAddress; + } + + public void setSourceAddress(String sourceAddress) { + this.sourceAddress = sourceAddress; + } + + public String getRouteTableId() { + return routeTableId; + } + + public void setRouteTableId(String routeTableId) { + this.routeTableId = routeTableId; + } + + public String getDestinationAddress() { + return destinationAddress; + } + + public void setDestinationAddress(String destinationAddress) { + this.destinationAddress = destinationAddress; + } + + 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 getNexthopType() { + return nexthopType; + } + + public void setNexthopType(String nexthopType) { + this.nexthopType = nexthopType; + } + + + +} diff --git a/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java b/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java index 11925126..d3b81a89 100644 --- a/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java +++ b/src/main/java/com/baidubce/services/ruleengine/RuleEngineClient.java @@ -74,6 +74,12 @@ public RuleEngineClient(String accessKey, String secretKey) { public ListRuleResponse listRules(ListRuleRequest request) { InternalRequest internalRequest = createRequest(request, HttpMethodName.GET, RULES); + 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, ListRuleResponse.class); } diff --git a/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java b/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java index 08019345..7ec87e8f 100644 --- a/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java +++ b/src/main/java/com/baidubce/services/ruleengine/model/DestinationKind.java @@ -18,4 +18,5 @@ public class DestinationKind { public static final String KAFKA = "KAFKA"; public static final String BOS = "BOS"; public static final String MQTT_DYNAMIC = "MQTT_DYNAMIC"; + public static final String SMS = "SMS"; } diff --git a/src/main/java/com/baidubce/services/subnet/SubnetClient.java b/src/main/java/com/baidubce/services/subnet/SubnetClient.java new file mode 100644 index 00000000..4aefb54e --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/SubnetClient.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.subnet; + +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.subnet.model.CreateSubnetRequest; +import com.baidubce.services.subnet.model.CreateSubnetResponse; +import com.baidubce.services.subnet.model.DeleteSubnetRequest; +import com.baidubce.services.subnet.model.GetSubnetRequest; +import com.baidubce.services.subnet.model.GetSubnetResponse; +import com.baidubce.services.subnet.model.ListSubnetsRequest; +import com.baidubce.services.subnet.model.ListSubnetsResponse; +import com.baidubce.services.subnet.model.ModifySubnetAttributesRequest; +import com.baidubce.services.subnet.model.NetworkAction; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +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.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 subnet part. + */ +public class SubnetClient extends AbstractBceClient { + + private static final Logger LOGGER = LoggerFactory.getLogger(SubnetClient.class); + + private static final String VERSION = "v1"; + private static final String SUBNET_PREFIX = "subnet"; + + /** + * Responsible for handling httpResponses from all network service calls. + */ + private static final HttpResponseHandler[] vpc_handlers = new HttpResponseHandler[]{ + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new client to invoke service methods on network. + */ + public SubnetClient() { + this(new SubnetClientConfiguration()); + } + + /** + * 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 SubnetClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, vpc_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(); + } + + /** + * + * @param name The name of subnet that will be created. + * @param vpcId The id of vpc which this subnet belong. + * @param cidr The CIDR of this subnet. + * @param zoneName + * the name of available zone which the subnet belong + * through listZones, we can get all available zone info at current region + * ee.g. "cn-gz-a" "cn-gz-b" + * @return + */ + public CreateSubnetResponse createSubnet(String name, String vpcId, String cidr, String zoneName) { + CreateSubnetRequest request = new CreateSubnetRequest(); + request.withName(name).withCidr(cidr).withZoneName(zoneName).withVpcId(vpcId); + return createSubnet(request); + + } + /** + * Create a subnet 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 subnet. + * @return List of subnetId newly created + * @throws BceClientException + */ + public CreateSubnetResponse createSubnet(CreateSubnetRequest request) + throws BceClientException { + checkNotNull(request, "request should not be null."); + if (Strings.isNullOrEmpty(request.getClientToken())) { + request.setClientToken(this.generateClientToken()); + } + checkStringNotEmpty(request.getName(), "name should not be empty"); + checkStringNotEmpty(request.getCidr(), "cidr should not be empty"); + checkStringNotEmpty(request.getZoneName(), "zone name should not be empty"); + checkStringNotEmpty(request.getVpcId(), "vpc id should not be empty"); + + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.POST, SUBNET_PREFIX); + if (!Strings.isNullOrEmpty(request.getClientToken())) { + internalRequest.addParameter("clientToken", request.getClientToken()); + } + fillPayload(internalRequest, request); + return invokeHttpClient(internalRequest, CreateSubnetResponse.class); + } + + /** + * Return a list of subnets owned by the authenticated user. + * + * @return The response containing a list of subnets owned by the authenticated user. + */ + public ListSubnetsResponse listSubnets() { + return this.listSubnets(new ListSubnetsRequest()); + } + + /** + * Return a list of subnet owned by the authenticated user. + * + * @param request The request containing all options for listing own's subnet. + * @return The response containing a list of subnets owned by the authenticated user. + */ + public ListSubnetsResponse listSubnets(ListSubnetsRequest request) { + checkNotNull(request, "request should not be null."); + InternalRequest internalRequest = this.createRequest(request, HttpMethodName.GET, SUBNET_PREFIX); + if (request.getMarker() != null) { + internalRequest.addParameter("marker", request.getMarker()); + } + if (request.getMaxKeys() > 0) { + internalRequest.addParameter("maxKeys", String.valueOf(request.getMaxKeys())); + } + return invokeHttpClient(internalRequest, ListSubnetsResponse.class); + } + + /** + * Get the detail information of specified subnet. + * + * @param subnetId The id of the subnet. + * @return A subnet detail model for the subnetId. + */ + public GetSubnetResponse getSubnet(String subnetId) { + return getSubnet(new GetSubnetRequest().withSubnetId(subnetId)); + } + + /** + * Get the detail information of specified subnet. + * + * @param getSubnetRequest The request containing all options for getting the subnet info. + * @return A subnet detail model for the subnetId. + */ + public GetSubnetResponse getSubnet(GetSubnetRequest getSubnetRequest) { + checkNotNull(getSubnetRequest, "request should not be null."); + checkNotNull(getSubnetRequest.getSubnetId(), "request vpcId should not be null."); + InternalRequest internalRequest = this.createRequest( + getSubnetRequest, HttpMethodName.GET, SUBNET_PREFIX, getSubnetRequest.getSubnetId()); + return this.invokeHttpClient(internalRequest, GetSubnetResponse.class); + } + + /** + * Delete the specified subnet owned by the user. + *

+ * + * @param subnetId The id of the subnet to delete. + */ + public void deleteSubnet(String subnetId) { + this.deleteSubnet(new DeleteSubnetRequest().withSubnetId(subnetId)); + } + + /** + * Delete the specified subnet owned by the user. + *

+ * + * @param deleteSubnetRequest the request containing all options for deleting own's subnet. + */ + public void deleteSubnet(DeleteSubnetRequest deleteSubnetRequest) { + checkNotNull(deleteSubnetRequest, "request should not be null."); + checkNotNull(deleteSubnetRequest.getSubnetId(), "request subnetId should not be null."); + if (Strings.isNullOrEmpty(deleteSubnetRequest.getClientToken())) { + deleteSubnetRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + deleteSubnetRequest, HttpMethodName.DELETE, SUBNET_PREFIX, deleteSubnetRequest.getSubnetId()); + internalRequest.addParameter("clientToken", deleteSubnetRequest.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } + + /** + * Modifying the special attribute to new value of the subnet owned by the user. + * @param subnetId The id of the subnet + * @param name The name of the subnet after modifying + */ + public void modifySubnetAttributes(String subnetId, String name) { + ModifySubnetAttributesRequest request = new ModifySubnetAttributesRequest(); + modifySubnetAttributes(request.withName(name).withSubnetId(subnetId)); + } + /** + * Modifying the special attribute to new value of the subnet owned by the user. + *

+ * + * @param modifySubnetAttributesRequest The request containing all options for modifying own's subnet. + */ + public void modifySubnetAttributes(ModifySubnetAttributesRequest modifySubnetAttributesRequest) { + checkNotNull(modifySubnetAttributesRequest, "request should not be null."); + checkStringNotEmpty(modifySubnetAttributesRequest.getSubnetId(), "request subnetId should not be empty."); + checkStringNotEmpty(modifySubnetAttributesRequest.getName(), "request name should not be empty."); + if (Strings.isNullOrEmpty(modifySubnetAttributesRequest.getClientToken())) { + modifySubnetAttributesRequest.setClientToken(this.generateClientToken()); + } + InternalRequest internalRequest = this.createRequest( + modifySubnetAttributesRequest, HttpMethodName.PUT, + SUBNET_PREFIX, modifySubnetAttributesRequest.getSubnetId()); + fillPayload(internalRequest, modifySubnetAttributesRequest); + internalRequest.addParameter(NetworkAction.modifyAttribute.name(), null); + internalRequest.addParameter("clientToken", modifySubnetAttributesRequest.getClientToken()); + this.invokeHttpClient(internalRequest, AbstractBceResponse.class); + } +} diff --git a/src/main/java/com/baidubce/services/subnet/SubnetClientConfiguration.java b/src/main/java/com/baidubce/services/subnet/SubnetClientConfiguration.java new file mode 100644 index 00000000..838a1662 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/SubnetClientConfiguration.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.subnet; + +import com.baidubce.BceClientConfiguration; + +/** + * Extended client configuration for bcc service. + */ +public class SubnetClientConfiguration extends BceClientConfiguration { + +} diff --git a/src/main/java/com/baidubce/services/subnet/model/CreateSubnetRequest.java b/src/main/java/com/baidubce/services/subnet/model/CreateSubnetRequest.java new file mode 100644 index 00000000..be1556c1 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/CreateSubnetRequest.java @@ -0,0 +1,209 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for creating a newly subnet. + */ +public class CreateSubnetRequest 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 subnet that will be created. + */ + private String name; + + /** + * the name of available zone which the subnet belong + * through listZones, we can get all available zone info at current region + * ee.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * The CIDR of this subnet. + */ + private String cidr; + + /** + * The id of vpc which this subnet belong. + */ + private String vpcId; + + /** + * The option param to describe the type of subnet create + * See more detail on + * + * Subnet API doc + */ + private String subnetType; + + /** + * The option param to describe the subnet + */ + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + 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 getSubnetType() { + return subnetType; + } + + public void setSubnetType(String subnetType) { + this.subnetType = subnetType; + } + + 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; + } + + /** + * 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 CreateSubnetRequest with specific clientToken + */ + public CreateSubnetRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + /** + * Configure name for the request. + * + * @param name The name of subnet + * @return CreateSubnetRequest with specific name + */ + public CreateSubnetRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure zoneName for the request. + * + * @param zoneName the name of available zone + * @return CreateSubnetRequest with zone name + */ + public CreateSubnetRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure cidr for the request. + * + * @param cidr the cidr of subnet + * @return CreateSubnetRequest with cidr + */ + public CreateSubnetRequest withCidr(String cidr) { + this.cidr = cidr; + return this; + } + + /** + * Configure vpc id for the request. + * + * @param vpcId the vpcId of subnet + * @return CreateSubnetRequest with vpcId + */ + public CreateSubnetRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure subnet type for the request. + * + * @param subnetType the type of subnet + * @return CreateSubnetRequest with subnet type + */ + public CreateSubnetRequest withSubnetType(String subnetType) { + this.subnetType = subnetType; + return this; + } + + /** + * Configure description for the request. + * + * @param description the type of subnet + * @return CreateSubnetRequest with description + */ + public CreateSubnetRequest withDescription(String description) { + this.description = description; + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return CreateInstanceRequest with credentials. + */ + public CreateSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/CreateSubnetResponse.java b/src/main/java/com/baidubce/services/subnet/model/CreateSubnetResponse.java new file mode 100644 index 00000000..ba531135 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/CreateSubnetResponse.java @@ -0,0 +1,28 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for CreateSubnetRequest. + */ +public class CreateSubnetResponse extends AbstractBceResponse { + /** + * The id of subnet created. + */ + private String subnetId; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + @Override + public String toString() { + return "subnetId{" + + "subnetId=" + subnetId + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/DeleteSubnetRequest.java b/src/main/java/com/baidubce/services/subnet/model/DeleteSubnetRequest.java new file mode 100644 index 00000000..e2183a1e --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/DeleteSubnetRequest.java @@ -0,0 +1,82 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * The request for deleting subnet. + */ +public class DeleteSubnetRequest 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 subnet. + */ + private String subnetId; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + 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 DeleteSubnetRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + /** + * Configure the subnetId for the request. + * + * @param subnetId The id of subnet. + * @return GetSubnetRequest with specified subnetId. + */ + public DeleteSubnetRequest withSubnetId(String subnetId) { + this.setSubnetId(subnetId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return DeleteSubnetRequest with credentials. + */ + @Override + public DeleteSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/GetSubnetRequest.java b/src/main/java/com/baidubce/services/subnet/model/GetSubnetRequest.java new file mode 100644 index 00000000..50992218 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/GetSubnetRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * The request for getting subnet + */ +public class GetSubnetRequest extends AbstractBceRequest { + + /** + * The id of subnet. + */ + private String subnetId; + + public String getSubnetId() { + return subnetId; + } + + public void setSubnetId(String subnetId) { + this.subnetId = subnetId; + } + + /** + * Configure the subnetId for the request. + * + * @param subnetId The id of subnet. + * @return GetSubnetRequest with specified subnetId. + */ + public GetSubnetRequest withSubnetId(String subnetId) { + this.setSubnetId(subnetId); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return GetSubnetRequest with credentials. + */ + @Override + public GetSubnetRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/GetSubnetResponse.java b/src/main/java/com/baidubce/services/subnet/model/GetSubnetResponse.java new file mode 100644 index 00000000..34810f97 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/GetSubnetResponse.java @@ -0,0 +1,22 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * The response for GetSubnetRequest. + */ +public class GetSubnetResponse extends AbstractBceResponse { + + /** + * A subnet detail model contains all of the information of specific subnet. + */ + private Subnet subnet; + + public Subnet getSubnet() { + return subnet; + } + + public void setSubnet(Subnet subnet) { + this.subnet = subnet; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/ListSubnetsRequest.java b/src/main/java/com/baidubce/services/subnet/model/ListSubnetsRequest.java new file mode 100644 index 00000000..500fe300 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/ListSubnetsRequest.java @@ -0,0 +1,125 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.ListRequest; + +/** + * The request model to query subnet list + */ +public class ListSubnetsRequest extends ListRequest { + + /** + * The id of vpc which this subnet belong. + */ + private String vpcId; + + /** + * the name of available zone which the subnet belong + * through listZones, we can get all available zone info at current region + * ee.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * The option param to describe the type of subnet create + * See more detail on + * + * Subnet API doc + */ + private String subnetType; + + /** + * Configure zoneName for the request. + * + * @param zoneName the name of available zone + * @return ListSubnetsRequest with zone name + */ + public ListSubnetsRequest withZoneName(String zoneName) { + this.zoneName = zoneName; + return this; + } + + /** + * Configure vpc id for the request. + * + * @param vpcId the vpcId of subnet + * @return ListSubnetsRequest with vpcId + */ + public ListSubnetsRequest withVpcId(String vpcId) { + this.vpcId = vpcId; + return this; + } + + /** + * Configure subnet type for the request. + * + * @param subnetType the type of subnet + * @return ListSubnetsRequest with subnet type + */ + public ListSubnetsRequest withSubnetType(String subnetType) { + this.subnetType = subnetType; + return this; + } + + public String getVpcId() { + return vpcId; + } + + public void setVpcId(String vpcId) { + this.vpcId = vpcId; + } + + public String getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + public String getSubnetType() { + return subnetType; + } + + public void setSubnetType(String subnetType) { + this.subnetType = subnetType; + } + + /** + * 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 ListSubnetsRequest with specified marker. + */ + @Override + public ListSubnetsRequest 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 ListSubnetsRequest with specified maxKeys. + */ + @Override + public ListSubnetsRequest withMaxKeys(int maxKeys) { + this.setMaxKeys(maxKeys); + return this; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ListSubnetsRequest with credentials. + */ + @Override + public ListSubnetsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/ListSubnetsResponse.java b/src/main/java/com/baidubce/services/subnet/model/ListSubnetsResponse.java new file mode 100644 index 00000000..39fc9723 --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/ListSubnetsResponse.java @@ -0,0 +1,24 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.model.ListResponse; + +import java.util.List; + +/** + * The response for CreateSubnetRequest. + */ +public class ListSubnetsResponse extends ListResponse { + + /** + * List of subnet info + */ + private List subnets; + + public List getSubnets() { + return subnets; + } + + public void setSubnets(List subnets) { + this.subnets = subnets; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/ModifySubnetAttributesRequest.java b/src/main/java/com/baidubce/services/subnet/model/ModifySubnetAttributesRequest.java new file mode 100644 index 00000000..f3c4ec2a --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/ModifySubnetAttributesRequest.java @@ -0,0 +1,130 @@ +package com.baidubce.services.subnet.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * request model to modify subnet + */ +public class ModifySubnetAttributesRequest 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 subnet modified. + */ + private String subnetId; + + /** + * The new name of subnet + */ + private String name; + + /** + * The new value description of subnet. + */ + private String description; + + /** + * 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 ModifySubnetAttributesRequest with specific clientToken + */ + public ModifySubnetAttributesRequest withClientToken(String clientToken) { + this.setClientToken(clientToken); + return this; + } + + /** + * Configure subnet id for the request. + * + * @param subnetId the id of subnet + * @return ModifySubnetAttributesRequest with subnetId + */ + public ModifySubnetAttributesRequest withSubnetId(String subnetId) { + this.subnetId = subnetId; + return this; + } + + /** + * Configure name for the request. + * + * @param name The new name of subnet + * @return ModifySubnetAttributesRequest with specific name + */ + public ModifySubnetAttributesRequest withName(String name) { + this.name = name; + return this; + } + + /** + * Configure description for the request. + * + * @param description the type of subnet + * @return ModifySubnetAttributesRequest with description + */ + public ModifySubnetAttributesRequest withDescription(String description) { + this.description = description; + return this; + } + + public String getClientToken() { + return clientToken; + } + + public void setClientToken(String clientToken) { + this.clientToken = clientToken; + } + + 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; + } + + /** + * Configure request credential for the request. + * + * @param credentials a valid instance of BceCredentials. + * @return ModifyVpcAttributesRequest with credentials. + */ + @Override + public ModifySubnetAttributesRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/subnet/model/NetworkAction.java b/src/main/java/com/baidubce/services/subnet/model/NetworkAction.java new file mode 100644 index 00000000..29396f7f --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/NetworkAction.java @@ -0,0 +1,12 @@ +package com.baidubce.services.subnet.model; + +/** + * The action for operating. + */ +public enum NetworkAction { + + /** + * The action to modify the attribute. + */ + modifyAttribute +} diff --git a/src/main/java/com/baidubce/services/subnet/model/Subnet.java b/src/main/java/com/baidubce/services/subnet/model/Subnet.java new file mode 100644 index 00000000..87970e4a --- /dev/null +++ b/src/main/java/com/baidubce/services/subnet/model/Subnet.java @@ -0,0 +1,116 @@ +package com.baidubce.services.subnet.model; + +/** + * subnet detail info model + */ +public class Subnet { + + /** + * The name of subnet. + */ + private String name; + + /** + * The id of subnet. + */ + private String subnetId; + + /** + * the name of available zone which the subnet belong + * through listZones, we can get all available zone info at current region + * ee.g. "cn-gz-a" "cn-gz-b" + */ + private String zoneName; + + /** + * The CIDR of this subnet. + */ + private String cidr; + + /** + * The id of vpc which this subnet belong. + */ + private String vpcId; + + /** + * The type of subnet + * See more detail on + * + * Subnet API doc + */ + private String subnetType; + + /** + * The description of subnet. + */ + 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 getZoneName() { + return zoneName; + } + + public void setZoneName(String zoneName) { + this.zoneName = zoneName; + } + + 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 getSubnetType() { + return subnetType; + } + + public void setSubnetType(String subnetType) { + this.subnetType = subnetType; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public String toString() { + return "Subnet{" + + "subnetId='" + subnetId + '\'' + + ", name='" + name + '\'' + + ", zoneName='" + zoneName + '\'' + + ", cidr='" + cidr + '\'' + + ", vpcId='" + vpcId + '\'' + + ", subnetType='" + subnetType + '\'' + + ", description='" + description + '\'' + + '}'; + } +} diff --git a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java index 2f19efd5..42fe28d6 100644 --- a/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java +++ b/src/main/java/com/baidubce/services/tsdb/TsdbConstants.java @@ -21,22 +21,35 @@ public class TsdbConstants { public static final String AGGREGATOR_NAME_DIV = "Div"; public static final String AGGREGATOR_NAME_SCALE = "Scale"; public static final String AGGREGATOR_NAME_RATE = "Rate"; + public static final String AGGREGATOR_NAME_ADJACENT_UNIQUE = "AdjacentUnique"; // GroupInfo name. + @Deprecated public static final String GROUP_INFO_NAME_TYPE = "Type"; public static final String GROUP_INFO_NAME_TAG = "Tag"; + @Deprecated public static final String GROUP_INFO_NAME_TIME = "Time"; + @Deprecated public static final String GROUP_INFO_NAME_VALUE = "Value"; // GroupInfo type. + @Deprecated public static final String GROUP_INFO_TYPE_NUMBER = "Number"; + @Deprecated public static final String GROUP_INFO_TYPE_STRING = "String"; // GroupBy name. public static final String GROUP_BY_NAME_TAG = "Tag"; + @Deprecated public static final String GROUP_BY_NAME_TIME = "Time"; + @Deprecated public static final String GROUP_BY_NAME_VALUE = "Value"; + // Field type. + public static final String FIELD_TYPE_NUMBER = "Number"; + public static final String FIELD_TYPE_STRING = "String"; + public static final String FIELD_TYPE_BYTES = "Bytes"; + // Datapoint value type. public static final String TYPE_BYTES = "Bytes"; public static final String TYPE_LONG = "Long"; @@ -63,4 +76,5 @@ public class TsdbConstants { // Fill type. public static final String FILL_TYPE_LINEAR = "Linear"; public static final String FILL_TYPE_PREVIOUS = "Previous"; + public static final String FILL_TYPE_FIXED = "Fixed"; } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Fill.java b/src/main/java/com/baidubce/services/tsdb/model/Fill.java index 6fb868b9..aa578275 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Fill.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Fill.java @@ -1,5 +1,10 @@ package com.baidubce.services.tsdb.model; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.DoubleNode; +import com.fasterxml.jackson.databind.node.LongNode; +import com.fasterxml.jackson.databind.node.TextNode; + /** * Represent the fill in query. * @@ -27,6 +32,11 @@ public class Fill { */ private String maxWriteInterval; + /** + * Required when type is {@link com.baidubce.services.tsdb.TsdbConstants#FILL_TYPE_FIXED}. + */ + private JsonNode value; + public String getType() { return type; } @@ -51,6 +61,22 @@ public void setMaxWriteInterval(String maxWriteInterval) { this.maxWriteInterval = maxWriteInterval; } + public JsonNode getValue() { + return value; + } + + public void setValue(long value) { + this.value = new LongNode(value); + } + + public void setValue(double value) { + this.value = new DoubleNode(value); + } + + public void setValue(String value) { + this.value = new TextNode(value); + } + public Fill withType(String type) { setType(type); return this; @@ -66,4 +92,19 @@ public Fill withMaxWriteInterval(String maxWriteInterval) { return this; } + public Fill withValue(long value) { + setValue(value); + return this; + } + + public Fill withValue(double value) { + setValue(value); + return this; + } + + public Fill withValue(String value) { + setValue(value); + return this; + } + } diff --git a/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java b/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java index 5222e14a..0d4250ad 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java +++ b/src/main/java/com/baidubce/services/tsdb/model/GroupBy.java @@ -9,7 +9,7 @@ public class GroupBy { /** * Required. - * Represent the name of GroupBy which should be one of Tag, Time and Value. + * Represent the name of GroupBy which should be Tag. */ private String name; @@ -23,18 +23,21 @@ public class GroupBy { * Required when name is Time. * Represent range size of time for grouping by time. */ + @Deprecated private String timeRangeSize; /** * Required when name is Time. * Represent the count of group for grouping by time. */ + @Deprecated private Integer groupCount; /** * Required when name is Value. * Represent the range size of value for grouping by value. */ + @Deprecated private Integer valueRangeSize; public String getName() { @@ -53,26 +56,32 @@ public void setTags(List tags) { this.tags = tags; } + @Deprecated public String getTimeRangeSize() { return timeRangeSize; } + @Deprecated public void setTimeRangeSize(String timeRangeSize) { this.timeRangeSize = timeRangeSize; } + @Deprecated public Integer getGroupCount() { return groupCount; } + @Deprecated public void setGroupCount(Integer groupCount) { this.groupCount = groupCount; } + @Deprecated public Integer getValueRangeSize() { return valueRangeSize; } + @Deprecated public void setValueRangeSize(Integer valueRangeSize) { this.valueRangeSize = valueRangeSize; } @@ -86,17 +95,20 @@ public GroupBy withTags(List tags) { this.tags = tags; return this; } - + + @Deprecated public GroupBy withTimeRangeSize(String timeRangeSize) { this.timeRangeSize = timeRangeSize; return this; } - + + @Deprecated public GroupBy withGroupCount(int groupCount) { this.groupCount = groupCount; return this; } - + + @Deprecated public GroupBy withValueRangeSize(int valueRangeSize) { this.valueRangeSize = valueRangeSize; return this; diff --git a/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java b/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java index 9e74dc9e..108f0b1c 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java +++ b/src/main/java/com/baidubce/services/tsdb/model/GroupInfo.java @@ -11,7 +11,7 @@ public class GroupInfo { /** - * The name of GroupInfo which should be one of the Type, Tag, Time and Value. + * The name of GroupInfo which should be Tag. */ private String name; @@ -19,6 +19,7 @@ public class GroupInfo { * Available when the name is Type. * Represent the type of this group which is one of the Number, String and Bytes. */ + @Deprecated private String type; /** @@ -31,18 +32,21 @@ public class GroupInfo { * Available when name is Time. * Represent the group number of this group. */ + @Deprecated private Integer groupNumber; /** * Available when name is Value. * Represent the beginning of this group. The type could be Long/Double. */ + @Deprecated private JsonNode from; /** * Available when name is Value. * Represent the ending of this group. The type could be Long/Double. */ + @Deprecated private JsonNode to; public String getName() { @@ -53,10 +57,12 @@ public void setName(String name) { this.name = name; } + @Deprecated public String getType() { return type; } + @Deprecated public void setType(String type) { this.type = type; } @@ -69,66 +75,80 @@ public void setTags(Map tags) { this.tags = tags; } + @Deprecated public Integer getGroupNumber() { return groupNumber; } + @Deprecated public void setGroupNumber(Integer groupNumber) { this.groupNumber = groupNumber; } + @Deprecated public JsonNode getFrom() { return from; } @JsonIgnore + @Deprecated public long getLongFrom() { return from.asLong(); } @JsonIgnore + @Deprecated public double getDoubleFrom() { return from.asDouble(); } @JsonIgnore + @Deprecated public boolean isLongFrom() { return from.isLong(); } @JsonIgnore + @Deprecated public boolean isDoubleFrom() { return from.isDouble(); } + @Deprecated public void setFrom(JsonNode from) { this.from = from; } + @Deprecated public JsonNode getTo() { return to; } @JsonIgnore + @Deprecated public long getLongTo() { return to.asLong(); } @JsonIgnore + @Deprecated public double getDoubleTo() { return to.asDouble(); } @JsonIgnore + @Deprecated public boolean isLongTo() { return to.isLong(); } @JsonIgnore + @Deprecated public boolean isDoubleTo() { return to.isDouble(); } + @Deprecated public void setTo(JsonNode to) { this.to = to; } diff --git a/src/main/java/com/baidubce/services/tsdb/model/Query.java b/src/main/java/com/baidubce/services/tsdb/model/Query.java index 97d6963f..81e55c77 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Query.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Query.java @@ -70,6 +70,21 @@ public class Query { */ private Fill fill; + /** + * Optional. + * The marker which is used to get data started from. + * It should be the value of nextMarker of previous query request's result or null for the first query request. + */ + private String marker; + + public String getMarker() { + return marker; + } + + public void setMarker(String marker) { + this.marker = marker; + } + public Fill getFill() { return fill; } @@ -150,6 +165,11 @@ public void setOrder(String order) { this.order = order; } + public Query withMarker(String marker) { + this.marker = marker; + return this; + } + public Query withFill(Fill fill) { this.fill = fill; return this; diff --git a/src/main/java/com/baidubce/services/tsdb/model/Result.java b/src/main/java/com/baidubce/services/tsdb/model/Result.java index 8bf2817f..addaf921 100644 --- a/src/main/java/com/baidubce/services/tsdb/model/Result.java +++ b/src/main/java/com/baidubce/services/tsdb/model/Result.java @@ -19,6 +19,10 @@ public class Result { private List groups; + private Boolean truncated; + + private String nextMarker; + public String getMetric() { return metric; } @@ -66,4 +70,20 @@ public List getGroups() { public void setGroups(List groups) { this.groups = groups; } + + public boolean isTruncated() { + return truncated != null && truncated; + } + + public void setTruncated(Boolean truncated) { + this.truncated = truncated; + } + + public String getNextMarker() { + return nextMarker; + } + + public void setNextMarker(String nextMarker) { + this.nextMarker = nextMarker; + } } diff --git a/src/main/java/com/baidubce/services/vod/VodClient.java b/src/main/java/com/baidubce/services/vod/VodClient.java index ef726036..42055b8b 100644 --- a/src/main/java/com/baidubce/services/vod/VodClient.java +++ b/src/main/java/com/baidubce/services/vod/VodClient.java @@ -361,6 +361,76 @@ public CreateMediaResourceResponse createMediaResource( return response; } + /** + * Load a media resource from URL to VOD. + * + * @param sourceUrl The source url of the media resource + * @param title The title string of the media resource + * @param description The description string of the media resource + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own jobs + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public CreateMediaResourceResponse createMediaResource( + String sourceUrl, + String title, + String description, + String transcodingPresetGroupName, + int priority) { + return createMediaResource( + sourceUrl, title, description, transcodingPresetGroupName, priority, null); + } + + /** + * Load a media resource from URL to VOD. + * + * @param sourceUrl The source url of the media resource + * @param title The title string of the media resource + * @param description The description string of the media resource + * @param transcodingPresetGroupName set transcoding presetgroup name, if NULL, use default + * @param priority set transcoding priority[0,9], lowest priority is 0. Only effect your own jobs + * @param mode the mode of the media resource + * @return A PutObjectResponse object containing the information returned by Bos for the newly created object. + */ + public CreateMediaResourceResponse createMediaResource( + String sourceUrl, + String title, + String description, + String transcodingPresetGroupName, + int priority, + String mode) { + checkStringNotEmpty(sourceUrl, "sourceUrl should not be null or empty!"); + + // generate media Id + GenerateMediaIdResponse generateMediaIdresponse; + if (mode == null) { + generateMediaIdresponse = applyMedia(); + } else { + generateMediaIdresponse = applyMedia(mode); + } + String mediaId = generateMediaIdresponse.getMediaId(); + String targetBucket = generateMediaIdresponse.getSourceBucket(); + String targetKey = generateMediaIdresponse.getSourceKey(); + + // fetch to temp bucket + bosClient.fetchObject(targetBucket, targetKey, sourceUrl); + + // create mediaId + InternalCreateMediaRequest request = + new InternalCreateMediaRequest() + .withMediaId(mediaId) + .withTitle(title) + .withDescription(description) + .withTranscodingPresetGroupName(transcodingPresetGroupName) + .withPriority(priority); + InternalCreateMediaResponse internalResponse = processMedia(request); + + CreateMediaResourceResponse response = new CreateMediaResourceResponse(); + response.setMediaId(internalResponse.getMediaId()); + + return response; + } + public InternalCreateMediaResponse processMedia(InternalCreateMediaRequest request) { InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, PATH_MEDIA, request.getMediaId()); diff --git a/src/main/java/com/baidubce/services/vodpro/AdaptorClient.java b/src/main/java/com/baidubce/services/vodpro/AdaptorClient.java new file mode 100644 index 00000000..9f303f81 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/AdaptorClient.java @@ -0,0 +1,181 @@ +package com.baidubce.services.vodpro; + +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.vodpro.model.adaptor.RequestType; +import com.baidubce.services.vodpro.model.adaptor.request.QueryVcaRequest; +import com.baidubce.services.vodpro.model.adaptor.request.QueryVcrRequest; +import com.baidubce.services.vodpro.model.adaptor.request.TaskStartRequest; +import com.baidubce.services.vodpro.model.adaptor.response.QueryVcaResponse; +import com.baidubce.services.vodpro.model.adaptor.response.QueryVcrResponse; +import com.baidubce.services.vodpro.model.adaptor.response.TaskStartResponse; +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.ArrayList; +import java.util.List; + +/** + * Created on 17/10/9 + * + * @author liumin08 + */ +public class AdaptorClient extends AbstractBceClient { + + private static final String VERSION = "v1"; + + private static final String PATH_TASK = "task"; + + private static HttpResponseHandler[] vodProAdaptorHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + public AdaptorClient() { + this(new BceClientConfiguration()); + } + + public AdaptorClient(BceClientConfiguration config) { + super(config, vodProAdaptorHandlers); + } + + public TaskStartResponse startTask(RequestType type, String url, String description, String preset) { + TaskStartRequest request = new TaskStartRequest(); + request.setType(type); + request.setDescription(description); + request.setPreset(preset); + request.setUrl(url); + return startTask(request); + } + + private TaskStartResponse startTask(TaskStartRequest request) { + InternalRequest internalRequest = createRequest(HttpMethodName.POST, + request, VERSION, PATH_TASK); + internalRequest.addParameter("type", request.getType().toString()); + return this.invokeHttpClient(internalRequest, TaskStartResponse.class); + } + + public QueryVcaResponse queryAdaptorVca(String url) { + QueryVcaRequest request = new QueryVcaRequest(); + request.setUrl(url); + return queryAdaptorVca(request); + } + + private QueryVcaResponse queryAdaptorVca(QueryVcaRequest request) { + InternalRequest internalRequest = createRequest(HttpMethodName.GET, + request, VERSION, PATH_TASK); + internalRequest.addParameter("vca", null); + internalRequest.addParameter("url", request.getUrl()); + + return this.invokeHttpClient(internalRequest, QueryVcaResponse.class); + } + + public QueryVcrResponse queryAdaptorVcr(String url) { + QueryVcrRequest request = new QueryVcrRequest(); + request.setUrl(url); + return queryAdaptorVcr(request); + } + + private QueryVcrResponse queryAdaptorVcr(QueryVcrRequest request) { + InternalRequest internalRequest = createRequest(HttpMethodName.GET, + request, VERSION, PATH_TASK); + internalRequest.addParameter("vcr", null); + internalRequest.addParameter("url", request.getUrl()); + return this.invokeHttpClient(internalRequest, QueryVcrResponse.class); + } + + /** + * Creates and initializes a new request object for the specified resource. + * This method is responsible for determining HTTP method, URI path, + * credentials and request body for POST method. + *

+ * 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. + * @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( + 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 = 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; + } + + public URI appendUri(URI baseUri, String... pathComponents) { + StringBuilder builder = new StringBuilder(baseUri.toASCIIString()); + for (String path : pathComponents) { + if (path != null && path.length() > 0) { + path = HttpUtils.normalize(path).replace("%2F", "/").replace("%3F", "?"); + if (path.startsWith("/")) { + if (builder.charAt(builder.length() - 1) == '/') { + builder.setLength(builder.length() - 1); + } + } else { + if (builder.charAt(builder.length() - 1) != '/') { + builder.append('/'); + } + } + builder.append(path); + } + } + try { + return new URI(builder.toString()); + } catch (URISyntaxException e) { + throw new RuntimeException("Unexpected error", e); + } + } +} diff --git a/src/main/java/com/baidubce/services/vodpro/Constants.java b/src/main/java/com/baidubce/services/vodpro/Constants.java new file mode 100644 index 00000000..76ab1b14 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/Constants.java @@ -0,0 +1,31 @@ +package com.baidubce.services.vodpro; + +/** + * Created on 17/9/6 + * + * @author liumin08 + */ +public class Constants { + + static final String VERSION = "v1"; + + static final String PATH_PROJECT = "project"; + + static final String PATH_SPACE = "space"; + + static final String PATH_MEDIA = "media"; + + static final String TYPE_VCA = "vca"; + + static final String TYPE_VCR = "vcr"; + + public static final String STATUS_SUCCESS = "FINISHED"; + + public static final String STATUS_FAILED = "FAILED"; + + public static final String STATUS_ERROR = "ERROR"; + + public static final String STATUS_PROCESSING = "PROCESSING"; + + public static final String STATUS_PROVISIONING = "PROVISIONING"; +} diff --git a/src/main/java/com/baidubce/services/vodpro/VodproClient.java b/src/main/java/com/baidubce/services/vodpro/VodproClient.java new file mode 100644 index 00000000..a92d7630 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/VodproClient.java @@ -0,0 +1,219 @@ +package com.baidubce.services.vodpro; + +import com.baidubce.AbstractBceClient; +import com.baidubce.BceClientConfiguration; +import com.baidubce.BceClientException; +import com.baidubce.BceServiceException; +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.vodpro.model.common.Path; +import com.baidubce.services.vodpro.model.request.CreateMediaRequest; +import com.baidubce.services.vodpro.model.request.GetMediaRequest; +import com.baidubce.services.vodpro.model.response.GetVcaResultResponse; +import com.baidubce.services.vodpro.model.response.GetVcrResultResponse; +import com.baidubce.services.vodpro.model.response.MediaResponse; +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.services.vodpro.Constants.PATH_MEDIA; +import static com.baidubce.services.vodpro.Constants.PATH_PROJECT; +import static com.baidubce.services.vodpro.Constants.PATH_SPACE; +import static com.baidubce.services.vodpro.Constants.TYPE_VCA; +import static com.baidubce.services.vodpro.Constants.TYPE_VCR; +import static com.baidubce.services.vodpro.Constants.VERSION; +import static com.baidubce.util.HttpUtils.appendUri; +import static com.baidubce.util.Validate.checkStringNotEmpty; + +/** + * Created on 17/8/24 + * + * @author liumin08 + */ +public class VodproClient extends AbstractBceClient { + + private static HttpResponseHandler[] vodproHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + + public VodproClient() { + this(new BceClientConfiguration()); + } + + public VodproClient(BceClientConfiguration config) { + super(config, vodproHandlers); + } + + public MediaResponse createMedia(String projectName, String spaceName, + String path, String triggerName, + String notificationName, String description) { + CreateMediaRequest request = new CreateMediaRequest(); + request.setPath(new Path(path)); + request.setDescription(description); + request.setNotificationName(notificationName); + request.setTriggerName(triggerName); + return createMedia(request, projectName, spaceName); + } + + public MediaResponse createMedia(CreateMediaRequest request, + String projectName, String spaceName) throws BceServiceException { + + checkStringNotEmpty(projectName, + "The parameter projectName should not be null or empty string."); + checkStringNotEmpty(spaceName, + "The parameter spaceName should not be null or empty string."); + checkStringNotEmpty(request.getPath().getMe(), + "The parameter path should not be null or empty string."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, VERSION, PATH_PROJECT, + projectName, PATH_SPACE, spaceName, PATH_MEDIA); + + String json = JsonUtils.toJsonString(request); + byte[] requestJson = null; + try { + requestJson = json.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, MediaResponse.class); + } + + public MediaResponse getMedia(String projectName, String spaceName, String path) { + GetMediaRequest request = new GetMediaRequest(); + request.setProjectName(projectName); + request.setSpaceName(spaceName); + request.setPath(new Path(path)); + return getMedia(request); + + } + + private MediaResponse getMedia(GetMediaRequest request) { + + InternalRequest internalRequest = + createRequest(HttpMethodName.GET, request, VERSION, PATH_PROJECT, request.getProjectName(), + PATH_SPACE, request.getSpaceName(), PATH_MEDIA, request.getPath().getMe()); + return this.invokeHttpClient(internalRequest, MediaResponse.class); + } + + public GetVcaResultResponse getVcaResult( + String projectName, String spaceName, String path, String type) { + if (TYPE_VCA.equals(type)) { + GetMediaRequest request = new GetMediaRequest(); + request.setProjectName(projectName); + request.setSpaceName(spaceName); + request.setPath(new Path(path)); + request.setType(TYPE_VCA); + return getVcaResult(request); + } else { + throw new BceClientException("The type is wrong, maybe you should set type to vca"); + } + } + + private GetVcaResultResponse getVcaResult(GetMediaRequest request) { + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, VERSION, + PATH_PROJECT, request.getProjectName(), PATH_SPACE, request.getSpaceName(), PATH_MEDIA, + request.getPath().getMe()); + internalRequest.addParameter(TYPE_VCA, null); + + return this.invokeHttpClient(internalRequest, GetVcaResultResponse.class); + } + + public GetVcrResultResponse getVcrResult(String projectName, + String spaceName, + String path, + String type) { + if (TYPE_VCR.equals(type)) { + GetMediaRequest request = new GetMediaRequest(); + request.setProjectName(projectName); + request.setSpaceName(spaceName); + request.setPath(new Path(path)); + request.setType(TYPE_VCR); + return getVcrResult(request); + } else { + throw new BceClientException("The type is wrong, maybe you should set type to vcr"); + } + } + + private GetVcrResultResponse getVcrResult(GetMediaRequest request) { + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, + VERSION, + PATH_PROJECT, request.getProjectName(), PATH_SPACE, request.getSpaceName(), PATH_MEDIA, + request.getPath().getMe()); + internalRequest.addParameter(TYPE_VCR, null); + return this.invokeHttpClient(internalRequest, GetVcrResultResponse.class); + } + + /** + * Creates and initializes a new request object for the specified resource. + * This method is responsible for determining HTTP method, URI path, + * credentials and request body for POST method. + *

+ * 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. + * @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( + 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 = 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/vodpro/model/adaptor/RequestType.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/RequestType.java new file mode 100644 index 00000000..f201dc95 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/RequestType.java @@ -0,0 +1,10 @@ +package com.baidubce.services.vodpro.model.adaptor; + +/** + * Created on 17/10/10 + * + * @author liumin08 + */ +public enum RequestType { + vca, vcr +} diff --git a/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcaRequest.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcaRequest.java new file mode 100644 index 00000000..e3a16da9 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcaRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.vodpro.model.adaptor.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created on 17/10/10 + * + * @author liumin08 + */ +public class QueryVcaRequest extends AbstractBceRequest { + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public QueryVcaRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcrRequest.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcrRequest.java new file mode 100644 index 00000000..69835dcd --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/QueryVcrRequest.java @@ -0,0 +1,28 @@ +package com.baidubce.services.vodpro.model.adaptor.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created on 17/10/10 + * + * @author liumin08 + */ +public class QueryVcrRequest extends AbstractBceRequest { + + private String url; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + @Override + public QueryVcrRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/TaskStartRequest.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/TaskStartRequest.java new file mode 100644 index 00000000..e4713e34 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/request/TaskStartRequest.java @@ -0,0 +1,55 @@ +package com.baidubce.services.vodpro.model.adaptor.request; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; +import com.baidubce.services.vodpro.model.adaptor.RequestType; + +/** + * Created on 17/10/10 + * + * @author liumin08 + */ +public class TaskStartRequest extends AbstractBceRequest { + private String url; + private String description; + private String preset; + private RequestType type; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPreset() { + return preset; + } + + public void setPreset(String preset) { + this.preset = preset; + } + + public RequestType getType() { + return type; + } + + public void setType(RequestType type) { + this.type = type; + } + + @Override + public TaskStartRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } +} diff --git a/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Constants.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Constants.java new file mode 100644 index 00000000..73625730 --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Constants.java @@ -0,0 +1,48 @@ +package com.baidubce.services.vodpro.model.adaptor.response; + +/** + * Created on 17/10/19 + * + * @author liumin08 + */ +public class Constants { + public static final String RESULTLABEL_REJECT = "REJECT"; + + public static final Integer RESULTLABEL_REJECT_CODE = 2; + + public static final String RESULTLABEL_REVIEW = "REVIEW"; + + public static final Integer RESULTLABEL_REVIEW_CODE = 1; + + public static final String RESULTLABEL_NORMAL = "NORMAL"; + + public static final Integer RESULTLABEL_NORMAL_CODE = 0; + + public static final Integer RESULTLABEL_INVALID_CODE = -1; + + public static final String TYPE_PICTURE = "PICTURE"; + + public static final String TYPE_VIDEO = "VIDEO"; + + public static final String VIDEOSTATUS_SUCCESS = "SUCCESS"; + + public static final String VIDEOSTATUS_DUPLICATED_REQUEST = "DUPLICATED_REQUEST"; + + public static final String VIDEOSTATUS_INVALID_ARGUMENT = "INVALID_ARGUMENT"; + + public static final String VIDEOSTATUS_PARSE_ERROR = "PARSE_ERROR"; + + public static final String VIDEOSTATUS_TYPE_ERROR = "TYPE_ERROR"; + + public static final Integer VIDEOSTATUS_SUCCESS_CODE = 0; + + public static final Integer VIDEOSTATUS_DUPLICATED_REQUEST_CODE = 110; + + public static final Integer VIDEOSTATUS_INVALID_ARGUMENT_CODE = 120; + + public static final Integer VIDEOSTATUS_PARSE_ERROR_CODE = 130; + + public static final Integer VIDEOSTATUS_TYPE_ERROR_CODE = 140; + + public static final Integer VIDEOSTATUS_UNKOWN_STATUS_CODE = -1; +} diff --git a/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Evidence.java b/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Evidence.java new file mode 100644 index 00000000..c3d24c9f --- /dev/null +++ b/src/main/java/com/baidubce/services/vodpro/model/adaptor/response/Evidence.java @@ -0,0 +1,67 @@ +package com.baidubce.services.vodpro.model.adaptor.response; + +import java.util.List; + +/** + * Created on 17/10/18 + * + * @author liumin08 + */ +public class Evidence { + private Integer beginTime; + private Integer endTime; + private String type; + private String url; + private List