cloudpdf 3.0.0.alpha.1 → 3.0.0.alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. checksums.yaml +4 -4
  2. data/.fern/metadata.json +2 -2
  3. data/README.md +5 -5
  4. data/lib/CloudPDF/client.rb +5 -0
  5. data/lib/CloudPDF/documents/client.rb +23 -6
  6. data/lib/CloudPDF/documents/types/documents_init_request.rb +2 -0
  7. data/lib/CloudPDF/documents/types/documents_init_request_upload_preference.rb +15 -0
  8. data/lib/CloudPDF/documents/types/upload_proxy_documents_request.rb +15 -0
  9. data/lib/CloudPDF/shares/client.rb +264 -0
  10. data/lib/CloudPDF/shares/types/delete_shares_request.rb +13 -0
  11. data/lib/CloudPDF/shares/types/get_shares_request.rb +13 -0
  12. data/lib/CloudPDF/shares/types/list_shares_request.rb +17 -0
  13. data/lib/CloudPDF/shares/types/shares_create_request.rb +25 -0
  14. data/lib/CloudPDF/shares/types/shares_exchange_request.rb +13 -0
  15. data/lib/CloudPDF/shares/types/shares_update_request.rb +25 -0
  16. data/lib/CloudPDF/tenants/client.rb +117 -0
  17. data/lib/CloudPDF/tenants/types/resume_tenants_request.rb +11 -0
  18. data/lib/CloudPDF/tenants/types/tenants_suspend_request.rb +13 -0
  19. data/lib/CloudPDF/tenants/types/usage_tenants_request.rb +13 -0
  20. data/lib/CloudPDF/types/doc_annotations_create400response_code.rb +1 -0
  21. data/lib/CloudPDF/types/doc_annotations_create404response_code.rb +1 -0
  22. data/lib/CloudPDF/types/doc_annotations_delete404response_code.rb +1 -0
  23. data/lib/CloudPDF/types/doc_annotations_list200response_annotations_item_caret.rb +4 -0
  24. data/lib/CloudPDF/types/doc_annotations_list200response_annotations_item_caret_unrotated_rect.rb +15 -0
  25. data/lib/CloudPDF/types/doc_annotations_list404response_code.rb +1 -0
  26. data/lib/CloudPDF/types/doc_annotations_update400response_code.rb +1 -0
  27. data/lib/CloudPDF/types/doc_annotations_update404response_code.rb +1 -0
  28. data/lib/CloudPDF/types/doc_download_response_code.rb +1 -0
  29. data/lib/CloudPDF/types/doc_forms_export_data_response_code.rb +1 -0
  30. data/lib/CloudPDF/types/doc_forms_get404response_code.rb +1 -0
  31. data/lib/CloudPDF/types/doc_forms_import_data400response_code.rb +1 -0
  32. data/lib/CloudPDF/types/doc_forms_import_data404response_code.rb +1 -0
  33. data/lib/CloudPDF/types/doc_forms_reset404response_code.rb +1 -0
  34. data/lib/CloudPDF/types/doc_forms_set_value400response_code.rb +1 -0
  35. data/lib/CloudPDF/types/doc_forms_set_value404response_code.rb +1 -0
  36. data/lib/CloudPDF/types/doc_head404response_code.rb +1 -0
  37. data/lib/CloudPDF/types/doc_manifest404response_code.rb +1 -0
  38. data/lib/CloudPDF/types/doc_metadata_get404response_code.rb +1 -0
  39. data/lib/CloudPDF/types/doc_pages_delete400response_code.rb +1 -0
  40. data/lib/CloudPDF/types/doc_pages_delete404response_code.rb +1 -0
  41. data/lib/CloudPDF/types/doc_pages_flatten400response_code.rb +1 -0
  42. data/lib/CloudPDF/types/doc_pages_flatten404response_code.rb +1 -0
  43. data/lib/CloudPDF/types/doc_pages_move400response_code.rb +1 -0
  44. data/lib/CloudPDF/types/doc_pages_move404response_code.rb +1 -0
  45. data/lib/CloudPDF/types/doc_pages_rotate400response_code.rb +1 -0
  46. data/lib/CloudPDF/types/doc_pages_rotate404response_code.rb +1 -0
  47. data/lib/CloudPDF/types/doc_redactions_apply400response_code.rb +1 -0
  48. data/lib/CloudPDF/types/doc_redactions_apply404response_code.rb +1 -0
  49. data/lib/CloudPDF/types/doc_render_response_code.rb +1 -0
  50. data/lib/CloudPDF/types/doc_text200response.rb +2 -0
  51. data/lib/CloudPDF/types/doc_text404response_code.rb +1 -0
  52. data/lib/CloudPDF/types/documents_init200response_created_upload.rb +1 -1
  53. data/lib/CloudPDF/types/{documents_init200response_created_upload_direct.rb → documents_init200response_created_upload_proxy.rb} +1 -1
  54. data/lib/CloudPDF/types/documents_init200response_resumed_upload.rb +1 -1
  55. data/lib/CloudPDF/types/{documents_init200response_resumed_upload_direct.rb → documents_init200response_resumed_upload_proxy.rb} +1 -1
  56. data/lib/CloudPDF/types/{documents_upload_direct200response.rb → documents_upload_proxy200response.rb} +1 -1
  57. data/lib/CloudPDF/types/documents_upload_proxy400response.rb +9 -0
  58. data/lib/CloudPDF/types/{documents_upload_direct400response_error.rb → documents_upload_proxy400response_error.rb} +1 -1
  59. data/lib/CloudPDF/types/documents_upload_proxy409response.rb +9 -0
  60. data/lib/CloudPDF/types/documents_upload_proxy409response_error.rb +11 -0
  61. data/lib/CloudPDF/types/engine_error_payload_code.rb +1 -0
  62. data/lib/CloudPDF/types/shares_create200response.rb +9 -0
  63. data/lib/CloudPDF/types/shares_create200response_share.rb +37 -0
  64. data/lib/CloudPDF/types/shares_create400response.rb +9 -0
  65. data/lib/CloudPDF/types/shares_create400response_error.rb +11 -0
  66. data/lib/CloudPDF/types/shares_create403response.rb +9 -0
  67. data/lib/CloudPDF/types/shares_create403response_error.rb +11 -0
  68. data/lib/CloudPDF/types/shares_create404response.rb +9 -0
  69. data/lib/CloudPDF/types/shares_create404response_error.rb +11 -0
  70. data/lib/CloudPDF/types/shares_delete_response.rb +9 -0
  71. data/lib/CloudPDF/types/shares_delete_response_error.rb +11 -0
  72. data/lib/CloudPDF/types/shares_exchange200response.rb +15 -0
  73. data/lib/CloudPDF/types/shares_exchange400response.rb +9 -0
  74. data/lib/CloudPDF/types/shares_exchange400response_error.rb +11 -0
  75. data/lib/CloudPDF/types/shares_exchange403response.rb +9 -0
  76. data/lib/CloudPDF/types/shares_exchange403response_error.rb +11 -0
  77. data/lib/CloudPDF/types/shares_exchange404response.rb +9 -0
  78. data/lib/CloudPDF/types/shares_exchange404response_error.rb +11 -0
  79. data/lib/CloudPDF/types/shares_exchange410response.rb +9 -0
  80. data/lib/CloudPDF/types/shares_exchange410response_error.rb +11 -0
  81. data/lib/CloudPDF/types/shares_exchange422response.rb +9 -0
  82. data/lib/CloudPDF/types/shares_exchange422response_error.rb +11 -0
  83. data/lib/CloudPDF/types/shares_get200response.rb +9 -0
  84. data/lib/CloudPDF/types/shares_get200response_share.rb +37 -0
  85. data/lib/CloudPDF/types/shares_get404response.rb +9 -0
  86. data/lib/CloudPDF/types/shares_get404response_error.rb +11 -0
  87. data/lib/CloudPDF/types/shares_list200response.rb +11 -0
  88. data/lib/CloudPDF/types/shares_list200response_shares_item.rb +37 -0
  89. data/lib/CloudPDF/types/shares_list400response.rb +9 -0
  90. data/lib/CloudPDF/types/shares_list400response_error.rb +11 -0
  91. data/lib/CloudPDF/types/shares_update200response.rb +9 -0
  92. data/lib/CloudPDF/types/shares_update200response_share.rb +37 -0
  93. data/lib/CloudPDF/types/shares_update400response.rb +9 -0
  94. data/lib/CloudPDF/types/shares_update400response_error.rb +11 -0
  95. data/lib/CloudPDF/types/shares_update404response.rb +9 -0
  96. data/lib/CloudPDF/types/shares_update404response_error.rb +11 -0
  97. data/lib/CloudPDF/types/tenants_create200response_tenant.rb +2 -0
  98. data/lib/CloudPDF/types/tenants_create200response_tenant_status.rb +12 -0
  99. data/lib/CloudPDF/types/tenants_get200response_tenant.rb +2 -0
  100. data/lib/CloudPDF/types/tenants_get200response_tenant_status.rb +12 -0
  101. data/lib/CloudPDF/types/tenants_list200response_tenants_item.rb +2 -0
  102. data/lib/CloudPDF/types/tenants_list200response_tenants_item_status.rb +12 -0
  103. data/lib/CloudPDF/types/tenants_resume_response.rb +9 -0
  104. data/lib/CloudPDF/types/tenants_resume_response_error.rb +11 -0
  105. data/lib/CloudPDF/types/tenants_suspend_response.rb +9 -0
  106. data/lib/CloudPDF/types/tenants_suspend_response_error.rb +11 -0
  107. data/lib/CloudPDF/types/tenants_usage200response.rb +15 -0
  108. data/lib/CloudPDF/types/tenants_usage200response_metrics.rb +13 -0
  109. data/lib/CloudPDF/types/tenants_usage400response.rb +9 -0
  110. data/lib/CloudPDF/types/tenants_usage400response_error.rb +11 -0
  111. data/lib/CloudPDF/types/tenants_usage404response.rb +9 -0
  112. data/lib/CloudPDF/types/tenants_usage404response_error.rb +11 -0
  113. data/lib/CloudPDF/types/tokens_issue_request_doc.rb +2 -0
  114. data/lib/CloudPDF/types/tokens_issue_request_tenant_scope_item_one.rb +1 -0
  115. data/lib/CloudPDF/version.rb +1 -1
  116. data/lib/cloudpdf.rb +68 -5
  117. data/reference.md +762 -0
  118. metadata +70 -7
  119. data/lib/CloudPDF/types/documents_upload_direct400response.rb +0 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7488b5cf7308ffa096afde5f8fa0bd6219ec8f4dbf2fe8cca1700671b7b83cb4
4
- data.tar.gz: afd57c62439ba51d770e0c122e0b0ef94031dd134e055ab3b8776097f033a3a5
3
+ metadata.gz: f7fdb77742ceeaefd0a0ac71e28438252a6dbfa2689eaa1eb8abbb9b28d55b04
4
+ data.tar.gz: f5c6113005f71a826485beca4913918964b4c1ae4467898ad2e2fd0cbbfa6329
5
5
  SHA512:
6
- metadata.gz: 7724b409b0a4fd39048a65c15d05305786bb36cd5c78138459bb3e118c70cac1a915a8fcb5c67120d594165b803414903a4015069cec85313c3733c1099dd73f
7
- data.tar.gz: 890779b93a00d59f7768c812ffe75f4aa0adb6c0d4bf556455b73051540ddb36d6b4eee77b6537f97e776eb5cd4034c4e74fcbcbde31525e7b8847d1b67f2ed8
6
+ metadata.gz: 15bcadf646b92f03162188b682a9954d8526934cc03f071f541b725243e9e02159852e4a6bd889770998699f44c1ec1b72c58a9ea216cac62fd5665d8955b210
7
+ data.tar.gz: d3d4ba66658252c98ba21f90ed485c782fbaffffe0a1a60bfa201452b1fc0e65aa9b6cdfd91c82e6b5226399aea5cc26d548ebf930354df1ee586dbb826409d4
data/.fern/metadata.json CHANGED
@@ -5,9 +5,9 @@
5
5
  "generatorConfig": {
6
6
  "moduleName": "CloudPDF"
7
7
  },
8
- "originGitCommit": "a0adb9e77ef16feaef2358d71b247b4f5a98fd23",
8
+ "originGitCommit": "81e6a2097d2997ef713a3013668e5eae0e748575",
9
9
  "originGitCommitIsDirty": false,
10
10
  "invokedBy": "ci",
11
- "requestedVersion": "3.0.0.alpha.1",
11
+ "requestedVersion": "3.0.0.alpha.5",
12
12
  "ciProvider": "github"
13
13
  }
data/README.md CHANGED
@@ -30,7 +30,7 @@ require "cloudpdf"
30
30
 
31
31
  client = CloudPDF::Client.new(token: "<token>")
32
32
 
33
- client.tenants.create(id: "id")
33
+ client.shares.exchange(share_token: "shareToken")
34
34
  ```
35
35
 
36
36
  ## Environments
@@ -58,7 +58,7 @@ client = CloudPDF::Client.new(
58
58
  )
59
59
 
60
60
  begin
61
- result = client.tenants.create
61
+ result = client.shares.exchange
62
62
  rescue CloudPDF::Errors::TimeoutError
63
63
  puts "API didn't respond before our timeout elapsed"
64
64
  rescue CloudPDF::Errors::ServiceUnavailableError
@@ -108,7 +108,7 @@ The SDK defaults to a 60 second timeout. Use the `timeout` option to configure t
108
108
  ```ruby
109
109
  require "cloudpdf"
110
110
 
111
- response = client.tenants.create(
111
+ response = client.shares.exchange(
112
112
  ...,
113
113
  timeout: 30 # 30 second timeout
114
114
  )
@@ -121,7 +121,7 @@ If you would like to send additional headers as part of the request, use the `ad
121
121
  ```ruby
122
122
  require "cloudpdf"
123
123
 
124
- response = client.tenants.create(
124
+ response = client.shares.exchange(
125
125
  ...,
126
126
  request_options: {
127
127
  additional_headers: {
@@ -138,7 +138,7 @@ If you would like to send additional query parameters as part of the request, us
138
138
  ```ruby
139
139
  require "cloudpdf"
140
140
 
141
- response = client.tenants.create(
141
+ response = client.shares.exchange(
142
142
  ...,
143
143
  request_options: {
144
144
  additional_query_parameters: {
@@ -28,6 +28,11 @@ module CloudPDF
28
28
  @doc ||= CloudPDF::Doc::Client.new(client: @raw_client)
29
29
  end
30
30
 
31
+ # @return [CloudPDF::Shares::Client]
32
+ def shares
33
+ @shares ||= CloudPDF::Shares::Client.new(client: @raw_client)
34
+ end
35
+
31
36
  # @return [CloudPDF::Tenants::Client]
32
37
  def tenants
33
38
  @tenants ||= CloudPDF::Tenants::Client.new(client: @raw_client)
@@ -249,8 +249,11 @@ module CloudPDF
249
249
  raise error_class.new(response.body, code: code)
250
250
  end
251
251
 
252
+ # This bounded origin-mediated fallback must only be used after documents.init returns upload.kind=proxy. Auto
253
+ # mode prefers a presigned object-store PUT whenever available.
254
+ #
252
255
  # @param request_options [Hash]
253
- # @param params [Hash]
256
+ # @param params [void]
254
257
  # @option request_options [String] :base_url
255
258
  # @option request_options [Hash{String => Object}] :additional_headers
256
259
  # @option request_options [Hash{String => Object}] :additional_query_parameters
@@ -258,14 +261,28 @@ module CloudPDF
258
261
  # @option request_options [Integer] :timeout_in_seconds
259
262
  # @option params [String] :tenant_id
260
263
  # @option params [String] :id
264
+ # @option params [#read] :file
261
265
  #
262
- # @return [CloudPDF::Types::DocumentsUploadDirect200Response]
263
- def upload_direct(request_options: {}, **params)
266
+ # @example
267
+ # client.documents.upload_proxy(
268
+ # tenant_id: "tenantId",
269
+ # id: "id",
270
+ # file: File.open("document.pdf", "rb")
271
+ # )
272
+ #
273
+ # @return [CloudPDF::Types::DocumentsUploadProxy200Response]
274
+ def upload_proxy(request_options: {}, **params)
264
275
  params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
265
- request = CloudPDF::Internal::JSON::Request.new(
276
+ body = Internal::Multipart::FormData.new
277
+
278
+ raise ArgumentError, "file is required" unless params[:file]
279
+ body.add_file(name: "file", file: params[:file], content_type: "application/pdf")
280
+
281
+ request = CloudPDF::Internal::Multipart::Request.new(
266
282
  base_url: request_options[:base_url],
267
283
  method: "POST",
268
- path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/documents/#{URI.encode_uri_component(params[:id].to_s)}/upload-direct",
284
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/documents/#{URI.encode_uri_component(params[:id].to_s)}/upload-proxy",
285
+ body: body,
269
286
  request_options: request_options
270
287
  )
271
288
  begin
@@ -275,7 +292,7 @@ module CloudPDF
275
292
  end
276
293
  code = response.code.to_i
277
294
  if code.between?(200, 299)
278
- CloudPDF::Types::DocumentsUploadDirect200Response.load(response.body)
295
+ CloudPDF::Types::DocumentsUploadProxy200Response.load(response.body)
279
296
  else
280
297
  error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
281
298
  raise error_class.new(response.body, code: code)
@@ -19,6 +19,8 @@ module CloudPDF
19
19
  field :doc_id, -> { String }, optional: true, nullable: false, api_name: "docId"
20
20
 
21
21
  field :upload_ttl_sec, -> { Integer }, optional: true, nullable: false, api_name: "uploadTtlSec"
22
+
23
+ field :upload_preference, -> { CloudPDF::Documents::Types::DocumentsInitRequestUploadPreference }, optional: true, nullable: false, api_name: "uploadPreference"
22
24
  end
23
25
  end
24
26
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Documents
5
+ module Types
6
+ module DocumentsInitRequestUploadPreference
7
+ extend CloudPDF::Internal::Types::Enum
8
+
9
+ AUTO = "auto"
10
+ PRESIGNED = "presigned"
11
+ PROXY = "proxy"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Documents
5
+ module Types
6
+ class UploadProxyDocumentsRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :id, -> { String }, optional: false, nullable: false
10
+
11
+ field :file, -> { Object }, optional: false, nullable: false
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,264 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ class Client
6
+ # @param client [CloudPDF::Internal::Http::RawClient]
7
+ #
8
+ # @return [void]
9
+ def initialize(client:)
10
+ @client = client
11
+ end
12
+
13
+ # Unauthenticated, but requires a browser Origin header, checked against the grant allowlist. Unknown, revoked,
14
+ # and disabled tokens are indistinguishable (404). Passphrase-protected grants return 422 SharePasswordRequired
15
+ # until `password` is supplied. Mounted only when the deployment can sign (HS256 mode).
16
+ #
17
+ # @param request_options [Hash]
18
+ # @param params [CloudPDF::Shares::Types::SharesExchangeRequest]
19
+ # @option request_options [String] :base_url
20
+ # @option request_options [Hash{String => Object}] :additional_headers
21
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
22
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
23
+ # @option request_options [Integer] :timeout_in_seconds
24
+ #
25
+ # @example
26
+ # client.shares.exchange(share_token: "shareToken")
27
+ #
28
+ # @return [CloudPDF::Types::SharesExchange200Response]
29
+ def exchange(request_options: {}, **params)
30
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
31
+ request = CloudPDF::Internal::JSON::Request.new(
32
+ base_url: request_options[:base_url],
33
+ method: "POST",
34
+ path: "v1/share-sessions",
35
+ body: CloudPDF::Shares::Types::SharesExchangeRequest.new(params).to_h,
36
+ request_options: request_options
37
+ )
38
+ begin
39
+ response = @client.send(request)
40
+ rescue Net::HTTPRequestTimeout
41
+ raise CloudPDF::Errors::TimeoutError
42
+ end
43
+ code = response.code.to_i
44
+ if code.between?(200, 299)
45
+ CloudPDF::Types::SharesExchange200Response.load(response.body)
46
+ else
47
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
48
+ raise error_class.new(response.body, code: code)
49
+ end
50
+ end
51
+
52
+ # @param request_options [Hash]
53
+ # @param params [Hash]
54
+ # @option request_options [String] :base_url
55
+ # @option request_options [Hash{String => Object}] :additional_headers
56
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
57
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
58
+ # @option request_options [Integer] :timeout_in_seconds
59
+ # @option params [String] :tenant_id
60
+ # @option params [Integer, nil] :limit
61
+ # @option params [String, nil] :cursor
62
+ # @option params [String, nil] :doc_id
63
+ #
64
+ # @example
65
+ # client.shares.list(tenant_id: "tenantId")
66
+ #
67
+ # @return [CloudPDF::Types::SharesList200Response]
68
+ def list(request_options: {}, **params)
69
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
70
+ query_params = {}
71
+ query_params["limit"] = params[:limit] if params.key?(:limit)
72
+ query_params["cursor"] = params[:cursor] if params.key?(:cursor)
73
+ query_params["docId"] = params[:doc_id] if params.key?(:doc_id)
74
+
75
+ request = CloudPDF::Internal::JSON::Request.new(
76
+ base_url: request_options[:base_url],
77
+ method: "GET",
78
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/shares",
79
+ query: query_params,
80
+ request_options: request_options
81
+ )
82
+ begin
83
+ response = @client.send(request)
84
+ rescue Net::HTTPRequestTimeout
85
+ raise CloudPDF::Errors::TimeoutError
86
+ end
87
+ code = response.code.to_i
88
+ if code.between?(200, 299)
89
+ CloudPDF::Types::SharesList200Response.load(response.body)
90
+ else
91
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
92
+ raise error_class.new(response.body, code: code)
93
+ end
94
+ end
95
+
96
+ # The returned share id IS the public share token. Mounted only when the deployment can sign (HS256 mode) —
97
+ # exchange mints session JWTs, so grants exist only where minting does.
98
+ #
99
+ # @param request_options [Hash]
100
+ # @param params [CloudPDF::Shares::Types::SharesCreateRequest]
101
+ # @option request_options [String] :base_url
102
+ # @option request_options [Hash{String => Object}] :additional_headers
103
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
104
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
105
+ # @option request_options [Integer] :timeout_in_seconds
106
+ # @option params [String] :tenant_id
107
+ #
108
+ # @example
109
+ # client.shares.create(
110
+ # tenant_id: "tenantId",
111
+ # doc_id: "docId",
112
+ # scope: ["scope"]
113
+ # )
114
+ #
115
+ # @return [CloudPDF::Types::SharesCreate200Response]
116
+ def create(request_options: {}, **params)
117
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
118
+ request_data = CloudPDF::Shares::Types::SharesCreateRequest.new(params).to_h
119
+ non_body_param_names = %w[tenantId]
120
+ body = request_data.except(*non_body_param_names)
121
+
122
+ request = CloudPDF::Internal::JSON::Request.new(
123
+ base_url: request_options[:base_url],
124
+ method: "POST",
125
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/shares",
126
+ body: body,
127
+ request_options: request_options
128
+ )
129
+ begin
130
+ response = @client.send(request)
131
+ rescue Net::HTTPRequestTimeout
132
+ raise CloudPDF::Errors::TimeoutError
133
+ end
134
+ code = response.code.to_i
135
+ if code.between?(200, 299)
136
+ CloudPDF::Types::SharesCreate200Response.load(response.body)
137
+ else
138
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
139
+ raise error_class.new(response.body, code: code)
140
+ end
141
+ end
142
+
143
+ # @param request_options [Hash]
144
+ # @param params [Hash]
145
+ # @option request_options [String] :base_url
146
+ # @option request_options [Hash{String => Object}] :additional_headers
147
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
148
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
149
+ # @option request_options [Integer] :timeout_in_seconds
150
+ # @option params [String] :tenant_id
151
+ # @option params [String] :share_id
152
+ #
153
+ # @example
154
+ # client.shares.get(
155
+ # tenant_id: "tenantId",
156
+ # share_id: "shareId"
157
+ # )
158
+ #
159
+ # @return [CloudPDF::Types::SharesGet200Response]
160
+ def get(request_options: {}, **params)
161
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
162
+ request = CloudPDF::Internal::JSON::Request.new(
163
+ base_url: request_options[:base_url],
164
+ method: "GET",
165
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/shares/#{URI.encode_uri_component(params[:share_id].to_s)}",
166
+ request_options: request_options
167
+ )
168
+ begin
169
+ response = @client.send(request)
170
+ rescue Net::HTTPRequestTimeout
171
+ raise CloudPDF::Errors::TimeoutError
172
+ end
173
+ code = response.code.to_i
174
+ if code.between?(200, 299)
175
+ CloudPDF::Types::SharesGet200Response.load(response.body)
176
+ else
177
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
178
+ raise error_class.new(response.body, code: code)
179
+ end
180
+ end
181
+
182
+ # @param request_options [Hash]
183
+ # @param params [Hash]
184
+ # @option request_options [String] :base_url
185
+ # @option request_options [Hash{String => Object}] :additional_headers
186
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
187
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
188
+ # @option request_options [Integer] :timeout_in_seconds
189
+ # @option params [String] :tenant_id
190
+ # @option params [String] :share_id
191
+ #
192
+ # @example
193
+ # client.shares.delete(
194
+ # tenant_id: "tenantId",
195
+ # share_id: "shareId"
196
+ # )
197
+ #
198
+ # @return [untyped]
199
+ def delete(request_options: {}, **params)
200
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
201
+ request = CloudPDF::Internal::JSON::Request.new(
202
+ base_url: request_options[:base_url],
203
+ method: "DELETE",
204
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/shares/#{URI.encode_uri_component(params[:share_id].to_s)}",
205
+ request_options: request_options
206
+ )
207
+ begin
208
+ response = @client.send(request)
209
+ rescue Net::HTTPRequestTimeout
210
+ raise CloudPDF::Errors::TimeoutError
211
+ end
212
+ code = response.code.to_i
213
+ return if code.between?(200, 299)
214
+
215
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
216
+ raise error_class.new(response.body, code: code)
217
+ end
218
+
219
+ # @param request_options [Hash]
220
+ # @param params [CloudPDF::Shares::Types::SharesUpdateRequest]
221
+ # @option request_options [String] :base_url
222
+ # @option request_options [Hash{String => Object}] :additional_headers
223
+ # @option request_options [Hash{String => Object}] :additional_query_parameters
224
+ # @option request_options [Hash{String => Object}] :additional_body_parameters
225
+ # @option request_options [Integer] :timeout_in_seconds
226
+ # @option params [String] :tenant_id
227
+ # @option params [String] :share_id
228
+ #
229
+ # @example
230
+ # client.shares.update(
231
+ # tenant_id: "tenantId",
232
+ # share_id: "shareId"
233
+ # )
234
+ #
235
+ # @return [CloudPDF::Types::SharesUpdate200Response]
236
+ def update(request_options: {}, **params)
237
+ params = CloudPDF::Internal::Types::Utils.normalize_keys(params)
238
+ request_data = CloudPDF::Shares::Types::SharesUpdateRequest.new(params).to_h
239
+ non_body_param_names = %w[tenantId shareId]
240
+ body = request_data.except(*non_body_param_names)
241
+
242
+ request = CloudPDF::Internal::JSON::Request.new(
243
+ base_url: request_options[:base_url],
244
+ method: "PATCH",
245
+ path: "v1/tenants/#{URI.encode_uri_component(params[:tenant_id].to_s)}/shares/#{URI.encode_uri_component(params[:share_id].to_s)}",
246
+ body: body,
247
+ request_options: request_options
248
+ )
249
+ begin
250
+ response = @client.send(request)
251
+ rescue Net::HTTPRequestTimeout
252
+ raise CloudPDF::Errors::TimeoutError
253
+ end
254
+ code = response.code.to_i
255
+ if code.between?(200, 299)
256
+ CloudPDF::Types::SharesUpdate200Response.load(response.body)
257
+ else
258
+ error_class = CloudPDF::Errors::ResponseError.subclass_for_code(code)
259
+ raise error_class.new(response.body, code: code)
260
+ end
261
+ end
262
+ end
263
+ end
264
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class DeleteSharesRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :share_id, -> { String }, optional: false, nullable: false, api_name: "shareId"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class GetSharesRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :share_id, -> { String }, optional: false, nullable: false, api_name: "shareId"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class ListSharesRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :limit, -> { Integer }, optional: true, nullable: false
10
+
11
+ field :cursor, -> { String }, optional: true, nullable: false
12
+
13
+ field :doc_id, -> { String }, optional: true, nullable: false, api_name: "docId"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class SharesCreateRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :doc_id, -> { String }, optional: false, nullable: false, api_name: "docId"
10
+
11
+ field :layer_name, -> { String }, optional: true, nullable: false, api_name: "layerName"
12
+
13
+ field :scope, -> { Internal::Types::Array[String] }, optional: false, nullable: false
14
+
15
+ field :origins, -> { Internal::Types::Array[String] }, optional: true, nullable: false
16
+
17
+ field :password, -> { String }, optional: true, nullable: false
18
+
19
+ field :session_ttl_seconds, -> { Integer }, optional: true, nullable: false, api_name: "sessionTtlSeconds"
20
+
21
+ field :expires_at, -> { Integer }, optional: true, nullable: false, api_name: "expiresAt"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class SharesExchangeRequest < Internal::Types::Model
7
+ field :share_token, -> { String }, optional: false, nullable: false, api_name: "shareToken"
8
+
9
+ field :password, -> { String }, optional: true, nullable: false
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CloudPDF
4
+ module Shares
5
+ module Types
6
+ class SharesUpdateRequest < Internal::Types::Model
7
+ field :tenant_id, -> { String }, optional: false, nullable: false, api_name: "tenantId"
8
+
9
+ field :share_id, -> { String }, optional: false, nullable: false, api_name: "shareId"
10
+
11
+ field :scope, -> { Internal::Types::Array[String] }, optional: true, nullable: false
12
+
13
+ field :origins, -> { Internal::Types::Array[String] }, optional: true, nullable: false
14
+
15
+ field :password, -> { String }, optional: true, nullable: false
16
+
17
+ field :session_ttl_seconds, -> { Integer }, optional: true, nullable: false, api_name: "sessionTtlSeconds"
18
+
19
+ field :disabled, -> { Internal::Types::Boolean }, optional: true, nullable: false
20
+
21
+ field :expires_at, -> { Integer }, optional: true, nullable: false, api_name: "expiresAt"
22
+ end
23
+ end
24
+ end
25
+ end