nft_storage 1.0.0

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 (67) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +68 -0
  4. data/README.md +118 -0
  5. data/Rakefile +10 -0
  6. data/docs/Deal.md +36 -0
  7. data/docs/DeleteResponse.md +18 -0
  8. data/docs/ErrorResponse.md +20 -0
  9. data/docs/ErrorResponseError.md +20 -0
  10. data/docs/ForbiddenErrorResponse.md +20 -0
  11. data/docs/ForbiddenErrorResponseError.md +20 -0
  12. data/docs/GetResponse.md +20 -0
  13. data/docs/Links.md +22 -0
  14. data/docs/LinksFile.md +20 -0
  15. data/docs/ListResponse.md +20 -0
  16. data/docs/NFT.md +32 -0
  17. data/docs/NFTStorageAPI.md +289 -0
  18. data/docs/Pin.md +26 -0
  19. data/docs/PinStatus.md +15 -0
  20. data/docs/UnauthorizedErrorResponse.md +20 -0
  21. data/docs/UnauthorizedErrorResponseError.md +20 -0
  22. data/docs/UploadResponse.md +20 -0
  23. data/git_push.sh +58 -0
  24. data/lib/nft_storage/api/nft_storage_api.rb +282 -0
  25. data/lib/nft_storage/api_client.rb +390 -0
  26. data/lib/nft_storage/api_error.rb +57 -0
  27. data/lib/nft_storage/configuration.rb +278 -0
  28. data/lib/nft_storage/models/deal.rb +364 -0
  29. data/lib/nft_storage/models/delete_response.rb +218 -0
  30. data/lib/nft_storage/models/error_response.rb +229 -0
  31. data/lib/nft_storage/models/error_response_error.rb +227 -0
  32. data/lib/nft_storage/models/forbidden_error_response.rb +229 -0
  33. data/lib/nft_storage/models/forbidden_error_response_error.rb +263 -0
  34. data/lib/nft_storage/models/get_response.rb +229 -0
  35. data/lib/nft_storage/models/links.rb +238 -0
  36. data/lib/nft_storage/models/links_file.rb +227 -0
  37. data/lib/nft_storage/models/list_response.rb +231 -0
  38. data/lib/nft_storage/models/nft.rb +329 -0
  39. data/lib/nft_storage/models/pin.rb +256 -0
  40. data/lib/nft_storage/models/pin_status.rb +39 -0
  41. data/lib/nft_storage/models/unauthorized_error_response.rb +229 -0
  42. data/lib/nft_storage/models/unauthorized_error_response_error.rb +231 -0
  43. data/lib/nft_storage/models/upload_response.rb +229 -0
  44. data/lib/nft_storage/version.rb +15 -0
  45. data/lib/nft_storage.rb +56 -0
  46. data/nft_storage.gemspec +38 -0
  47. data/spec/api/nft_storage_api_spec.rb +83 -0
  48. data/spec/api_client_spec.rb +226 -0
  49. data/spec/configuration_spec.rb +42 -0
  50. data/spec/models/deal_spec.rb +96 -0
  51. data/spec/models/delete_response_spec.rb +34 -0
  52. data/spec/models/error_response_error_spec.rb +40 -0
  53. data/spec/models/error_response_spec.rb +40 -0
  54. data/spec/models/forbidden_error_response_error_spec.rb +44 -0
  55. data/spec/models/forbidden_error_response_spec.rb +40 -0
  56. data/spec/models/get_response_spec.rb +40 -0
  57. data/spec/models/links_file_spec.rb +40 -0
  58. data/spec/models/links_spec.rb +46 -0
  59. data/spec/models/list_response_spec.rb +40 -0
  60. data/spec/models/nft_spec.rb +80 -0
  61. data/spec/models/pin_spec.rb +58 -0
  62. data/spec/models/pin_status_spec.rb +28 -0
  63. data/spec/models/unauthorized_error_response_error_spec.rb +40 -0
  64. data/spec/models/unauthorized_error_response_spec.rb +40 -0
  65. data/spec/models/upload_response_spec.rb +40 -0
  66. data/spec/spec_helper.rb +111 -0
  67. metadata +168 -0
@@ -0,0 +1,289 @@
1
+ # NFTStorage::NFTStorageAPI
2
+
3
+ All URIs are relative to *https://api.nft.storage*
4
+
5
+ | Method | HTTP request | Description |
6
+ | ------ | ------------ | ----------- |
7
+ | [**delete**](NFTStorageAPI.md#delete) | **DELETE** /{cid} | Stop storing the content with the passed CID |
8
+ | [**list**](NFTStorageAPI.md#list) | **GET** / | List all stored files |
9
+ | [**status**](NFTStorageAPI.md#status) | **GET** /{cid} | Get information for the stored file CID |
10
+ | [**store**](NFTStorageAPI.md#store) | **POST** /upload | Store a file |
11
+
12
+
13
+ ## delete
14
+
15
+ > <DeleteResponse> delete(cid)
16
+
17
+ Stop storing the content with the passed CID
18
+
19
+ Stop storing the content with the passed CID on nft.storage. - Unpin the item from the underlying IPFS pinning service. - Cease renewals for expired Filecoin deals involving the CID. ⚠️ This does not remove the content from the network. - Does not terminate any established Filecoin deal. - Does not remove the content from other IPFS nodes in the network that already cached or pinned the CID. Note: the content will remain available if another user has stored the CID with nft.storage.
20
+
21
+ ### Examples
22
+
23
+ ```ruby
24
+ require 'time'
25
+ require 'nft_storage'
26
+ # setup authorization
27
+ NFTStorage.configure do |config|
28
+ # Configure Bearer authorization (JWT): bearerAuth
29
+ config.access_token = 'YOUR_BEARER_TOKEN'
30
+ end
31
+
32
+ api_instance = NFTStorage::NFTStorageAPI.new
33
+ cid = 'cid_example' # String | CID for the NFT
34
+
35
+ begin
36
+ # Stop storing the content with the passed CID
37
+ result = api_instance.delete(cid)
38
+ p result
39
+ rescue NFTStorage::ApiError => e
40
+ puts "Error when calling NFTStorageAPI->delete: #{e}"
41
+ end
42
+ ```
43
+
44
+ #### Using the delete_with_http_info variant
45
+
46
+ This returns an Array which contains the response data, status code and headers.
47
+
48
+ > <Array(<DeleteResponse>, Integer, Hash)> delete_with_http_info(cid)
49
+
50
+ ```ruby
51
+ begin
52
+ # Stop storing the content with the passed CID
53
+ data, status_code, headers = api_instance.delete_with_http_info(cid)
54
+ p status_code # => 2xx
55
+ p headers # => { ... }
56
+ p data # => <DeleteResponse>
57
+ rescue NFTStorage::ApiError => e
58
+ puts "Error when calling NFTStorageAPI->delete_with_http_info: #{e}"
59
+ end
60
+ ```
61
+
62
+ ### Parameters
63
+
64
+ | Name | Type | Description | Notes |
65
+ | ---- | ---- | ----------- | ----- |
66
+ | **cid** | **String** | CID for the NFT | |
67
+
68
+ ### Return type
69
+
70
+ [**DeleteResponse**](DeleteResponse.md)
71
+
72
+ ### Authorization
73
+
74
+ [bearerAuth](../README.md#bearerAuth)
75
+
76
+ ### HTTP request headers
77
+
78
+ - **Content-Type**: Not defined
79
+ - **Accept**: application/json
80
+
81
+
82
+ ## list
83
+
84
+ > <ListResponse> list(opts)
85
+
86
+ List all stored files
87
+
88
+ ### Examples
89
+
90
+ ```ruby
91
+ require 'time'
92
+ require 'nft_storage'
93
+ # setup authorization
94
+ NFTStorage.configure do |config|
95
+ # Configure Bearer authorization (JWT): bearerAuth
96
+ config.access_token = 'YOUR_BEARER_TOKEN'
97
+ end
98
+
99
+ api_instance = NFTStorage::NFTStorageAPI.new
100
+ opts = {
101
+ before: Time.parse('2020-07-27T17:32:28Z'), # Time | Return results created before provided timestamp
102
+ limit: 56 # Integer | Max records to return
103
+ }
104
+
105
+ begin
106
+ # List all stored files
107
+ result = api_instance.list(opts)
108
+ p result
109
+ rescue NFTStorage::ApiError => e
110
+ puts "Error when calling NFTStorageAPI->list: #{e}"
111
+ end
112
+ ```
113
+
114
+ #### Using the list_with_http_info variant
115
+
116
+ This returns an Array which contains the response data, status code and headers.
117
+
118
+ > <Array(<ListResponse>, Integer, Hash)> list_with_http_info(opts)
119
+
120
+ ```ruby
121
+ begin
122
+ # List all stored files
123
+ data, status_code, headers = api_instance.list_with_http_info(opts)
124
+ p status_code # => 2xx
125
+ p headers # => { ... }
126
+ p data # => <ListResponse>
127
+ rescue NFTStorage::ApiError => e
128
+ puts "Error when calling NFTStorageAPI->list_with_http_info: #{e}"
129
+ end
130
+ ```
131
+
132
+ ### Parameters
133
+
134
+ | Name | Type | Description | Notes |
135
+ | ---- | ---- | ----------- | ----- |
136
+ | **before** | **Time** | Return results created before provided timestamp | [optional] |
137
+ | **limit** | **Integer** | Max records to return | [optional][default to 10] |
138
+
139
+ ### Return type
140
+
141
+ [**ListResponse**](ListResponse.md)
142
+
143
+ ### Authorization
144
+
145
+ [bearerAuth](../README.md#bearerAuth)
146
+
147
+ ### HTTP request headers
148
+
149
+ - **Content-Type**: Not defined
150
+ - **Accept**: application/json
151
+
152
+
153
+ ## status
154
+
155
+ > <GetResponse> status(cid)
156
+
157
+ Get information for the stored file CID
158
+
159
+ Includes the IPFS pinning state and the Filecoin deal state.
160
+
161
+ ### Examples
162
+
163
+ ```ruby
164
+ require 'time'
165
+ require 'nft_storage'
166
+ # setup authorization
167
+ NFTStorage.configure do |config|
168
+ # Configure Bearer authorization (JWT): bearerAuth
169
+ config.access_token = 'YOUR_BEARER_TOKEN'
170
+ end
171
+
172
+ api_instance = NFTStorage::NFTStorageAPI.new
173
+ cid = 'cid_example' # String | CID for the NFT
174
+
175
+ begin
176
+ # Get information for the stored file CID
177
+ result = api_instance.status(cid)
178
+ p result
179
+ rescue NFTStorage::ApiError => e
180
+ puts "Error when calling NFTStorageAPI->status: #{e}"
181
+ end
182
+ ```
183
+
184
+ #### Using the status_with_http_info variant
185
+
186
+ This returns an Array which contains the response data, status code and headers.
187
+
188
+ > <Array(<GetResponse>, Integer, Hash)> status_with_http_info(cid)
189
+
190
+ ```ruby
191
+ begin
192
+ # Get information for the stored file CID
193
+ data, status_code, headers = api_instance.status_with_http_info(cid)
194
+ p status_code # => 2xx
195
+ p headers # => { ... }
196
+ p data # => <GetResponse>
197
+ rescue NFTStorage::ApiError => e
198
+ puts "Error when calling NFTStorageAPI->status_with_http_info: #{e}"
199
+ end
200
+ ```
201
+
202
+ ### Parameters
203
+
204
+ | Name | Type | Description | Notes |
205
+ | ---- | ---- | ----------- | ----- |
206
+ | **cid** | **String** | CID for the NFT | |
207
+
208
+ ### Return type
209
+
210
+ [**GetResponse**](GetResponse.md)
211
+
212
+ ### Authorization
213
+
214
+ [bearerAuth](../README.md#bearerAuth)
215
+
216
+ ### HTTP request headers
217
+
218
+ - **Content-Type**: Not defined
219
+ - **Accept**: application/json
220
+
221
+
222
+ ## store
223
+
224
+ > <UploadResponse> store(body)
225
+
226
+ Store a file
227
+
228
+ Store a file with nft.storage. - Submit a HTTP `POST` request passing the file data in the request body. - To store multiple files in a directory, submit a `multipart/form-data` HTTP `POST` request. Use the `Content-Disposition` header for each part to specify a filename.
229
+
230
+ ### Examples
231
+
232
+ ```ruby
233
+ require 'time'
234
+ require 'nft_storage'
235
+ # setup authorization
236
+ NFTStorage.configure do |config|
237
+ # Configure Bearer authorization (JWT): bearerAuth
238
+ config.access_token = 'YOUR_BEARER_TOKEN'
239
+ end
240
+
241
+ api_instance = NFTStorage::NFTStorageAPI.new
242
+ body = File.new('/path/to/some/file') # File |
243
+
244
+ begin
245
+ # Store a file
246
+ result = api_instance.store(body)
247
+ p result
248
+ rescue NFTStorage::ApiError => e
249
+ puts "Error when calling NFTStorageAPI->store: #{e}"
250
+ end
251
+ ```
252
+
253
+ #### Using the store_with_http_info variant
254
+
255
+ This returns an Array which contains the response data, status code and headers.
256
+
257
+ > <Array(<UploadResponse>, Integer, Hash)> store_with_http_info(body)
258
+
259
+ ```ruby
260
+ begin
261
+ # Store a file
262
+ data, status_code, headers = api_instance.store_with_http_info(body)
263
+ p status_code # => 2xx
264
+ p headers # => { ... }
265
+ p data # => <UploadResponse>
266
+ rescue NFTStorage::ApiError => e
267
+ puts "Error when calling NFTStorageAPI->store_with_http_info: #{e}"
268
+ end
269
+ ```
270
+
271
+ ### Parameters
272
+
273
+ | Name | Type | Description | Notes |
274
+ | ---- | ---- | ----------- | ----- |
275
+ | **body** | **File** | | |
276
+
277
+ ### Return type
278
+
279
+ [**UploadResponse**](UploadResponse.md)
280
+
281
+ ### Authorization
282
+
283
+ [bearerAuth](../README.md#bearerAuth)
284
+
285
+ ### HTTP request headers
286
+
287
+ - **Content-Type**: image/png, application/octet-stream, multipart/form-data
288
+ - **Accept**: application/json
289
+
data/docs/Pin.md ADDED
@@ -0,0 +1,26 @@
1
+ # NFTStorage::Pin
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **cid** | **String** | Self-describing content-addressed identifiers for distributed systems. Check [spec](https://github.com/multiformats/cid) for more info. | [optional] |
8
+ | **name** | **String** | | [optional] |
9
+ | **status** | [**PinStatus**](PinStatus.md) | | [optional] |
10
+ | **created** | **Time** | This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: YYYY-MM-DDTHH:MM:SSZ. | [optional] |
11
+ | **size** | **Float** | | [optional] |
12
+
13
+ ## Example
14
+
15
+ ```ruby
16
+ require 'nft_storage'
17
+
18
+ instance = NFTStorage::Pin.new(
19
+ cid: bafkreidivzimqfqtoqxkrpge6bjyhlvxqs3rhe73owtmdulaxr5do5in7u,
20
+ name: pin name,
21
+ status: null,
22
+ created: 2021-03-12T17:03:07.787Z,
23
+ size: 132614
24
+ )
25
+ ```
26
+
data/docs/PinStatus.md ADDED
@@ -0,0 +1,15 @@
1
+ # NFTStorage::PinStatus
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+
8
+ ## Example
9
+
10
+ ```ruby
11
+ require 'nft_storage'
12
+
13
+ instance = NFTStorage::PinStatus.new()
14
+ ```
15
+
@@ -0,0 +1,20 @@
1
+ # NFTStorage::UnauthorizedErrorResponse
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **ok** | **Boolean** | | [optional][default to false] |
8
+ | **error** | [**UnauthorizedErrorResponseError**](UnauthorizedErrorResponseError.md) | | [optional] |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'nft_storage'
14
+
15
+ instance = NFTStorage::UnauthorizedErrorResponse.new(
16
+ ok: null,
17
+ error: null
18
+ )
19
+ ```
20
+
@@ -0,0 +1,20 @@
1
+ # NFTStorage::UnauthorizedErrorResponseError
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **name** | **String** | | [optional][default to &#39;HTTP Error&#39;] |
8
+ | **message** | **String** | | [optional][default to &#39;Unauthorized&#39;] |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'nft_storage'
14
+
15
+ instance = NFTStorage::UnauthorizedErrorResponseError.new(
16
+ name: null,
17
+ message: null
18
+ )
19
+ ```
20
+
@@ -0,0 +1,20 @@
1
+ # NFTStorage::UploadResponse
2
+
3
+ ## Properties
4
+
5
+ | Name | Type | Description | Notes |
6
+ | ---- | ---- | ----------- | ----- |
7
+ | **ok** | **Boolean** | | [optional][default to true] |
8
+ | **value** | [**NFT**](NFT.md) | | [optional] |
9
+
10
+ ## Example
11
+
12
+ ```ruby
13
+ require 'nft_storage'
14
+
15
+ instance = NFTStorage::UploadResponse.new(
16
+ ok: null,
17
+ value: null
18
+ )
19
+ ```
20
+
data/git_push.sh ADDED
@@ -0,0 +1,58 @@
1
+ #!/bin/sh
2
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
+ #
4
+ # Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com"
5
+
6
+ git_user_id=$1
7
+ git_repo_id=$2
8
+ release_note=$3
9
+ git_host=$4
10
+
11
+ if [ "$git_host" = "" ]; then
12
+ git_host="github.com"
13
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
+ fi
15
+
16
+ if [ "$git_user_id" = "" ]; then
17
+ git_user_id="nftstorage"
18
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
+ fi
20
+
21
+ if [ "$git_repo_id" = "" ]; then
22
+ git_repo_id="ruby-client"
23
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
+ fi
25
+
26
+ if [ "$release_note" = "" ]; then
27
+ release_note="Minor update"
28
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
+ fi
30
+
31
+ # Initialize the local directory as a Git repository
32
+ git init
33
+
34
+ # Adds the files in the local repository and stages them for commit.
35
+ git add .
36
+
37
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
+ git commit -m "$release_note"
39
+
40
+ # Sets the new remote
41
+ git_remote=`git remote`
42
+ if [ "$git_remote" = "" ]; then # git remote not defined
43
+
44
+ if [ "$GIT_TOKEN" = "" ]; then
45
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
+ else
48
+ git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git
49
+ fi
50
+
51
+ fi
52
+
53
+ git pull origin master
54
+
55
+ # Pushes (Forces) the changes in the local repository up to the remote repository
56
+ echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
+ git push origin master 2>&1 | grep -v 'To https'
58
+