yandex_cloud 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.env.example +1 -0
- data/.gitignore +3 -0
- data/CHANGELOG.md +15 -0
- data/README.md +38 -6
- data/lib/yandex_cloud/auth/iam_token.rb +15 -0
- data/lib/yandex_cloud/auth.rb +19 -0
- data/lib/yandex_cloud/version.rb +1 -1
- data/lib/yandex_cloud.rb +2 -0
- data/yandex_cloud.gemspec +1 -0
- metadata +19 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 297479377896994a62b9eae0d0481c58b701c9bc45d53812c0539cb5c43cd433
|
4
|
+
data.tar.gz: 9aa260fe5f0d97ff33c42ef4ffce432116c25c119366b9dbe1d22d49bd984047
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90e35db9dd9110aeba9520c7737d729cd5ee0b42fe6083ebe5b5f8f3bea21753e02f9ddbc3f9d0bad0e0a30a743efbf0d2061072ba12cb85823fead6b1766222
|
7
|
+
data.tar.gz: 2ce35a6c50a764ec0152d328f469ed85b18ade85caa1edd6e9dd41670d5910d95dd019ccf37a61dff0210faf399972d61bd79571f26f319fc56232ea4c7508a7
|
data/.env.example
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
YANDEX_CLOUD_API_KEY=
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
6
|
+
|
7
|
+
## Unreleased
|
8
|
+
### Added
|
9
|
+
- CHANGELOG
|
10
|
+
- dotenv support
|
11
|
+
- YandexCloud::Auth with token()
|
12
|
+
- specs for YandexCloud::Auth.token()
|
13
|
+
|
14
|
+
### Modified
|
15
|
+
- README
|
data/README.md
CHANGED
@@ -16,22 +16,54 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install yandex_cloud
|
18
18
|
|
19
|
-
##
|
19
|
+
## Get access to API
|
20
20
|
|
21
|
-
|
21
|
+
To make api requests in Yandex.Cloud you must include IAM-token in request headers and for getting IAM-token you must have Oauth token.
|
22
22
|
|
23
|
-
|
23
|
+
Instructions for getting Oauth token is [here](https://cloud.yandex.com/docs/iam/operations/iam-token/create)
|
24
24
|
|
25
|
-
|
25
|
+
### Configuration
|
26
|
+
|
27
|
+
You can use your Oauth token directly in spesific requests or put it to the ENV variables.
|
28
|
+
|
29
|
+
## Using
|
30
|
+
|
31
|
+
### Get IAM-token for cloud API access
|
32
|
+
|
33
|
+
Request for getting IAM-token for access to cloud API. Valid 12 hours.
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
# with oauth_token in ENV
|
37
|
+
auth_service = YandexCloud::Auth.new
|
38
|
+
auth_service.token
|
39
|
+
|
40
|
+
# or with oauth_token in request
|
41
|
+
auth_service = YandexCloud::Auth.new(oauth_token: oauth_token)
|
42
|
+
auth_service.token
|
43
|
+
```
|
44
|
+
|
45
|
+
#### Responses
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# successful response
|
49
|
+
{ "iamToken" => iam_token }
|
50
|
+
|
51
|
+
# response with errors
|
52
|
+
{ "code" => 16, "message" => "Token is invalid or has expired.", "details" => [...] }
|
53
|
+
```
|
26
54
|
|
27
55
|
## Contributing
|
28
56
|
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/yandex_cloud.
|
57
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/yandex_cloud.
|
30
58
|
|
31
59
|
## License
|
32
60
|
|
33
61
|
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
34
62
|
|
63
|
+
## Disclaimer
|
64
|
+
|
65
|
+
Use this package at your own peril and risk.
|
66
|
+
|
35
67
|
## Code of Conduct
|
36
68
|
|
37
|
-
Everyone interacting in the YandexCloud project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/
|
69
|
+
Everyone interacting in the YandexCloud project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kortirso/yandex_cloud/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module YandexCloud
|
2
|
+
class Auth
|
3
|
+
# Module for getting IAM token
|
4
|
+
module IamToken
|
5
|
+
# Get IAM token
|
6
|
+
def token
|
7
|
+
# define params for request
|
8
|
+
body = { 'yandexPassportOauthToken' => oauth_token }
|
9
|
+
headers = { 'Content-Type' => 'application/json' }
|
10
|
+
# make request
|
11
|
+
self.class.post('/tokens', query: body, headers: headers).parsed_response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require_relative 'auth/iam_token'
|
3
|
+
|
4
|
+
module YandexCloud
|
5
|
+
# Authentification requests
|
6
|
+
class Auth
|
7
|
+
include HTTParty
|
8
|
+
include YandexCloud::Auth::IamToken
|
9
|
+
|
10
|
+
base_uri 'https://iam.api.cloud.yandex.net/iam/v1'
|
11
|
+
format :json
|
12
|
+
|
13
|
+
attr_reader :oauth_token
|
14
|
+
|
15
|
+
def initialize(args = {})
|
16
|
+
@oauth_token = args[:oauth_token] || ENV['YANDEX_CLOUD_API_KEY']
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/yandex_cloud/version.rb
CHANGED
data/lib/yandex_cloud.rb
CHANGED
data/yandex_cloud.gemspec
CHANGED
@@ -21,6 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.require_paths = ['lib']
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.15'
|
24
|
+
spec.add_development_dependency 'dotenv', '~> 2.5'
|
24
25
|
spec.add_development_dependency 'rake', '~> 10.0'
|
25
26
|
spec.add_development_dependency 'rubocop', '~> 0.63.1'
|
26
27
|
spec.add_dependency 'httparty', '~> 0.16'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yandex_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Bogdanov
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dotenv
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.5'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,10 +87,12 @@ executables: []
|
|
73
87
|
extensions: []
|
74
88
|
extra_rdoc_files: []
|
75
89
|
files:
|
90
|
+
- ".env.example"
|
76
91
|
- ".gitignore"
|
77
92
|
- ".rspec"
|
78
93
|
- ".rubocop.yml"
|
79
94
|
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
80
96
|
- CODE_OF_CONDUCT.md
|
81
97
|
- Gemfile
|
82
98
|
- LICENSE.txt
|
@@ -85,6 +101,8 @@ files:
|
|
85
101
|
- bin/console
|
86
102
|
- bin/setup
|
87
103
|
- lib/yandex_cloud.rb
|
104
|
+
- lib/yandex_cloud/auth.rb
|
105
|
+
- lib/yandex_cloud/auth/iam_token.rb
|
88
106
|
- lib/yandex_cloud/version.rb
|
89
107
|
- yandex_cloud.gemspec
|
90
108
|
homepage: https://github.com/kortirso/yandex-cloud
|