From 5cd266cbbcecc6234e86ed2f55f8c980f9cd90f9 Mon Sep 17 00:00:00 2001 From: xuchuan Date: Fri, 15 Jul 2016 20:55:36 +0800 Subject: [PATCH] 0.10.6 --- pom.xml | 2 +- src/main/java/com/baidubce/BceConstants.java | 2 +- .../com/baidubce/services/doc/DocClient.java | 710 ++++++++++++++++++ .../model/CreateDocumentFromBosRequest.java | 51 ++ .../model/CreateDocumentFromBosResponse.java | 16 + .../doc/model/CreateDocumentRequest.java | 46 ++ .../doc/model/CreateDocumentResponse.java | 16 + .../doc/model/CreateNotificationRequest.java | 72 ++ .../doc/model/CreateNotificationResponse.java | 26 + .../doc/model/DeleteDocumentRequest.java | 24 + .../doc/model/DeleteDocumentResponse.java | 10 + .../doc/model/DeleteNotificationRequest.java | 51 ++ .../doc/model/DeleteNotificationResponse.java | 26 + .../baidubce/services/doc/model/Document.java | 89 +++ .../services/doc/model/DocumentError.java | 35 + .../services/doc/model/DocumentMeta.java | 35 + .../doc/model/DocumentPublishInfo.java | 57 ++ .../doc/model/DocumentUploadInfo.java | 45 ++ .../doc/model/GetDocumentDownloadRequest.java | 23 + .../model/GetDocumentDownloadResponse.java | 39 + .../doc/model/GetDocumentRequest.java | 23 + .../doc/model/GetDocumentResponse.java | 116 +++ .../doc/model/GetNotificationRequest.java | 51 ++ .../doc/model/GetNotificationResponse.java | 54 ++ .../doc/model/ListDocumentsRequest.java | 15 + .../doc/model/ListDocumentsResponse.java | 27 + .../doc/model/ListNotificationsRequest.java | 33 + .../doc/model/ListNotificationsResponse.java | 39 + .../services/doc/model/Notification.java | 62 ++ .../doc/model/PublishDocumentRequest.java | 24 + .../doc/model/PublishDocumentResponse.java | 10 + .../doc/model/ReadDocumentRequest.java | 23 + .../doc/model/ReadDocumentResponse.java | 59 ++ .../doc/model/RegisterDocumentRequest.java | 37 + .../doc/model/RegisterDocumentResponse.java | 59 ++ .../com/baidubce/services/lss/LssClient.java | 335 ++++++++- .../lss/model/CreateSessionRequest.java | 18 + .../lss/model/CreateSessionResponse.java | 13 + .../services/lss/model/GetAppRequest.java | 38 + .../services/lss/model/GetAppResponse.java | 128 ++++ .../lss/model/GetAppStreamRequest.java | 53 ++ .../lss/model/GetAppStreamResponse.java | 172 +++++ .../lss/model/GetSessionResponse.java | 13 + .../services/lss/model/ListAppRequest.java | 23 + .../services/lss/model/ListAppResponse.java | 29 + .../lss/model/ListAppStreamsRequest.java | 53 ++ .../lss/model/ListAppStreamsResponse.java | 29 + .../baidubce/services/lss/model/LivePlay.java | 64 ++ .../services/lss/model/LiveSession.java | 13 + .../lss/model/PauseAppStreamRequest.java | 53 ++ .../lss/model/PauseAppStreamResponse.java | 16 + .../services/lss/model/PlayPrefix.java | 47 ++ .../services/lss/model/PublishPrefix.java | 25 + .../lss/model/RefreshSessionResponse.java | 13 + .../lss/model/ResumeAppStreamRequest.java | 53 ++ .../lss/model/ResumeAppStreamResponse.java | 16 + 56 files changed, 3187 insertions(+), 24 deletions(-) create mode 100755 src/main/java/com/baidubce/services/doc/DocClient.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/Document.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DocumentError.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DocumentMeta.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java create mode 100755 src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/Notification.java create mode 100755 src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java create mode 100755 src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/GetAppRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/GetAppResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ListAppRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ListAppResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java create mode 100755 src/main/java/com/baidubce/services/lss/model/PlayPrefix.java create mode 100755 src/main/java/com/baidubce/services/lss/model/PublishPrefix.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java create mode 100755 src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java diff --git a/pom.xml b/pom.xml index bdde2853..a90e08d8 100755 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.baidubce bce-java-sdk - 0.10.5 + 0.10.6 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 4c8c2241..3dc3ab10 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.5"; + public static final String VERSION = "0.10.6"; } diff --git a/src/main/java/com/baidubce/services/doc/DocClient.java b/src/main/java/com/baidubce/services/doc/DocClient.java new file mode 100755 index 00000000..55206f60 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/DocClient.java @@ -0,0 +1,710 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +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.bos.BosClient; +import com.baidubce.services.bos.BosClientConfiguration; +import com.baidubce.services.bos.model.PutObjectResponse; +import com.baidubce.services.doc.model.GetDocumentResponse; +import com.baidubce.services.doc.model.GetDocumentRequest; +import com.baidubce.services.doc.model.GetDocumentDownloadResponse; +import com.baidubce.services.doc.model.GetDocumentDownloadRequest; +import com.baidubce.services.doc.model.CreateDocumentRequest; +import com.baidubce.services.doc.model.CreateDocumentResponse; +import com.baidubce.services.doc.model.CreateDocumentFromBosRequest; +import com.baidubce.services.doc.model.CreateDocumentFromBosResponse; +import com.baidubce.services.doc.model.CreateNotificationRequest; +import com.baidubce.services.doc.model.ListDocumentsResponse; +import com.baidubce.services.doc.model.ListNotificationsResponse; +import com.baidubce.services.doc.model.ListNotificationsRequest; +import com.baidubce.services.doc.model.CreateNotificationResponse; +import com.baidubce.services.doc.model.DeleteDocumentRequest; +import com.baidubce.services.doc.model.DeleteDocumentResponse; +import com.baidubce.services.doc.model.DeleteNotificationRequest; +import com.baidubce.services.doc.model.DeleteNotificationResponse; +import com.baidubce.services.doc.model.ListDocumentsRequest; +import com.baidubce.services.doc.model.ReadDocumentRequest; +import com.baidubce.services.doc.model.ReadDocumentResponse; +import com.baidubce.services.doc.model.GetNotificationRequest; +import com.baidubce.services.doc.model.GetNotificationResponse; +import com.baidubce.services.doc.model.RegisterDocumentResponse; +import com.baidubce.services.doc.model.RegisterDocumentRequest; +import com.baidubce.services.doc.model.PublishDocumentResponse; +import com.baidubce.services.doc.model.PublishDocumentRequest; + +import com.baidubce.util.HttpUtils; +import com.baidubce.util.JsonUtils; +import java.io.File; + +import java.io.UnsupportedEncodingException; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; + + +/** + * Client for accessing Document Transcoder Services. All service calls made + * using this client are blocking, and will not return until the service call + * completes. + * Created by xuchuan on 2015/4/20. + */ +public class DocClient extends AbstractBceClient { + + /** + * The version information for Document service APIs as URI prefix. + */ + private static final String VERSION = "v2"; + + + /** + * The common URI prefix for doc services. + */ + private static final String DOC = "document"; + + /** + * The common URI prefix for notification services. + */ + private static final String NOTIFICATION = "notification"; + + @Override + public boolean isRegionSupported() { + return false; + } + + + + /** + * Responsible for handling httpResponses from all service calls. + */ + private static final HttpResponseHandler[] docHandlers = new HttpResponseHandler[] { + new BceMetadataResponseHandler(), + new BceErrorResponseHandler(), + new BceJsonResponseHandler() + }; + + /** + * Constructs a new Document client to invoke service methods on Document Transcoder. + */ + public DocClient() { + this(new BceClientConfiguration()); + } + + /** + * Constructs a new client using the client configuration to access Document Transcoder services. + * + * @param clientConfiguration The client configuration options controlling how this client + * connects to Document services (e.g. proxy settings, retry counts, etc). + */ + public DocClient(BceClientConfiguration clientConfiguration) { + super(clientConfiguration, docHandlers); + } + + /** + * Create a Document. + * + * @param file The document . + * @param title The document title. + * @param format The document format. + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentResponse createDocument(File file, String title, String format) { + CreateDocumentRequest request = new CreateDocumentRequest(); + request.setFile(file); + request.setTitle(title); + request.setFormat(format); + return this.createDocument(request); + } + + /** + * Create a Document. + * + * @param file The document . + * @param title The document title. + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentResponse createDocument(File file, String title) { + CreateDocumentRequest request = new CreateDocumentRequest(); + String format; + String filename = file.getName(); + if (filename.lastIndexOf(".") == -1) { + throw new BceClientException("Cannot get file format from file name:" + filename); + } + format = filename.substring(filename.lastIndexOf(".") + 1); + request.setFile(file); + request.setTitle(title); + request.setFormat(format); + return this.createDocument(request); + } + + /** + * Create a Document. + * + * @param file The document . + * @param title The document title. + * @param format The document format. + * @param notification The document notification name. + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentResponse createDocument(File file, String title, String format, String notification) { + CreateDocumentRequest request = new CreateDocumentRequest(); + request.setFile(file); + request.setTitle(title); + request.setFormat(format); + request.setNotification(notification); + return this.createDocument(request); + } + + /** + * Create a Document. + * + * @param request The request object containing all the parameters to upload a new doc. + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentResponse createDocument(CreateDocumentRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getFile(), "file should not be null."); + checkNotNull(request.getTitle(), "title should not be null."); + checkNotNull(request.getFormat(), "format should not be null."); + // register document + RegisterDocumentRequest regRequest = new RegisterDocumentRequest(); + regRequest.setFormat(request.getFormat()); + regRequest.setTitle(request.getTitle()); + regRequest.setNotification(request.getNotification()); + + RegisterDocumentResponse regResponse = registerDocument(regRequest); + + // call bos upload doc + bosUploadDocument(regResponse.getBucket(), regResponse.getObject(), + request.getFile(), regResponse.getBosEndpoint()); + + // publish document + PublishDocumentRequest pubRequest = new PublishDocumentRequest(); + pubRequest.setDocumentId(regResponse.getDocumentId()); + publishDocument(pubRequest); + + CreateDocumentResponse response = new CreateDocumentResponse(); + response.setDocumentId(regResponse.getDocumentId()); + + return response; + } + + /** + * Create a Document. + * + * @param bucket The document bucket. + * @param object The document object. + * @param title The document title. + * @param format The document format. + * @param notification The document notification name. + * + * @return A CreateDocumentFromBosResponse object containing the information returned by Document. + */ + public CreateDocumentFromBosResponse createDocumentFromBos(String bucket, String object, + String title, String format, String notification) { + CreateDocumentFromBosRequest request = new CreateDocumentFromBosRequest(); + request.setBucket(bucket); + request.setObject(object); + request.setTitle(title); + request.setFormat(format); + request.setNotification(notification); + return this.createDocumentFromBos(request); + } + + /** + * Create a Document. + * + * @param bucket The document bucket. + * @param object The document object. + * @param title The document title. + * @param format The document format. + * + * @return A CreateDocumentFromBosResponse object containing the information returned by Document. + */ + public CreateDocumentFromBosResponse createDocumentFromBos(String bucket, String object, + String title, String format) { + CreateDocumentFromBosRequest request = new CreateDocumentFromBosRequest(); + request.setBucket(bucket); + request.setObject(object); + request.setTitle(title); + request.setFormat(format); + return this.createDocumentFromBos(request); + } + + /** + * Create a Document. + * + * @param request The request object containing all the parameters to upload a new doc. + * + * @return A CreateDocumentResponse object containing the information returned by Document. + */ + public CreateDocumentFromBosResponse createDocumentFromBos(CreateDocumentFromBosRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getBucket(), "bucket should not be null."); + checkNotNull(request.getObject(), "object should not be null."); + checkNotNull(request.getTitle(), "title should not be null."); + checkNotNull(request.getFormat(), "format should not be null."); + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, DOC); + internalRequest.addParameter("source", "bos"); + 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 invokeHttpClient(internalRequest, CreateDocumentFromBosResponse.class); + } + + /** + * publish a Document. + * + * @param request The request object containing register infomation. + * + * @return A RegisterDocumentResponse object containing the information returned by Document. + */ + private RegisterDocumentResponse registerDocument(RegisterDocumentRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, DOC); + internalRequest.addParameter("register", null); + 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 invokeHttpClient(internalRequest, RegisterDocumentResponse.class); + } + + /** + * publish a Document. + * + * @param bucketName The bucket name response from register. + * @param objectName The object name response from register. + * @param file The Document file need to be uploaded. + * @param endpoint The bos endpoint response from register. + * + * @return A PublishDocumentResponse object containing the information returned by Document. + */ + private void bosUploadDocument(String bucketName, String objectName, File file, String endpoint) { + BosClientConfiguration config = new BosClientConfiguration(this.config); + config.setEndpoint(endpoint); + BosClient bosClient = new BosClient(config); + + PutObjectResponse response = bosClient.putObject(bucketName, objectName, file); + } + + /** + * publish a Document. + * + * @param request The request object containing a documentId. + * + * @return A PublishDocumentResponse object containing the information returned by Document. + */ + private PublishDocumentResponse publishDocument(PublishDocumentRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getDocumentId(), "documentId should not be null."); + InternalRequest internalRequest = this.createRequest(HttpMethodName.PUT, request, DOC, request.getDocumentId()); + internalRequest.addParameter("publish", null); + // need to set content-length, otherwise auth will failed + // cause HTTP will set Content-Length auto when send http request + internalRequest.addHeader(Headers.CONTENT_LENGTH, "0"); + PublishDocumentResponse response; + try { + response = this.invokeHttpClient(internalRequest, PublishDocumentResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** + * get a Document. + * + * @param documentId The document id. + * + * @return A GetDocumentResponse object containing the information returned by Document. + */ + public GetDocumentResponse getDocument(String documentId) { + GetDocumentRequest request = new GetDocumentRequest(); + request.setDocumentId(documentId); + return this.getDocument(request); + } + + /** + * get a Document. + * + * @param request The request object containing a docId. + * + * @return A GetDocumentResponse object containing the information returned by Document. + */ + public GetDocumentResponse getDocument(GetDocumentRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getDocumentId(), "documentId should not be null."); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC, request.getDocumentId()); + GetDocumentResponse response; + try { + response = this.invokeHttpClient(internalRequest, GetDocumentResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + + /** + * list all Document. + * + * + * @return A ListDocumentsResponse object containing the information returned by Document. + */ + public ListDocumentsResponse listDocuments() { + ListDocumentsRequest request = new ListDocumentsRequest(); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC); + ListDocumentsResponse response; + try { + response = this.invokeHttpClient(internalRequest, ListDocumentsResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** + * list all Document by status. + * + * + * @return A ListDocumentsResponse object containing the information returned by Document. + */ + public ListDocumentsResponse listDocuments(String status) { + ListDocumentsRequest request = new ListDocumentsRequest(); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC); + internalRequest.addParameter("status", status); + ListDocumentsResponse response; + try { + response = this.invokeHttpClient(internalRequest, ListDocumentsResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** + * delete a Document. + * + * @param documentId The document id. + * + * @return A DeleteDocumentResponse object containing the information returned by Document. + */ + public DeleteDocumentResponse deleteDocument(String documentId) { + DeleteDocumentRequest request = new DeleteDocumentRequest(); + request.setDocumentId(documentId); + return this.deleteDocument(request); + } + + /** + * delete a Document. + * + * @param request The request object containing a docId. + * + * @return A DeleteDocumentResponse object containing the information returned by Document. + */ + public DeleteDocumentResponse deleteDocument(DeleteDocumentRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getDocumentId(), "documentId should not be null."); + InternalRequest internalRequest = this.createRequest( + HttpMethodName.DELETE, request, DOC, request.getDocumentId()); + DeleteDocumentResponse response; + try { + response = this.invokeHttpClient(internalRequest, DeleteDocumentResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** + * get a Document Download link. + * + * @param documentId the documentId need to download. + * + * @return A GetDocumentDownloadResponse object containing the information returned by Document. + */ + public GetDocumentDownloadResponse getDocumentDownload(String documentId) { + checkNotNull(documentId, "documentId should not be null."); + GetDocumentDownloadRequest request = new GetDocumentDownloadRequest(); + request.setDocumentId(documentId); + InternalRequest internalRequest = this.createRequest(HttpMethodName.GET, request, DOC, request.getDocumentId()); + internalRequest.addParameter("download", null); + GetDocumentDownloadResponse response; + try { + response = this.invokeHttpClient(internalRequest, GetDocumentDownloadResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + + /** + * read a Document, get document reader infomation. + * + * @param documentId The document id. + * + * @return A ReadDocumentResponse object containing the information returned by Document. + */ + public ReadDocumentResponse readDocument(String documentId) { + ReadDocumentRequest request = new ReadDocumentRequest(); + request.setDocumentId(documentId); + return this.readDocument(request); + } + + /** + * read a Document, get document reader infomation. + * + * @param request The request object containing a documentId. + * + * @return A ReadDocumentResponse object containing the information returned by Document. + */ + public ReadDocumentResponse readDocument(ReadDocumentRequest request) { + checkNotNull(request, "request should not be null."); + checkNotNull(request.getDocumentId(), "documentId should not be null."); + InternalRequest internalRequest = this.createRequest( + HttpMethodName.GET, request, DOC, request.getDocumentId()); + internalRequest.addParameter("read", null); + ReadDocumentResponse response; + try { + response = this.invokeHttpClient(internalRequest, ReadDocumentResponse.class); + } finally { + try { + internalRequest.getContent().close(); + } catch (Exception e) { + // ignore exception + } + } + + return response; + } + + /** + * List all your doc notifications. + * + * @return The list of all your doc notifications + */ + public ListNotificationsResponse listNotifications() { + ListNotificationsRequest request = new ListNotificationsRequest(); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, NOTIFICATION); + return invokeHttpClient(internalRequest, ListNotificationsResponse.class); + } + + /** + * Delete your doc notification by doc notification name. + * + * @param name doc notification name. + * + */ + public DeleteNotificationResponse deleteNotification(String name) { + DeleteNotificationRequest request = new DeleteNotificationRequest(); + request.setName(name); + return deleteNotification(request); + } + + /** + * Delete your doc notification by doc notification name. + * + * @param request The request object containing all parameters for deleting dco notification. + * + */ + public DeleteNotificationResponse deleteNotification(DeleteNotificationRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getName(), "The parameter name should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.DELETE, request, NOTIFICATION, request + .getName()); + return invokeHttpClient(internalRequest, DeleteNotificationResponse.class); + } + + /** + * Get your doc notification by doc notification name. + * + * @param name doc notification name. + * + * @return Your doc notification. + */ + public GetNotificationResponse getNotification(String name) { + GetNotificationRequest request = new GetNotificationRequest(); + request.setName(name); + return getNotification(request); + } + + /** + * Get your doc notification by doc notification name. + * + * @param request The request object containing all parameters for getting doc notification. + * + * @return Your doc notification. + */ + public GetNotificationResponse getNotification(GetNotificationRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getName(), "The parameter name should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, NOTIFICATION, + request.getName()); + return invokeHttpClient(internalRequest, GetNotificationResponse.class); + } + + /** + * Create a doc notification in the doc stream service. + * + * @param name The name of notification. + * @param endpoint The address to receive notification message. + * + */ + public CreateNotificationResponse createNotification(String name, String endpoint) { + CreateNotificationRequest request = new CreateNotificationRequest(); + request.withName(name).withEndpoint(endpoint); + return createNotification(request); + } + + /** + * Create a doc notification in the doc stream service. + * + * @param request The request object containing all options for creating doc notification. + */ + public CreateNotificationResponse createNotification(CreateNotificationRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + + checkStringNotEmpty(request.getName(), + "The parameter name should NOT be null or empty string."); + checkStringNotEmpty(request.getEndpoint(), + "The parameter endpoint should NOT be null or empty string."); + + InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, NOTIFICATION); + 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 invokeHttpClient(internalRequest, CreateNotificationResponse.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(); + pathComponents.add(VERSION); + + // 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()); + + return internalRequest; + } + + + + +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java new file mode 100755 index 00000000..a584a0da --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosRequest.java @@ -0,0 +1,51 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class CreateDocumentFromBosRequest extends AbstractBceRequest { + private String bucket = null; + private String object = null; + private String title = null; + private String format = null; + private String notification = null; + + public CreateDocumentFromBosRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getBucket() { return this.bucket; } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getObject() { return this.object; } + + public void setObject(String object) { + this.object = object; + } + + public String getFormat() { return this.format; } + + public void setFormat(String format) { + this.format = format; + } + + public String getNotification() { return this.notification; } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getTitle() { return this.title; } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java new file mode 100755 index 00000000..699afb5b --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentFromBosResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class CreateDocumentFromBosResponse extends AbstractBceResponse { + private String documentId; + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getDocumentId() { return this.documentId; } +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java new file mode 100755 index 00000000..45960783 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentRequest.java @@ -0,0 +1,46 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +import java.io.File; + +/** + * Created by baidu on 15/12/30. + */ +public class CreateDocumentRequest extends AbstractBceRequest { + private File file = null; + private String title = null; + private String format = null; + private String notification = null; + + public CreateDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public File getFile() { return this.file; } + + public void setFile(File file) { + this.file = file; + } + + public String getFormat() { return this.format; } + + public void setFormat(String format) { + this.format = format; + } + + public String getNotification() { return this.notification; } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getTitle() { return this.title; } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java new file mode 100755 index 00000000..6c6a9b52 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateDocumentResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class CreateDocumentResponse extends AbstractBceResponse { + private String documentId; + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getDocumentId() { return this.documentId; } +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java new file mode 100755 index 00000000..da084902 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateNotificationRequest.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class CreateNotificationRequest extends AbstractBceRequest { + + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public CreateNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public CreateNotificationRequest withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + + public CreateNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java new file mode 100755 index 00000000..a259b3ac --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/CreateNotificationResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class CreateNotificationResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class CreateNotificationResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java new file mode 100755 index 00000000..3de33f6c --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class DeleteDocumentRequest extends AbstractBceRequest { + + private String documentId = null; + + public DeleteDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDocumentId() { return this.documentId; } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java new file mode 100755 index 00000000..6342d9e6 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DeleteDocumentResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class DeleteDocumentResponse extends AbstractBceResponse { + +} diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java new file mode 100755 index 00000000..0632e886 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class DeleteNotificationRequest extends AbstractBceRequest { + /** + * 通知名称 + **/ + private String name = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public DeleteNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public DeleteNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DeleteNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java new file mode 100755 index 00000000..50933447 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DeleteNotificationResponse.java @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class DeleteNotificationResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class DeleteNotificationResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/Document.java b/src/main/java/com/baidubce/services/doc/model/Document.java new file mode 100755 index 00000000..bd3d8b84 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/Document.java @@ -0,0 +1,89 @@ +package com.baidubce.services.doc.model; + +import java.util.Date; + +/** + * Created by baidu on 16/1/4. + */ +public class Document { + private String documentId = null; + private String status = null; + private String title = null; + private String format = null; + private String notification = null; + private DocumentError error = null; + private Date createTime = null; + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public DocumentError getError() { + return error; + } + + public void setError(DocumentError error) { + this.error = error; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Docuement {\n"); + sb.append(" documentId: ").append(documentId).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" title: ").append(title).append("\n"); + sb.append(" format: ").append(format).append("\n"); + sb.append(" notification: ").append(notification).append("\n"); + sb.append(" createTime: ").append(createTime).append("\n"); + if (error != null) { + sb.append(" error: ").append(error.toString()).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentError.java b/src/main/java/com/baidubce/services/doc/model/DocumentError.java new file mode 100755 index 00000000..db84e280 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DocumentError.java @@ -0,0 +1,35 @@ +package com.baidubce.services.doc.model; + +/** + * Created by baidu on 16/1/7. + */ +public class DocumentError { + private String code = null; + private String message = null; + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentError {\n"); + sb.append(" code: ").append(code).append("\n"); + sb.append(" message: ").append(message).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentMeta.java b/src/main/java/com/baidubce/services/doc/model/DocumentMeta.java new file mode 100755 index 00000000..387615b5 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DocumentMeta.java @@ -0,0 +1,35 @@ +package com.baidubce.services.doc.model; + +/** + * Created by baidu on 16/1/7. + */ +public class DocumentMeta { + private String md5 = null; + private long sizeInBytes = -1; + + public String getMd5() { + return md5; + } + + public void setMd5(String md5) { + this.md5 = md5; + } + + public long getSizeInBytes() { + return sizeInBytes; + } + + public void setSizeInBytes(long sizeInBytes) { + this.sizeInBytes = sizeInBytes; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentMeta {\n"); + sb.append(" md5: ").append(md5).append("\n"); + sb.append(" sizeInBytes: ").append(sizeInBytes).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java b/src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java new file mode 100755 index 00000000..07f3c96b --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DocumentPublishInfo.java @@ -0,0 +1,57 @@ +package com.baidubce.services.doc.model; + +import java.util.Date; + +/** + * Created by baidu on 16/1/7. + */ +public class DocumentPublishInfo { + private int pageCount = 0; + private int sizeInBytes = 0; + private Date publishTime = null; + private String coverUrl = null; + + public int getPageCount() { + return pageCount; + } + + public void setPageCount(int pageCount) { + this.pageCount = pageCount; + } + + public int getSizeInBytes() { + return sizeInBytes; + } + + public void setSizeInBytes(int sizeInBytes) { + this.sizeInBytes = sizeInBytes; + } + + public Date getPublishTime() { + return publishTime; + } + + public void setPublishTime(Date publishTime) { + this.publishTime = publishTime; + } + + public String getCoverUrl() { + return coverUrl; + } + + public void setCoverUrl(String coverUrl) { + this.coverUrl = coverUrl; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentPublishInfo {\n"); + sb.append(" pageCount: ").append(pageCount).append("\n"); + sb.append(" sizeInBytes: ").append(sizeInBytes).append("\n"); + sb.append(" publishTime: ").append(publishTime).append("\n"); + sb.append(" coverUrl: ").append(coverUrl).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java b/src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java new file mode 100755 index 00000000..1d012b79 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/DocumentUploadInfo.java @@ -0,0 +1,45 @@ +package com.baidubce.services.doc.model; + +/** + * Created by baidu on 16/1/7. + */ +public class DocumentUploadInfo { + private String bucket = null; + private String object = null; + private String bosEndpoint = null; + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } + + public String getBosEndpoint() { + return bosEndpoint; + } + + public void setBosEndpoint(String bosEndpoint) { + this.bosEndpoint = bosEndpoint; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocumentUploadInfo {\n"); + sb.append(" bucket: ").append(bucket).append("\n"); + sb.append(" object: ").append(object).append("\n"); + sb.append(" bosEndpoint: ").append(bosEndpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java new file mode 100755 index 00000000..71b4d1d5 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class GetDocumentDownloadRequest extends AbstractBceRequest { + private String documentId = null; + + public GetDocumentDownloadRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDocumentId() { return this.documentId; } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java new file mode 100755 index 00000000..df43ddf5 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentDownloadResponse.java @@ -0,0 +1,39 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class GetDocumentDownloadResponse extends AbstractBceResponse { + private String documentId = null; + private String downloadUrl = null; + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getDownloadUrl() { + return downloadUrl; + } + + public void setDownloadUrl(String downloadUrl) { + this.downloadUrl = downloadUrl; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class DocuementDownload {\n"); + + sb.append(" documentId: ").append(documentId).append("\n"); + sb.append(" downloadUrl: ").append(downloadUrl).append("\n"); + + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java new file mode 100755 index 00000000..a04ce902 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class GetDocumentRequest extends AbstractBceRequest { + private String documentId = null; + + public GetDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDocumentId() { return this.documentId; } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java new file mode 100755 index 00000000..8698e4cf --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetDocumentResponse.java @@ -0,0 +1,116 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Date; + +/** + * Created by baidu on 15/12/31. + */ +public class GetDocumentResponse extends AbstractBceResponse { + private String documentId = null; + private String status = null; + private String title = null; + private String format = null; + private String notification = null; + private Date createTime = null; + private DocumentUploadInfo uploadInfo = null; + private DocumentPublishInfo publishInfo = null; + private DocumentError error = null; + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getFormat() { + return format; + } + + public void setFormat(String format) { + this.format = format; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public DocumentUploadInfo getUploadInfo() { + return uploadInfo; + } + + public void setUploadInfo(DocumentUploadInfo uploadInfo) { + this.uploadInfo = uploadInfo; + } + + public DocumentPublishInfo getPublishInfo() { + return publishInfo; + } + + public void setPublishInfo(DocumentPublishInfo publishInfo) { + this.publishInfo = publishInfo; + } + + public DocumentError getError() { + return error; + } + + public void setError(DocumentError error) { + this.error = error; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Docuement {\n"); + + sb.append(" documentId: ").append(documentId).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" title: ").append(title).append("\n"); + sb.append(" format: ").append(format).append("\n"); + sb.append(" notification: ").append(notification).append("\n"); + sb.append(" createTime: ").append(createTime).append("\n"); + if (this.status.equals("PUBLISHED")) { + sb.append(" publishInfo:").append(publishInfo.toString()).append("\n"); + } + if (this.status.equals("UPLOADING")) { + sb.append(" uploadInfo:").append(uploadInfo.toString()).append("\n"); + } + if (error != null) { + sb.append(" error: ").append(error.toString()).append("\n"); + } + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java b/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java new file mode 100755 index 00000000..e6fd11a7 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetNotificationRequest.java @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class GetNotificationRequest extends AbstractBceRequest { + /** + * 通知名称 + **/ + private String name = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public GetNotificationRequest withName(String name) { + this.name = name; + return this; + } + + public GetNotificationRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetNotificationRequest {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java b/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java new file mode 100755 index 00000000..6707ba6f --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/GetNotificationResponse.java @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class GetNotificationResponse extends AbstractBceResponse { + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + 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; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetNotificationResponse {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java b/src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java new file mode 100755 index 00000000..74f4ba4f --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ListDocumentsRequest.java @@ -0,0 +1,15 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class ListDocumentsRequest extends AbstractBceRequest { + public ListDocumentsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java b/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java new file mode 100755 index 00000000..f57d59ff --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ListDocumentsResponse.java @@ -0,0 +1,27 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by baidu on 15/12/31. + */ +public class ListDocumentsResponse extends AbstractBceResponse { + private List documents = new ArrayList(); + + public void setDocuments(List documents) { + this.documents = documents; + } + + public List getDocuments() { return this.documents; } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListDocumentsResponse {\n"); + sb.append(" documents: ").append(documents).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java b/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java new file mode 100755 index 00000000..3db5154a --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ListNotificationsRequest.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class ListNotificationsRequest extends AbstractBceRequest { + + public ListNotificationsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListNotificationsRequest {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java b/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java new file mode 100755 index 00000000..89861824 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ListNotificationsResponse.java @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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 java.util.List; + +import com.baidubce.model.AbstractBceResponse; + +public class ListNotificationsResponse extends AbstractBceResponse { + private List notifications = null; + + public List getNotifications() { + return notifications; + } + + public void setNotifications(List notifications) { + this.notifications = notifications; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListNotificationsResponse {\n"); + sb.append(" notifications: ").append(notifications).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/Notification.java b/src/main/java/com/baidubce/services/doc/model/Notification.java new file mode 100755 index 00000000..de82cc66 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/Notification.java @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2015 Baidu.com, Inc. All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF 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; + +public class Notification { + /** + * 通知名称 + **/ + private String name = null; + + /** + * 通知消息接收地址 + **/ + private String endpoint = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Notification withName(String name) { + this.name = name; + return this; + } + + public String getEndpoint() { + return endpoint; + } + + public void setEndpoint(String endpoint) { + this.endpoint = endpoint; + } + + public Notification withEndpoint(String endpoint) { + this.endpoint = endpoint; + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class Notification {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" endpoint: ").append(endpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java new file mode 100755 index 00000000..e8e9ac4d --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/PublishDocumentRequest.java @@ -0,0 +1,24 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class PublishDocumentRequest extends AbstractBceRequest { + + private String documentId = null; + + public PublishDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDocumentId() { return this.documentId; } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java new file mode 100755 index 00000000..9ee13d20 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/PublishDocumentResponse.java @@ -0,0 +1,10 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class PublishDocumentResponse extends AbstractBceResponse { + +} diff --git a/src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java b/src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java new file mode 100755 index 00000000..ba583200 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ReadDocumentRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class ReadDocumentRequest extends AbstractBceRequest { + private String documentId = null; + + public ReadDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getDocumentId() { return this.documentId; } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java new file mode 100755 index 00000000..5f0c48ba --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/ReadDocumentResponse.java @@ -0,0 +1,59 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class ReadDocumentResponse extends AbstractBceResponse { + private String documentId; + private String host; + private String docId; + private String token; + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getDocId() { + return docId; + } + + public void setDocId(String docId) { + this.docId = docId; + } + + public String getToken() { + return token; + } + + public void setToken(String token) { + this.token = token; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Read Document {\n"); + + sb.append(" documentId: ").append(documentId).append("\n"); + sb.append(" host: ").append(host).append("\n"); + sb.append(" docId: ").append(docId).append("\n"); + sb.append(" token: ").append(token).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 new file mode 100755 index 00000000..75e2b9f7 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentRequest.java @@ -0,0 +1,37 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by baidu on 15/12/30. + */ +public class RegisterDocumentRequest extends AbstractBceRequest { + private String title = null; + private String format = null; + private String notification = null; + + public RegisterDocumentRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + public String getFormat() { return this.format; } + + public void setFormat(String format) { + this.format = format; + } + + public String getNotification() { return this.notification; } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getTitle() { return this.title; } + + public void setTitle(String title) { + this.title = title; + } + +} diff --git a/src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java new file mode 100755 index 00000000..113603c6 --- /dev/null +++ b/src/main/java/com/baidubce/services/doc/model/RegisterDocumentResponse.java @@ -0,0 +1,59 @@ +package com.baidubce.services.doc.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by baidu on 15/12/31. + */ +public class RegisterDocumentResponse extends AbstractBceResponse { + private String documentId; + private String bucket; + private String object; + private String bosEndpoint; + + public String getDocumentId() { + return documentId; + } + + public void setDocumentId(String documentId) { + this.documentId = documentId; + } + + public String getBucket() { + return bucket; + } + + public void setBucket(String bucket) { + this.bucket = bucket; + } + + public String getObject() { + return object; + } + + public void setObject(String object) { + this.object = object; + } + + public String getBosEndpoint() { + return bosEndpoint; + } + + public void setBosEndpoint(String bosEndpoint) { + this.bosEndpoint = bosEndpoint; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RegisterDocument {\n"); + + sb.append(" documentId: ").append(documentId).append("\n"); + sb.append(" bucket: ").append(bucket).append("\n"); + sb.append(" object: ").append(object).append("\n"); + sb.append(" bosEndpoint: ").append(bosEndpoint).append("\n"); + sb.append("}\n"); + return sb.toString(); + } + +} diff --git a/src/main/java/com/baidubce/services/lss/LssClient.java b/src/main/java/com/baidubce/services/lss/LssClient.java index 4db89ba5..cb20a305 100644 --- a/src/main/java/com/baidubce/services/lss/LssClient.java +++ b/src/main/java/com/baidubce/services/lss/LssClient.java @@ -13,21 +13,6 @@ package com.baidubce.services.lss; -import static com.baidubce.util.Validate.checkIsTrue; -import static com.baidubce.util.Validate.checkNotNull; -import static com.baidubce.util.Validate.checkStringNotEmpty; - -import java.io.UnsupportedEncodingException; -import java.net.URI; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.joda.time.DateTime; -import org.joda.time.DateTimeZone; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - import com.baidubce.AbstractBceClient; import com.baidubce.BceClientConfiguration; import com.baidubce.BceClientException; @@ -83,10 +68,14 @@ import com.baidubce.services.lss.model.ListSessionsResponse; import com.baidubce.services.lss.model.LivePublishInfo; import com.baidubce.services.lss.model.LiveThumbnail; +import com.baidubce.services.lss.model.PauseAppStreamRequest; +import com.baidubce.services.lss.model.PauseAppStreamResponse; import com.baidubce.services.lss.model.PauseSessionRequest; import com.baidubce.services.lss.model.PauseSessionResponse; import com.baidubce.services.lss.model.RefreshSessionRequest; 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.Rtmp; @@ -101,8 +90,31 @@ import com.baidubce.services.lss.model.UpdateSecurityPolicyResponse; 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.util.HttpUtils; import com.baidubce.util.JsonUtils; +import org.joda.time.DateTime; +import org.joda.time.DateTimeZone; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.baidubce.util.Validate.checkIsTrue; +import static com.baidubce.util.Validate.checkNotNull; +import static com.baidubce.util.Validate.checkStringNotEmpty; /** * Client for accessing Live Streaming Service. All service calls made @@ -125,6 +137,11 @@ public class LssClient extends AbstractBceClient { */ private static final String LIVE_SESSION = "session"; + /** + * The common URI prefix for live app services. + */ + private static final String LIVE_APP = "app"; + /** * The common URI prefix for live notification services. */ @@ -391,6 +408,29 @@ public CreateSessionResponse createSession(String description, String preset, St return createSession(request); } + /** + * 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 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. + * + */ + public CreateSessionResponse createSession(String description, List presets, String notification, + String securityPolicy, String recording, LivePublishInfo publish) { + CreateSessionRequest request = new CreateSessionRequest(); + Map presetMap = new HashMap(); + for (int i = 0; i < presets.size(); i++) { + presetMap.put("L" + i, presets.get(i)); + } + request.withPresets(presetMap).withDescription(description).withNotification(notification); + request.withSecurityPolicy(securityPolicy).withPublish(publish).withRecording(recording); + return createSession(request); + } + /** * Create a live session in the live stream service. * @@ -399,8 +439,9 @@ public CreateSessionResponse createSession(String description, String preset, St public CreateSessionResponse createSession(CreateSessionRequest request) { checkNotNull(request, "The parameter request should NOT be null."); - checkStringNotEmpty(request.getPreset(), - "The parameter preset should NOT be null or empty string."); + if (request.getPreset() == null && request.getPresets() == null) { + throw new IllegalArgumentException("The parameter preset and presets should NOT both be null or empty."); + } InternalRequest internalRequest = createRequest(HttpMethodName.POST, request, LIVE_SESSION); return invokeHttpClient(internalRequest, CreateSessionResponse.class); @@ -479,10 +520,37 @@ public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutI String expire = formatter.print(expireTime); GetSecurityPolicyResponse getSecurityPolicyResponse = getSecurityPolicy(getSessionResponse.getSecurityPolicy()); + Map hlsUrls = new HashMap(); + Map rtmpUrls = new HashMap(); + Map flvUrls = new HashMap(); if (getSecurityPolicyResponse.getAuth().getPlay()) { - String hlsUrl = getSessionResponse.getPlay().getHlsUrl(); - String rtmpUrl = getSessionResponse.getPlay().getRtmpUrl(); - if (hlsUrl != null) { + if (getSessionResponse.getPlay().getHlsUrls() != null) { + for (Map.Entry entry : getSessionResponse.getPlay().getHlsUrls().entrySet()) { + String line = entry.getKey(); + String hlsUrl = entry.getValue(); + if (hlsUrl != null) { + String hlsToken = null; + if (line.equals("L0")) { + hlsToken = LssUtils.hmacSha256( + String.format("/%s/live.m3u8;%s", sessionId, expire), + getSecurityPolicyResponse.getAuth().getKey()); + } else { + hlsToken = LssUtils.hmacSha256( + String.format("/%s-%s/live.m3u8;%s", sessionId, line, expire), + getSecurityPolicyResponse.getAuth().getKey()); + } + if (hlsUrl.lastIndexOf('?') == -1) { + hlsUrl += String.format("?token=%s&expire=%s", hlsToken, expire); + } else { + hlsUrl += String.format("&token=%s&expire=%s", hlsToken, expire); + } + hlsUrls.put(line, hlsUrl); + } + } + + getSessionResponse.getPlay().setHlsUrls(hlsUrls); + } else if (getSessionResponse.getPlay().getHlsUrl() != null) { + String hlsUrl = getSessionResponse.getPlay().getHlsUrl(); String hlsToken = LssUtils.hmacSha256( String.format("/%s/live.m3u8;%s", sessionId, expire), getSecurityPolicyResponse.getAuth().getKey()); @@ -491,15 +559,58 @@ public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutI } else { hlsUrl += String.format("&token=%s&expire=%s", hlsToken, expire); } + getSessionResponse.getPlay().setHlsUrl(hlsUrl); } - if (rtmpUrl != null) { + + if (getSessionResponse.getPlay().getRtmpUrls() != null) { + for (Map.Entry entry : getSessionResponse.getPlay().getRtmpUrls().entrySet()) { + String line = entry.getKey(); + String rtmpUrl = entry.getValue(); + if (rtmpUrl != null) { + String rtmpToken = LssUtils.hmacSha256( + String.format("%s;%s", sessionId, expire), + getSecurityPolicyResponse.getAuth().getKey()); + rtmpUrl += String.format("?token=%s&expire=%s", rtmpToken, expire); + } + rtmpUrls.put(line, rtmpUrl); + } + + getSessionResponse.getPlay().setRtmpUrls(rtmpUrls); + } else if (getSessionResponse.getPlay().getRtmpUrl() != null) { + String rtmpUrl = getSessionResponse.getPlay().getRtmpUrl(); String rtmpToken = LssUtils.hmacSha256( String.format("%s;%s", sessionId, expire), getSecurityPolicyResponse.getAuth().getKey()); rtmpUrl += String.format("?token=%s&expire=%s", rtmpToken, expire); + getSessionResponse.getPlay().setRtmpUrl(rtmpUrl); } + + if (getSessionResponse.getPlay().getFlvUrls() != null) { + for (Map.Entry entry : getSessionResponse.getPlay().getFlvUrls().entrySet()) { + String line = entry.getKey(); + String flvUrl = entry.getValue(); + if (flvUrl != null) { + String flvToken = LssUtils.hmacSha256( + String.format("%s;%s", flvUrl, expire), + getSecurityPolicyResponse.getAuth().getKey()); + flvUrl += String.format("?token=%s&expire=%s", flvToken, expire); + } + flvUrls.put(line, flvUrl); + } + + getSessionResponse.getPlay().setFlvUrls(flvUrls); + } else if (getSessionResponse.getPlay().getFlvUrl() != null) { + String flvUrl = getSessionResponse.getPlay().getFlvUrl(); + String flvToken = LssUtils.hmacSha256( + String.format("%s;%s", flvUrl, expire), + getSecurityPolicyResponse.getAuth().getKey()); + flvUrl += String.format("?token=%s&expire=%s", flvToken, expire); + + getSessionResponse.getPlay().setFlvUrl(flvUrl); + + } } if (getSecurityPolicyResponse.getAuth().getPush()) { @@ -510,6 +621,7 @@ public GetSessionResponse getSessionWithToken(String sessionId, Integer timeoutI pushUrl += String.format("?token=%s&expire=%s", pushToken, expire); getSessionResponse.getPublish().setPushUrl(pushUrl); } + return getSessionResponse; } @@ -581,6 +693,155 @@ public PauseSessionResponse pauseSession(PauseSessionRequest request) { return invokeHttpClient(internalRequest, PauseSessionResponse.class); } + /** + * get detail of your app by name + * + * @param app app name + * + */ + public GetAppResponse queryApp(String app) { + GetAppRequest request = new GetAppRequest(); + request.setApp(app); + return queryApp(request); + } + + /** + * get detail of your app by name + * + * @param request The request object containing all parameters for querying app. + * + */ + public GetAppResponse queryApp(GetAppRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP, + request.getApp()); + return invokeHttpClient(internalRequest, GetAppResponse.class); + } + + /** + * list all your apps + * + */ + public ListAppResponse listApp() { + ListAppRequest request = new ListAppRequest(); + return listApp(request); + } + + /** + * list all your apps + * + * @param request The request object containing all parameters for list all apps. + * + */ + public ListAppResponse listApp(ListAppRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP); + return invokeHttpClient(internalRequest, ListAppResponse.class); + } + + /** + * get detail of your stream by app name and stream name + * + * @param app app name + * @param stream stream name + * + */ + public GetAppStreamResponse queryAppStream(String app, String stream) { + GetAppStreamRequest request = new GetAppStreamRequest(); + request.setApp(app); + request.setStream(stream); + return queryAppStream(request); + } + + /** + * get detail of your stream by app name and stream name + * + * @param request The request object containing all parameters for query app stream. + * + */ + public GetAppStreamResponse queryAppStream(GetAppStreamRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string."); + checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP, + request.getApp(), LIVE_SESSION, request.getStream()); + return invokeHttpClient(internalRequest, GetAppStreamResponse.class); + } + + /** + * list your streams by app name and stream status + * + * @param app app name + * @param status stream status + * + */ + public ListAppStreamsResponse listAppStreams(String app, String status) { + ListAppStreamsRequest request = new ListAppStreamsRequest(); + request.setApp(app); + request.setStatus(status); + return listAppStreams(request); + } + + + /** + * list your streams by app name + * + * @param app app name + * + */ + public ListAppStreamsResponse listAppStreams(String app) { + ListAppStreamsRequest request = new ListAppStreamsRequest(); + request.setApp(app); + return listAppStreams(request); + } + + /** + * list your streams by app name and stream status + * + * @param request The request object containing all parameters for list app streams. + * + */ + public ListAppStreamsResponse listAppStreams(ListAppStreamsRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_APP, + request.getApp(), LIVE_SESSION); + if (request.getStatus() != null) { + internalRequest.addParameter("status", request.getStatus()); + } + return invokeHttpClient(internalRequest, ListAppStreamsResponse.class); + } + + /** + * Pause your app stream by app name and stream name + * + * @param app app name + * @param stream stream name + * + */ + public PauseAppStreamResponse pauseAppStream(String app, String stream) { + PauseAppStreamRequest pauseAppStreamRequest = new PauseAppStreamRequest(); + pauseAppStreamRequest.setApp(app); + pauseAppStreamRequest.setStream(stream); + return pauseAppStream(pauseAppStreamRequest); + } + + /** + * Pause your app stream by app name and stream name + * + * @param request The request object containing all parameters for pausing app session. + * + */ + public PauseAppStreamResponse pauseAppStream(PauseAppStreamRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string."); + checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP, + request.getApp(), LIVE_SESSION, request.getStream()); + internalRequest.addParameter(PAUSE, null); + return invokeHttpClient(internalRequest, PauseAppStreamResponse.class); + } /** * Resume your live session by live session id. @@ -609,6 +870,36 @@ public ResumeSessionResponse resumeSession(ResumeSessionRequest request) { return invokeHttpClient(internalRequest, ResumeSessionResponse.class); } + /** + * Resume your app stream by app name and stream name + * + * @param app app name + * @param stream stream name + * + */ + public ResumeAppStreamResponse resumeAppStream(String app, String stream) { + ResumeAppStreamRequest request = new ResumeAppStreamRequest(); + request.setApp(app); + request.setStream(stream); + return resumeAppStream(request); + } + + /** + * Resume your app stream by app name and stream name + * + * @param request The request object containing all parameters for resuming app session. + * + */ + public ResumeAppStreamResponse resumeAppStream(ResumeAppStreamRequest request) { + checkNotNull(request, "The parameter request should NOT be null."); + checkStringNotEmpty(request.getApp(), "The parameter app should NOT be null or empty string."); + checkStringNotEmpty(request.getStream(), "The parameter stream should NOT be null or empty string."); + InternalRequest internalRequest = createRequest(HttpMethodName.PUT, request, LIVE_APP, + request.getApp(), LIVE_SESSION, request.getStream()); + internalRequest.addParameter(RESUME, null); + return invokeHttpClient(internalRequest, ResumeAppStreamResponse.class); + } + /** * Refresh your live session by live session id. * @@ -996,4 +1287,4 @@ private InternalRequest fillRequestPayload(InternalRequest internalRequest, Abst return internalRequest; } -} +} \ No newline at end of file diff --git a/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java b/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java index 3957729e..351d2710 100644 --- a/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateSessionRequest.java @@ -16,12 +16,16 @@ import com.baidubce.auth.BceCredentials; import com.baidubce.model.AbstractBceRequest; +import java.util.Map; + public class CreateSessionRequest extends AbstractBceRequest { private String description = null; private String preset = null; + private Map presets = null; + private String notification = null; private String securityPolicy = null; @@ -56,6 +60,19 @@ public CreateSessionRequest withPreset(String preset) { return this; } + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + + public CreateSessionRequest withPresets(Map presets) { + this.presets = presets; + return this; + } + public String getNotification() { return notification; } @@ -119,6 +136,7 @@ public String toString() { sb.append("class CreateSessionRequest {\n"); sb.append(" description: ").append(description).append("\n"); sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); sb.append(" notification: ").append(notification).append("\n"); sb.append(" securityPolicy: ").append(securityPolicy).append("\n"); sb.append(" recording: ").append(recording).append("\n"); diff --git a/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java index 751faaaa..d0a27ca3 100644 --- a/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/CreateSessionResponse.java @@ -15,6 +15,8 @@ import com.baidubce.model.AbstractBceResponse; +import java.util.Map; + public class CreateSessionResponse extends AbstractBceResponse { private String sessionId = null; @@ -23,6 +25,8 @@ public class CreateSessionResponse extends AbstractBceResponse { private String preset = null; + private Map presets = null; + private String createTime = null; private String status = null; @@ -117,6 +121,14 @@ public void setPlay(LivePlay play) { this.play = play; } + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); @@ -124,6 +136,7 @@ public String toString() { sb.append(" sessionId: ").append(sessionId).append("\n"); sb.append(" description: ").append(description).append("\n"); sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); sb.append(" status: ").append(status).append("\n"); sb.append(" notification: ").append(notification).append("\n"); diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppRequest.java b/src/main/java/com/baidubce/services/lss/model/GetAppRequest.java new file mode 100755 index 00000000..1493e3bb --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAppRequest.java @@ -0,0 +1,38 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/28. + */ +public class GetAppRequest extends AbstractBceRequest { + private String app = null; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public GetAppRequest withApp(String app) { + this.app = app; + return this; + } + + public GetAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAppRequest {\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAppResponse.java new file mode 100755 index 00000000..bc414f56 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAppResponse.java @@ -0,0 +1,128 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Map; + +/** + * Created by wuyafei on 16/6/28. + */ +public class GetAppResponse extends AbstractBceResponse { + private String name = null; + + private String description = null; + + private Map presets = null; + + private String preset = null; + + private String status = null; + + private String notification = null; + + private String securityPolicy = null; + + private String recording = null; + + private PlayPrefix playPrefix = null; + + private PublishPrefix publishPrefix = null; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getPreset() { + return preset; + } + + public void setPreset(String preset) { + this.preset = preset; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public void setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + } + + public String getRecording() { + return recording; + } + + public void setRecording(String recording) { + this.recording = recording; + } + + public PlayPrefix getPlayPrefix() { + return playPrefix; + } + + public void setPlayPrefix(PlayPrefix playPrefix) { + this.playPrefix = playPrefix; + } + + public PublishPrefix getPublishPrefix() { + return publishPrefix; + } + + public void setPublishPrefix(PublishPrefix publishPrefix) { + this.publishPrefix = publishPrefix; + } + + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAppResponse {\n"); + sb.append(" name: ").append(name).append("\n"); + sb.append(" description: ").append(description).append("\n"); + sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" notification: ").append(notification).append("\n"); + sb.append(" securityPolicy: ").append(securityPolicy).append("\n"); + sb.append(" recording: ").append(recording).append("\n"); + sb.append(" playPrefix: ").append(playPrefix).append("\n"); + sb.append(" publishPrefix: ").append(publishPrefix).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java new file mode 100755 index 00000000..42bede88 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAppStreamRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/28. + */ +public class GetAppStreamRequest extends AbstractBceRequest { + private String app; + private String stream; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public GetAppStreamRequest withApp(String app) { + this.app = app; + return this; + } + + public GetAppStreamRequest withStream(String stream) { + this.stream = stream; + return this; + } + + public GetAppStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAppStreamRequest {\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append(" stream: ").append(stream).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java new file mode 100755 index 00000000..34a24482 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/GetAppStreamResponse.java @@ -0,0 +1,172 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.Map; + +/** + * Created by wuyafei on 16/6/28. + */ +public class GetAppStreamResponse extends AbstractBceResponse { + private String sessionId = null; + + private String description = null; + + private String preset = null; + + private Map presets = null; + + private String createTime = null; + + private String status = null; + + private String notification = null; + + private String securityPolicy = null; + + private String streamingStatus = null; + + private String recording = null; + + private LivePublish publish = null; + + private LivePlay play = null; + + private SessionErrorInfo error = null; + + private RealTimeSessionStatistics statistics = null; + + public String getSessionId() { + return sessionId; + } + + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + 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 String getCreateTime() { + return createTime; + } + + public void setCreateTime(String createTime) { + this.createTime = createTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getNotification() { + return notification; + } + + public void setNotification(String notification) { + this.notification = notification; + } + + public String getSecurityPolicy() { + return securityPolicy; + } + + public void setSecurityPolicy(String securityPolicy) { + this.securityPolicy = securityPolicy; + } + + public LivePublish getPublish() { + return publish; + } + + public void setPublish(LivePublish publish) { + this.publish = publish; + } + + public LivePlay getPlay() { + return play; + } + + public void setPlay(LivePlay play) { + this.play = play; + } + + public String getStreamingStatus() { + return streamingStatus; + } + + public void setStreamingStatus(String streamingStatus) { + this.streamingStatus = streamingStatus; + } + + public String getRecording() { + return recording; + } + + public void setRecording(String recording) { + this.recording = recording; + } + + public SessionErrorInfo getError() { + return error; + } + + public void setError(SessionErrorInfo error) { + this.error = error; + } + + public RealTimeSessionStatistics getStatistics() { + return statistics; + } + + public void setStatistics(RealTimeSessionStatistics statistics) { + this.statistics = statistics; + } + + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class GetAppStreamResponse {\n"); + sb.append(" sessionId: ").append(sessionId).append("\n"); + sb.append(" description: ").append(description).append("\n"); + sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); + sb.append(" createTime: ").append(createTime).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append(" notification: ").append(notification).append("\n"); + sb.append(" securityPolicy: ").append(securityPolicy).append("\n"); + sb.append(" streamingStatus: ").append(streamingStatus).append("\n"); + sb.append(" recording: ").append(recording).append("\n"); + sb.append(" publish: ").append(publish).append("\n"); + sb.append(" play: ").append(play).append("\n"); + sb.append(" error: ").append(error).append("\n"); + sb.append(" statistics: ").append(statistics).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java index f8d090a1..f4fedb51 100644 --- a/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/GetSessionResponse.java @@ -15,6 +15,8 @@ import com.baidubce.model.AbstractBceResponse; +import java.util.Map; + public class GetSessionResponse extends AbstractBceResponse { private String sessionId = null; @@ -22,6 +24,8 @@ public class GetSessionResponse extends AbstractBceResponse { private String preset = null; + private Map presets = null; + private String createTime = null; private String status = null; @@ -146,6 +150,14 @@ public void setStatistics(RealTimeSessionStatistics statistics) { this.statistics = statistics; } + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); @@ -153,6 +165,7 @@ public String toString() { sb.append(" sessionId: ").append(sessionId).append("\n"); sb.append(" description: ").append(description).append("\n"); sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); sb.append(" status: ").append(status).append("\n"); sb.append(" notification: ").append(notification).append("\n"); diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppRequest.java b/src/main/java/com/baidubce/services/lss/model/ListAppRequest.java new file mode 100755 index 00000000..5434c48e --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListAppRequest.java @@ -0,0 +1,23 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/28. + */ +public class ListAppRequest extends AbstractBceRequest { + + public ListAppRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListAppRequest {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppResponse.java b/src/main/java/com/baidubce/services/lss/model/ListAppResponse.java new file mode 100755 index 00000000..4bbe42d1 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListAppResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by wuyafei on 16/6/28. + */ +public class ListAppResponse extends AbstractBceResponse { + List apps = null; + + public List getApps() { + return apps; + } + + public void setApps(List apps) { + this.apps = apps; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListAppResponse {\n"); + sb.append(" streams: ").append(apps).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java new file mode 100755 index 00000000..164aec7e --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/28. + */ +public class ListAppStreamsRequest extends AbstractBceRequest { + private String app = null; + private String status = null; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public ListAppStreamsRequest withStatus(String status) { + this.status = status; + return this; + } + + public ListAppStreamsRequest withApp(String app) { + this.app = app; + return this; + } + + public ListAppStreamsRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListAppStreamsRequest {\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append(" status: ").append(status).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java new file mode 100755 index 00000000..105e2a3b --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ListAppStreamsResponse.java @@ -0,0 +1,29 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +import java.util.List; + +/** + * Created by wuyafei on 16/6/28. + */ +public class ListAppStreamsResponse extends AbstractBceResponse { + private List sessions = null; + + public List getSessions() { + return sessions; + } + + public void setSessions(List sessions) { + this.sessions = sessions; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ListAppStreamsResponse {\n"); + sb.append(" streams: ").append(sessions).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/LivePlay.java b/src/main/java/com/baidubce/services/lss/model/LivePlay.java index 83bda4d2..7b455811 100644 --- a/src/main/java/com/baidubce/services/lss/model/LivePlay.java +++ b/src/main/java/com/baidubce/services/lss/model/LivePlay.java @@ -13,12 +13,20 @@ package com.baidubce.services.lss.model; +import java.util.Map; + public class LivePlay { private String rtmpUrl = null; private String hlsUrl = null; + private String flvUrl = null; + + private Map hlsUrls; + private Map rtmpUrls; + private Map flvUrls; + public String getRtmpUrl() { return rtmpUrl; } @@ -32,6 +40,19 @@ public LivePlay withRtmpUrl(String rtmpUrl) { return this; } + public Map getRtmpUrls() { + return rtmpUrls; + } + + public void setRtmpUrls(Map rtmpUrls) { + this.rtmpUrls = rtmpUrls; + } + + public LivePlay withRtmpUrls(Map rtmpUrls) { + this.rtmpUrls = rtmpUrls; + return this; + } + public String getHlsUrl() { return hlsUrl; } @@ -45,12 +66,55 @@ public LivePlay withHlsUrl(String hlsUrl) { return this; } + public Map getHlsUrls() { + return hlsUrls; + } + + public void setHlsUrls(Map hlsUrls) { + this.hlsUrls = hlsUrls; + } + + public LivePlay withHlsUrls(Map hlsUrls) { + this.hlsUrls = hlsUrls; + return this; + } + + public String getFlvUrl() { + return flvUrl; + } + + public void setFlvUrl(String flvUrl) { + this.flvUrl = flvUrl; + } + + public LivePlay withFlvUrl(String flvUrl) { + this.flvUrl = flvUrl; + return this; + } + + public Map getFlvUrls() { + return flvUrls; + } + + public void setFlvUrls(Map flvUrls) { + this.flvUrls = flvUrls; + } + + public LivePlay withFlvUrls(Map flvUrls) { + this.flvUrls = flvUrls; + return this; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); sb.append("class LivePlay {\n"); sb.append(" rtmpUrl: ").append(rtmpUrl).append("\n"); sb.append(" hlsUrl: ").append(hlsUrl).append("\n"); + sb.append(" flvUrl: ").append(flvUrl).append("\n"); + sb.append(" rtmpUrls: ").append(rtmpUrls).append("\n"); + sb.append(" hlsUrls: ").append(hlsUrls).append("\n"); + sb.append(" flvUrls: ").append(flvUrls).append("\n"); sb.append("}\n"); return sb.toString(); } diff --git a/src/main/java/com/baidubce/services/lss/model/LiveSession.java b/src/main/java/com/baidubce/services/lss/model/LiveSession.java index 9e48f669..f6afa06b 100644 --- a/src/main/java/com/baidubce/services/lss/model/LiveSession.java +++ b/src/main/java/com/baidubce/services/lss/model/LiveSession.java @@ -13,6 +13,8 @@ package com.baidubce.services.lss.model; +import java.util.Map; + public class LiveSession { private String sessionId = null; @@ -20,6 +22,8 @@ public class LiveSession { private String preset = null; + private Map presets = null; + private String createTime = null; private String status = null; @@ -134,6 +138,14 @@ public void setError(SessionErrorInfo error) { this.error = error; } + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); @@ -141,6 +153,7 @@ public String toString() { sb.append(" sessionId: ").append(sessionId).append("\n"); sb.append(" description: ").append(description).append("\n"); sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); sb.append(" status: ").append(status).append("\n"); sb.append(" notification: ").append(notification).append("\n"); diff --git a/src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java new file mode 100755 index 00000000..4ac49701 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/26. + */ +public class PauseAppStreamRequest extends AbstractBceRequest { + private String app; + private String stream; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public PauseAppStreamRequest withApp(String app) { + this.app = app; + return this; + } + + public PauseAppStreamRequest withStream(String stream) { + this.stream = stream; + return this; + } + + public PauseAppStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PauseAppStreamRequest {\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append(" stream: ").append(stream).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java new file mode 100755 index 00000000..6bfbd89e --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/PauseAppStreamResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by wuyafei on 16/6/26. + */ +public class PauseAppStreamResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PauseAppStreamResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java b/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java new file mode 100755 index 00000000..9c32c861 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/PlayPrefix.java @@ -0,0 +1,47 @@ +package com.baidubce.services.lss.model; + +/** + * Created by wuyafei on 16/6/28. + */ +public class PlayPrefix { + private String rtmp; + + private String hls; + + private String flv; + + public String getRtmp() { + return rtmp; + } + + public void setRtmp(String rtmp) { + this.rtmp = rtmp; + } + + public String getHls() { + return hls; + } + + public void setHls(String hls) { + this.hls = hls; + } + + public String getFlv() { + return flv; + } + + public void setFlv(String flv) { + this.flv = flv; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PlayPrefix {\n"); + sb.append(" rtmpUrlPrefix: ").append(rtmp).append("\n"); + sb.append(" hlsUrlPrefix: ").append(hls).append("\n"); + sb.append(" flvUrlPrefix: ").append(flv).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java b/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java new file mode 100755 index 00000000..d8a31779 --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/PublishPrefix.java @@ -0,0 +1,25 @@ +package com.baidubce.services.lss.model; + +/** + * Created by wuyafei on 16/6/28. + */ +public class PublishPrefix { + private String push; + + public String getPush() { + return push; + } + + public void setPush(String push) { + this.push = push; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class PublishPrefix {\n"); + sb.append(" pushUrlPrefix: ").append(push).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java b/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java index 3692482a..8ed583f1 100644 --- a/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java +++ b/src/main/java/com/baidubce/services/lss/model/RefreshSessionResponse.java @@ -15,6 +15,8 @@ import com.baidubce.model.AbstractBceResponse; +import java.util.Map; + public class RefreshSessionResponse extends AbstractBceResponse { private String sessionId = null; @@ -22,6 +24,8 @@ public class RefreshSessionResponse extends AbstractBceResponse { private String preset = null; + private Map presets = null; + private String createTime = null; private String status = null; @@ -136,6 +140,14 @@ public void setError(SessionErrorInfo error) { this.error = error; } + public Map getPresets() { + return presets; + } + + public void setPresets(Map presets) { + this.presets = presets; + } + @Override public String toString() { final StringBuilder sb = new StringBuilder(); @@ -143,6 +155,7 @@ public String toString() { sb.append(" sessionId: ").append(sessionId).append("\n"); sb.append(" description: ").append(description).append("\n"); sb.append(" preset: ").append(preset).append("\n"); + sb.append(" presets: ").append(presets).append("\n"); sb.append(" createTime: ").append(createTime).append("\n"); sb.append(" status: ").append(status).append("\n"); sb.append(" notification: ").append(notification).append("\n"); diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java new file mode 100755 index 00000000..44c40dbc --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamRequest.java @@ -0,0 +1,53 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.auth.BceCredentials; +import com.baidubce.model.AbstractBceRequest; + +/** + * Created by wuyafei on 16/6/26. + */ +public class ResumeAppStreamRequest extends AbstractBceRequest { + private String app; + private String stream; + + public String getApp() { + return app; + } + + public void setApp(String app) { + this.app = app; + } + + public String getStream() { + return stream; + } + + public void setStream(String stream) { + this.stream = stream; + } + + public ResumeAppStreamRequest withApp(String app) { + this.app = app; + return this; + } + + public ResumeAppStreamRequest withStream(String stream) { + this.stream = stream; + return this; + } + + public ResumeAppStreamRequest withRequestCredentials(BceCredentials credentials) { + this.setRequestCredentials(credentials); + return this; + } + + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResumeAppStreamRequest {\n"); + sb.append(" app: ").append(app).append("\n"); + sb.append(" stream: ").append(stream).append("\n"); + sb.append("}\n"); + return sb.toString(); + } +} diff --git a/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java new file mode 100755 index 00000000..68b1828b --- /dev/null +++ b/src/main/java/com/baidubce/services/lss/model/ResumeAppStreamResponse.java @@ -0,0 +1,16 @@ +package com.baidubce.services.lss.model; + +import com.baidubce.model.AbstractBceResponse; + +/** + * Created by wuyafei on 16/6/26. + */ +public class ResumeAppStreamResponse extends AbstractBceResponse { + @Override + public String toString() { + final StringBuilder sb = new StringBuilder(); + sb.append("class ResumeAppStreamResponse {\n"); + sb.append("}\n"); + return sb.toString(); + } +}