Class: YandexClient::Disk
- Inherits:
-
Object
- Object
- YandexClient::Disk
- Includes:
- Configurable, ErrorHandler
- Defined in:
- lib/yandex_client/disk.rb
Overview
yandex.ru/dev/disk/api/reference/capacity.html yandex.ru/dev/disk/api/reference/content.html yandex.ru/dev/disk/api/reference/move.html
YandexClient::Disk.info YandexClient::Disk.download_url(‘path/to/file’) YandexClient::Disk.download_url(‘path/to/file’, overwrite: false)
Constant Summary collapse
- ACTION_URL =
'https://cloud-api.yandex.net'
Instance Attribute Summary collapse
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Class Method Summary collapse
- .with_token(token) ⇒ Object (also: [])
Instance Method Summary collapse
- #download_url(path) ⇒ Object
- #info ⇒ Object
-
#initialize(token) ⇒ Disk
constructor
A new instance of Disk.
- #move(from, to, overwrite: false) ⇒ Object
- #upload_url(path, overwrite: false) ⇒ Object
Methods included from Configurable
Constructor Details
#initialize(token) ⇒ Disk
Returns a new instance of Disk.
29 30 31 |
# File 'lib/yandex_client/disk.rb', line 29 def initialize(token) @token = token end |
Instance Attribute Details
#token ⇒ Object (readonly)
Returns the value of attribute token.
19 20 21 |
# File 'lib/yandex_client/disk.rb', line 19 def token @token end |
Class Method Details
.with_token(token) ⇒ Object Also known as: []
22 23 24 |
# File 'lib/yandex_client/disk.rb', line 22 def with_token(token) new(token) end |
Instance Method Details
#download_url(path) ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'lib/yandex_client/disk.rb', line 39 def download_url(path) url = URI.parse(ACTION_URL).tap do |uri| uri.path = '/v1/disk/resources/download' uri.query = URI.encode_www_form(path: path) end process_response( with_config.get(url, headers: auth_headers) ).fetch(:href) end |
#info ⇒ Object
33 34 35 36 37 |
# File 'lib/yandex_client/disk.rb', line 33 def info process_response( with_config.get("#{ACTION_URL}/v1/disk/", headers: auth_headers) ) end |
#move(from, to, overwrite: false) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/yandex_client/disk.rb', line 61 def move(from, to, overwrite: false) url = URI.parse(ACTION_URL).tap do |uri| uri.path = '/v1/disk/resources/move' uri.query = URI.encode_www_form(from: from, path: to, overwrite: overwrite) end process_response( with_config.post(url, headers: auth_headers) ).fetch(:href) end |
#upload_url(path, overwrite: false) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/yandex_client/disk.rb', line 50 def upload_url(path, overwrite: false) url = URI.parse(ACTION_URL).tap do |uri| uri.path = '/v1/disk/resources/upload' uri.query = URI.encode_www_form(path: path, overwrite: overwrite) end process_response( with_config.get(url, headers: auth_headers) ).fetch(:href) end |