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.

271 lines
9.8 KiB

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. func (s *CIService) CreateDocProcessJobs(ctx context.Context, opt *CreateDocProcessJobsOptions) (*CreateDocProcessJobsResult, *Response, error) {
  67. var res CreateDocProcessJobsResult
  68. sendOpt := sendOptions{
  69. baseURL: s.client.BaseURL.CIURL,
  70. uri: "/doc_jobs",
  71. method: http.MethodPost,
  72. body: opt,
  73. result: &res,
  74. }
  75. resp, err := s.client.send(ctx, &sendOpt)
  76. return &res, resp, err
  77. }
  78. type DescribeDocProcessJobResult struct {
  79. XMLName xml.Name `xml:"Response"`
  80. JobsDetail *DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  81. NonExistJobIds string `xml:"NonExistJobIds,omitempty"`
  82. }
  83. func (s *CIService) DescribeDocProcessJob(ctx context.Context, jobid string) (*DescribeDocProcessJobResult, *Response, error) {
  84. var res DescribeDocProcessJobResult
  85. sendOpt := sendOptions{
  86. baseURL: s.client.BaseURL.CIURL,
  87. uri: "/doc_jobs/" + jobid,
  88. method: http.MethodGet,
  89. result: &res,
  90. }
  91. resp, err := s.client.send(ctx, &sendOpt)
  92. return &res, resp, err
  93. }
  94. type DescribeDocProcessJobsOptions struct {
  95. QueueId string `url:"queueId,omitempty"`
  96. Tag string `url:"tag,omitempty"`
  97. OrderByTime string `url:"orderByTime,omitempty"`
  98. NextToken string `url:"nextToken,omitempty"`
  99. Size int `url:"size,omitempty"`
  100. States string `url:"states,omitempty"`
  101. StartCreationTime string `url:"startCreationTime,omitempty"`
  102. EndCreationTime string `url:"endCreationTime,omitempty"`
  103. }
  104. type DescribeDocProcessJobsResult struct {
  105. XMLName xml.Name `xml:"Response"`
  106. JobsDetail []DocProcessJobDetail `xml:"JobsDetail,omitempty"`
  107. NextToken string `xml:"NextToken,omitempty"`
  108. }
  109. func (s *CIService) DescribeDocProcessJobs(ctx context.Context, opt *DescribeDocProcessJobsOptions) (*DescribeDocProcessJobsResult, *Response, error) {
  110. var res DescribeDocProcessJobsResult
  111. sendOpt := sendOptions{
  112. baseURL: s.client.BaseURL.CIURL,
  113. uri: "/doc_jobs",
  114. optQuery: opt,
  115. method: http.MethodGet,
  116. result: &res,
  117. }
  118. resp, err := s.client.send(ctx, &sendOpt)
  119. return &res, resp, err
  120. }
  121. type DescribeDocProcessQueuesOptions struct {
  122. QueueIds string `url:"queueIds,omitempty"`
  123. State string `url:"state,omitempty"`
  124. PageNumber int `url:"pageNumber,omitempty"`
  125. PageSize int `url:"pageSize,omitempty"`
  126. }
  127. type DescribeDocProcessQueuesResult struct {
  128. XMLName xml.Name `xml:"Response"`
  129. RequestId string `xml:"RequestId,omitempty"`
  130. TotalCount int `xml:"TotalCount,omitempty"`
  131. PageNumber int `xml:"PageNumber,omitempty"`
  132. PageSize int `xml:"PageSize,omitempty"`
  133. QueueList []DocProcessQueue `xml:"QueueList,omitempty"`
  134. NonExistPIDs []string `xml:"NonExistPIDs,omitempty"`
  135. }
  136. type DocProcessQueue struct {
  137. QueueId string `xml:"QueueId,omitempty"`
  138. Name string `xml:"Name,omitempty"`
  139. State string `xml:"State,omitempty"`
  140. MaxSize int `xml:"MaxSize,omitempty"`
  141. MaxConcurrent int `xml:"MaxConcurrent,omitempty"`
  142. UpdateTime string `xml:"UpdateTime,omitempty"`
  143. CreateTime string `xml:"CreateTime,omitempty"`
  144. NotifyConfig *DocProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  145. }
  146. type DocProcessQueueNotifyConfig struct {
  147. Url string `xml:"Url,omitempty"`
  148. State string `xml:"State,omitempty"`
  149. Type string `xml:"Type,omitempty"`
  150. Event string `xml:"Event,omitempty"`
  151. }
  152. func (s *CIService) DescribeDocProcessQueues(ctx context.Context, opt *DescribeDocProcessQueuesOptions) (*DescribeDocProcessQueuesResult, *Response, error) {
  153. var res DescribeDocProcessQueuesResult
  154. sendOpt := sendOptions{
  155. baseURL: s.client.BaseURL.CIURL,
  156. uri: "/docqueue",
  157. optQuery: opt,
  158. method: http.MethodGet,
  159. result: &res,
  160. }
  161. resp, err := s.client.send(ctx, &sendOpt)
  162. return &res, resp, err
  163. }
  164. type UpdateDocProcessQueueOptions struct {
  165. XMLName xml.Name `xml:"Request"`
  166. Name string `xml:"Name,omitempty"`
  167. QueueID string `xml:"QueueID,omitempty"`
  168. State string `xml:"State,omitempty"`
  169. NotifyConfig *DocProcessQueueNotifyConfig `xml:"NotifyConfig,omitempty"`
  170. }
  171. type UpdateDocProcessQueueResult struct {
  172. XMLName xml.Name `xml:"Response"`
  173. RequestId string `xml:"RequestId"`
  174. Queue *DocProcessQueue `xml:"Queue"`
  175. }
  176. func (s *CIService) UpdateDocProcessQueue(ctx context.Context, opt *UpdateDocProcessQueueOptions) (*UpdateDocProcessQueueResult, *Response, error) {
  177. var res UpdateDocProcessQueueResult
  178. sendOpt := sendOptions{
  179. baseURL: s.client.BaseURL.CIURL,
  180. uri: "/docqueue/" + opt.QueueID,
  181. body: opt,
  182. method: http.MethodPut,
  183. result: &res,
  184. }
  185. resp, err := s.client.send(ctx, &sendOpt)
  186. return &res, resp, err
  187. }
  188. type DescribeDocProcessBucketsOptions struct {
  189. Regions string `url:"regions,omitempty"`
  190. BucketNames string `url:"bucketNames,omitempty"`
  191. BucketName string `url:"bucketName,omitempty"`
  192. PageNumber int `url:"pageNumber,omitempty"`
  193. PageSize int `url:"pageSize,omitempty"`
  194. }
  195. type DescribeDocProcessBucketsResult struct {
  196. XMLName xml.Name `xml:"Response"`
  197. RequestId string `xml:"RequestId,omitempty"`
  198. TotalCount int `xml:"TotalCount,omitempty"`
  199. PageNumber int `xml:"PageNumber,omitempty"`
  200. PageSize int `xml:"PageSize,omitempty"`
  201. DocBucketList []DocProcessBucket `xml:"DocBucketList,omitempty"`
  202. }
  203. type DocProcessBucket struct {
  204. BucketId string `xml:"BucketId,omitempty"`
  205. Name string `xml:"Name,omitempty"`
  206. Region string `xml:"Region,omitempty"`
  207. CreateTime string `xml:"CreateTime,omitempty"`
  208. AliasBucketId string `xml:"AliasBucketId,omitempty"`
  209. }
  210. func (s *CIService) DescribeDocProcessBuckets(ctx context.Context, opt *DescribeDocProcessBucketsOptions) (*DescribeDocProcessBucketsResult, *Response, error) {
  211. var res DescribeDocProcessBucketsResult
  212. sendOpt := sendOptions{
  213. baseURL: s.client.BaseURL.CIURL,
  214. uri: "/docbucket",
  215. optQuery: opt,
  216. method: http.MethodGet,
  217. result: &res,
  218. }
  219. resp, err := s.client.send(ctx, &sendOpt)
  220. return &res, resp, err
  221. }
  222. type DocPreviewOptions struct {
  223. SrcType string `url:"srcType,omitempty"`
  224. Page int `url:"page,omitempty"`
  225. ImageParams string `url:"ImageParams,omitempty"`
  226. Sheet int `url:"sheet,omitempty"`
  227. DstType string `url:"dstType,omitempty"`
  228. Password string `url:"password,omitempty"`
  229. Comment int `url:"comment,omitempty"`
  230. ExcelPaperDirection int `url:"excelPaperDirection,omitempty"`
  231. Quality int `url:"quality,omitempty"`
  232. Zoom int `url:"zoom,omitempty"`
  233. }
  234. func (s *CIService) DocPreview(ctx context.Context, name string, opt *DocPreviewOptions) (*Response, error) {
  235. sendOpt := sendOptions{
  236. baseURL: s.client.BaseURL.BucketURL,
  237. uri: "/" + encodeURIComponent(name) + "?ci-process=doc-preview",
  238. optQuery: opt,
  239. method: http.MethodGet,
  240. }
  241. resp, err := s.client.send(ctx, &sendOpt)
  242. return resp, err
  243. }