You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

279 lines
10 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. package cos
  2. import (
  3. "context"
  4. "encoding/xml"
  5. "net/http"
  6. )
  7. type DocProcessJobInput struct {
  8. Object string `xml:"Object,omitempty"`
  9. }
  10. type DocProcessJobOutput struct {
  11. Region string `xml:"Region,omitempty"`
  12. Bucket string `xml:"Bucket,omitempty"`
  13. Object string `xml:"Object,omitempty"`
  14. }
  15. type DocProcessJobDocProcess struct {
  16. SrcType string `xml:"SrcType,omitempty"`
  17. TgtType string `xml:"TgtType,omitempty"`
  18. SheetId int `xml:"SheetId,omitempty"`
  19. StartPage int `xml:"StartPage,omitempty"`
  20. EndPage int `xml:"EndPage,omitempty"`
  21. ImageParams string `xml:"ImageParams,omitempty"`
  22. DocPassword string `xml:"DocPassword,omitempty"`
  23. Comments int `xml:"Comments,omitempty"`
  24. PaperDirection int `xml:"PaperDirection,omitempty"`
  25. Quality int `xml:"Quality,omitempty"`
  26. Zoom int `xml:"Zoom,omitempty"`
  27. }
  28. type DocProcessJobDocProcessResult struct {
  29. FailPageCount int `xml:",omitempty"`
  30. SuccPageCount int `xml:"SuccPageCount,omitempty"`
  31. TaskId string `xml:"TaskId,omitempty"`
  32. TgtType string `xml:"TgtType,omitempty"`
  33. TotalPageCount int `xml:"TotalPageCount,omitempty"`
  34. PageInfo struct {
  35. PageNo int `xml:"PageNo,omitempty"`
  36. TgtUri string `xml:"TgtUri,omitempty"`
  37. } `xml:"PageInfo,omitempty"`
  38. }
  39. type DocProcessJobOperation struct {
  40. Output *DocProcessJobOutput `xml:"Output,omitempty"`
  41. DocProcess *DocProcessJobDocProcess `xml:"DocProcess,omitempty"`
  42. DocProcessResult *DocProcessJobDocProcessResult `xml:"DocProcessResult,omitempty"`
  43. }
  44. type DocProcessJobDetail struct {
  45. Code string `xml:"Code,omitempty"`
  46. Message string `xml:"Message,omitempty"`
  47. JobId string `xml:"JobId,omitempty"`
  48. Tag string `xml:"Tag,omitempty"`
  49. State string `xml:"State,omitempty"`
  50. CreationTime string `xml:"CreationTime,omitempty"`
  51. QueueId string `xml:"QueueId,omitempty"`
  52. Input *DocProcessJobInput `xml:"Input,omitempty"`
  53. Operation *DocProcessJobOperation `xml:"Operation,omitempty"`
  54. }
  55. type CreateDocProcessJobsOptions struct {
  56. XMLName xml.Name `xml:"Request"`
  57. Tag string `xml:"Tag,omitempty"`
  58. Input *DocProcessJobInput `xml:"Input,omitempty"`
  59. Operation *DocProcessJobOperation `xml:"Operation,omitempty"`
  60. QueueId string `xml:"QueueId,omitempty"`
  61. }
  62. type CreateDocProcessJobsResult struct {
  63. XMLName xml.Name `xml:"Response"`
  64. JobsDetail DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  65. }
  66. // 创建文档预览任务 https://cloud.tencent.com/document/product/436/54056
  67. func (s *CIService) CreateDocProcessJobs(ctx context.Context, opt *CreateDocProcessJobsOptions) (*CreateDocProcessJobsResult, *Response, error) {
  68. var res CreateDocProcessJobsResult
  69. sendOpt := sendOptions{
  70. baseURL: s.client.BaseURL.CIURL,
  71. uri: "/doc_jobs",
  72. method: http.MethodPost,
  73. body: opt,
  74. result: &res,
  75. }
  76. resp, err := s.client.send(ctx, &sendOpt)
  77. return &res, resp, err
  78. }
  79. type DescribeDocProcessJobResult struct {
  80. XMLName xml.Name `xml:"Response"`
  81. JobsDetail *DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  82. NonExistJobIds string `xml:"NonExistJobIds,omitempty"`
  83. }
  84. // 查询文档预览任务 https://cloud.tencent.com/document/product/436/54095
  85. func (s *CIService) DescribeDocProcessJob(ctx context.Context, jobid string) (*DescribeDocProcessJobResult, *Response, error) {
  86. var res DescribeDocProcessJobResult
  87. sendOpt := sendOptions{
  88. baseURL: s.client.BaseURL.CIURL,
  89. uri: "/doc_jobs/" + jobid,
  90. method: http.MethodGet,
  91. result: &res,
  92. }
  93. resp, err := s.client.send(ctx, &sendOpt)
  94. return &res, resp, err
  95. }
  96. type DescribeDocProcessJobsOptions struct {
  97. QueueId string `url:"queueId,omitempty"`
  98. Tag string `url:"tag,omitempty"`
  99. OrderByTime string `url:"orderByTime,omitempty"`
  100. NextToken string `url:"nextToken,omitempty"`
  101. Size int `url:"size,omitempty"`
  102. States string `url:"states,omitempty"`
  103. StartCreationTime string `url:"startCreationTime,omitempty"`
  104. EndCreationTime string `url:"endCreationTime,omitempty"`
  105. }
  106. type DescribeDocProcessJobsResult struct {
  107. XMLName xml.Name `xml:"Response"`
  108. JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  109. NextToken string `xml:"NextToken,omitempty"`
  110. }
  111. // 拉取符合条件的文档预览任务 https://cloud.tencent.com/document/product/436/54096
  112. func (s *CIService) DescribeDocProcessJobs(ctx context.Context, opt *DescribeDocProcessJobsOptions) (*DescribeDocProcessJobsResult, *Response, error) {
  113. var res DescribeDocProcessJobsResult
  114. sendOpt := sendOptions{
  115. baseURL: s.client.BaseURL.CIURL,
  116. uri: "/doc_jobs",
  117. optQuery: opt,
  118. method: http.MethodGet,
  119. result: &res,
  120. }
  121. resp, err := s.client.send(ctx, &sendOpt)
  122. return &res, resp, err
  123. }
  124. type DescribeDocProcessQueuesOptions struct {
  125. QueueIds string `url:"queueIds,omitempty"`
  126. State string `url:"state,omitempty"`
  127. PageNumber int `url:"pageNumber,omitempty"`
  128. PageSize int `url:"pageSize,omitempty"`
  129. }
  130. type DescribeDocProcessQueuesResult struct {
  131. XMLName xml.Name `xml:"Response"`
  132. RequestId string `xml:"RequestId,omitempty"`
  133. TotalCount int `xml:"TotalCount,omitempty"`
  134. PageNumber int `xml:"PageNumber,omitempty"`
  135. PageSize int `xml:"PageSize,omitempty"`
  136. QueueList []DocProcessQueue `xml:"QueueList,omitempty"`
  137. NonExistPIDs []string `xml:"NonExistPIDs,omitempty"`
  138. }
  139. type DocProcessQueue struct {
  140. QueueId string `xml:"QueueId,omitempty"`
  141. Name string `xml:"Name,omitempty"`
  142. State string `xml:"State,omitempty"`
  143. MaxSize int `xml:"MaxSize,omitempty"`
  144. MaxConcurrent int `xml:"MaxConcurrent,omitempty"`
  145. UpdateTime string `xml:"UpdateTime,omitempty"`
  146. CreateTime string `xml:"CreateTime,omitempty"`
  147. NotifyConfig *DocProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  148. }
  149. type DocProcessQueueNotifyConfig struct {
  150. Url string `xml:"Url,omitempty"`
  151. State string `xml:"State,omitempty"`
  152. Type string `xml:"Type,omitempty"`
  153. Event string `xml:"Event,omitempty"`
  154. }
  155. // 查询文档预览队列 https://cloud.tencent.com/document/product/436/54055
  156. func (s *CIService) DescribeDocProcessQueues(ctx context.Context, opt *DescribeDocProcessQueuesOptions) (*DescribeDocProcessQueuesResult, *Response, error) {
  157. var res DescribeDocProcessQueuesResult
  158. sendOpt := sendOptions{
  159. baseURL: s.client.BaseURL.CIURL,
  160. uri: "/docqueue",
  161. optQuery: opt,
  162. method: http.MethodGet,
  163. result: &res,
  164. }
  165. resp, err := s.client.send(ctx, &sendOpt)
  166. return &res, resp, err
  167. }
  168. type UpdateDocProcessQueueOptions struct {
  169. XMLName xml.Name `xml:"Request"`
  170. Name string `xml:"Name,omitempty"`
  171. QueueID string `xml:"QueueID,omitempty"`
  172. State string `xml:"State,omitempty"`
  173. NotifyConfig *DocProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  174. }
  175. type UpdateDocProcessQueueResult struct {
  176. XMLName xml.Name `xml:"Response"`
  177. RequestId string `xml:"RequestId"`
  178. Queue *DocProcessQueue `xml:"Queue"`
  179. }
  180. // 更新文档预览队列 https://cloud.tencent.com/document/product/436/54094
  181. func (s *CIService) UpdateDocProcessQueue(ctx context.Context, opt *UpdateDocProcessQueueOptions) (*UpdateDocProcessQueueResult, *Response, error) {
  182. var res UpdateDocProcessQueueResult
  183. sendOpt := sendOptions{
  184. baseURL: s.client.BaseURL.CIURL,
  185. uri: "/docqueue/" + opt.QueueID,
  186. body: opt,
  187. method: http.MethodPut,
  188. result: &res,
  189. }
  190. resp, err := s.client.send(ctx, &sendOpt)
  191. return &res, resp, err
  192. }
  193. type DescribeDocProcessBucketsOptions struct {
  194. Regions string `url:"regions,omitempty"`
  195. BucketNames string `url:"bucketNames,omitempty"`
  196. BucketName string `url:"bucketName,omitempty"`
  197. PageNumber int `url:"pageNumber,omitempty"`
  198. PageSize int `url:"pageSize,omitempty"`
  199. }
  200. type DescribeDocProcessBucketsResult struct {
  201. XMLName xml.Name `xml:"Response"`
  202. RequestId string `xml:"RequestId,omitempty"`
  203. TotalCount int `xml:"TotalCount,omitempty"`
  204. PageNumber int `xml:"PageNumber,omitempty"`
  205. PageSize int `xml:"PageSize,omitempty"`
  206. DocBucketList []DocProcessBucket `xml:"DocBucketList,omitempty"`
  207. }
  208. type DocProcessBucket struct {
  209. BucketId string `xml:"BucketId,omitempty"`
  210. Name string `xml:"Name,omitempty"`
  211. Region string `xml:"Region,omitempty"`
  212. CreateTime string `xml:"CreateTime,omitempty"`
  213. AliasBucketId string `xml:"AliasBucketId,omitempty"`
  214. }
  215. // 查询文档预览开通状态 https://cloud.tencent.com/document/product/436/54057
  216. func (s *CIService) DescribeDocProcessBuckets(ctx context.Context, opt *DescribeDocProcessBucketsOptions) (*DescribeDocProcessBucketsResult, *Response, error) {
  217. var res DescribeDocProcessBucketsResult
  218. sendOpt := sendOptions{
  219. baseURL: s.client.BaseURL.CIURL,
  220. uri: "/docbucket",
  221. optQuery: opt,
  222. method: http.MethodGet,
  223. result: &res,
  224. }
  225. resp, err := s.client.send(ctx, &sendOpt)
  226. return &res, resp, err
  227. }
  228. type DocPreviewOptions struct {
  229. SrcType string `url:"srcType,omitempty"`
  230. Page int `url:"page,omitempty"`
  231. ImageParams string `url:"ImageParams,omitempty"`
  232. Sheet int `url:"sheet,omitempty"`
  233. DstType string `url:"dstType,omitempty"`
  234. Password string `url:"password,omitempty"`
  235. Comment int `url:"comment,omitempty"`
  236. ExcelPaperDirection int `url:"excelPaperDirection,omitempty"`
  237. Quality int `url:"quality,omitempty"`
  238. Zoom int `url:"zoom,omitempty"`
  239. }
  240. // 同步请求接口 https://cloud.tencent.com/document/product/436/54058
  241. func (s *CIService) DocPreview(ctx context.Context, name string, opt *DocPreviewOptions) (*Response, error) {
  242. sendOpt := sendOptions{
  243. baseURL: s.client.BaseURL.BucketURL,
  244. uri: "/" + encodeURIComponent(name) + "?ci-process=doc-preview",
  245. optQuery: opt,
  246. method: http.MethodGet,
  247. disableCloseBody: true,
  248. }
  249. resp, err := s.client.send(ctx, &sendOpt)
  250. return resp, err
  251. }