yandex_cloud 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30d0ddbb3635582f3c10a08528674cfce9050d37430eeba8fa1282afb2ab8cae
4
- data.tar.gz: fd6f711af221602f80282bdf34c63c63be880c95d56a8be1071ed1e936b3399d
3
+ metadata.gz: 297479377896994a62b9eae0d0481c58b701c9bc45d53812c0539cb5c43cd433
4
+ data.tar.gz: 9aa260fe5f0d97ff33c42ef4ffce432116c25c119366b9dbe1d22d49bd984047
5
5
  SHA512:
6
- metadata.gz: b910c2b9df69142802fef25b9fe32c6253d6217d5f71627e62d170fd3c5693369aa9fbd05643b63ab0ebcfc21b8ce44ba3bc3e7ce5fbb6e9c8d2540d19e175e4
7
- data.tar.gz: d0633ca112d7530e836a63fa88a45bee1288d629bd548f58385af56968fab7693aff9e38843697e64687328125f66206b15c2d307c9e48f1dcc30483d6bdd467
6
+ metadata.gz: 90e35db9dd9110aeba9520c7737d729cd5ee0b42fe6083ebe5b5f8f3bea21753e02f9ddbc3f9d0bad0e0a30a743efbf0d2061072ba12cb85823fead6b1766222
7
+ data.tar.gz: 2ce35a6c50a764ec0152d328f469ed85b18ade85caa1edd6e9dd41670d5910d95dd019ccf37a61dff0210faf399972d61bd79571f26f319fc56232ea4c7508a7
data/.env.example ADDED
@@ -0,0 +1 @@
1
+ YANDEX_CLOUD_API_KEY=
data/.gitignore CHANGED
@@ -10,3 +10,6 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+
14
+ *.gem
15
+ .env
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
- ## Usage
19
+ ## Get access to API
20
20
 
21
- ## Development
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
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
23
+ Instructions for getting Oauth token is [here](https://cloud.yandex.com/docs/iam/operations/iam-token/create)
24
24
 
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
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/[USERNAME]/yandex_cloud/blob/master/CODE_OF_CONDUCT.md).
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
@@ -1,3 +1,3 @@
1
1
  module YandexCloud
2
- VERSION = '0.1.0'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
data/lib/yandex_cloud.rb CHANGED
@@ -1,4 +1,6 @@
1
+ require 'dotenv/load'
1
2
  require_relative 'yandex_cloud/version'
3
+ require_relative 'yandex_cloud/auth'
2
4
 
3
5
  # define main endpoint
4
6
  module YandexCloud
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.1.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