sn-ann 0.3.1
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 +7 -0
- data/CHANGELOG.md +34 -0
- data/LICENSE +3 -0
- data/README.md +92 -0
- data/bin/console +16 -0
- data/bin/setup +8 -0
- data/lib/ann.rb +2 -0
- data/lib/ann/client.rb +69 -0
- data/lib/ann/version.rb +3 -0
- metadata +177 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e41c967737ee542f36e6dcc8532e7e8167744f2d
|
4
|
+
data.tar.gz: 93b9393cdd21e21866a47497e554e5559dc50a3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9bd6c6c4873edcb435d00610543ac7376e8ed7440d0a8583fde9e81100ef8a816b3253cf455efec67510413b5d7a519293f8d674b844cf2424f0089979620e78
|
7
|
+
data.tar.gz: 4b9b9472932d8eda655d63dfe6f4fac6835127e33d84cc23ab4671af245e078132e2bfc07345377dca6c7a5fceee092ee3bc6f4f61cab7409382f3583d868f8f
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# Change Log
|
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/)
|
5
|
+
and this project adheres to [Semantic Versioning](http://semver.org/).
|
6
|
+
|
7
|
+
## [Unreleased][]
|
8
|
+
|
9
|
+
### [0.3.1][] - 2018-02-24
|
10
|
+
### Fixed
|
11
|
+
- Fix `remove_user_roles` double query param
|
12
|
+
|
13
|
+
### [0.3.0][] - 2017-12-08
|
14
|
+
### Added
|
15
|
+
- add_user_roles method for granting users roles in ANN
|
16
|
+
|
17
|
+
### [0.2.0][] - 2017-12-05
|
18
|
+
### Added
|
19
|
+
- Slack notifications for builds
|
20
|
+
### Changed
|
21
|
+
- `ANN_URL` no longer requires `/api`, just the base url
|
22
|
+
|
23
|
+
### [0.1.1][] - 2017-12-05
|
24
|
+
### Added
|
25
|
+
- Test case for certificate_templates method
|
26
|
+
|
27
|
+
## 0.1.0 - 2017-12-05
|
28
|
+
Initial release.
|
29
|
+
|
30
|
+
[Unreleased]: https://github.ibm.com/cognitive-class/ann-ruby/compare/0.3.1...HEAD
|
31
|
+
[0.3.1]: https://github.ibm.com/cognitive-class/ann-ruby/compare/0.3.0...0.3.1
|
32
|
+
[0.3.0]: https://github.ibm.com/cognitive-class/ann-ruby/compare/0.2.0...0.3.0
|
33
|
+
[0.2.0]: https://github.ibm.com/cognitive-class/ann-ruby/compare/0.1.1...0.2.0
|
34
|
+
[0.1.1]: https://github.ibm.com/cognitive-class/ann-ruby/compare/0.1.0...0.1.1
|
data/LICENSE
ADDED
data/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
[](https://travis.ibm.com/cognitive-class/ann-ruby)
|
2
|
+
|
3
|
+
# Ann-Ruby
|
4
|
+
|
5
|
+
Ruby client for [ANN](https://github.ibm.com/documentorum/ann).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's `Gemfile`:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem "ann"
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
```sh
|
18
|
+
bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
```sh
|
24
|
+
gem install ann
|
25
|
+
```
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
# To start, create a client
|
31
|
+
ann = Ann::Client.new(url: "https://ann.example.com")
|
32
|
+
```
|
33
|
+
|
34
|
+
## Development
|
35
|
+
|
36
|
+
To run the tests, run:
|
37
|
+
|
38
|
+
```sh
|
39
|
+
docker-compose run --rm ann-ruby rake spec
|
40
|
+
```
|
41
|
+
|
42
|
+
You can also run the following command for an interactive prompt that will
|
43
|
+
allow you to experiment.
|
44
|
+
|
45
|
+
```sh
|
46
|
+
docker-compose run --rm ann-ruby bin/console
|
47
|
+
```
|
48
|
+
|
49
|
+
For added flexibility, you can use Bash.
|
50
|
+
|
51
|
+
```sh
|
52
|
+
docker-compose run --rm ann-ruby bash
|
53
|
+
```
|
54
|
+
|
55
|
+
## Build
|
56
|
+
|
57
|
+
Add the gem repo to your configuration:
|
58
|
+
|
59
|
+
```sh
|
60
|
+
# keep @ AS IS
|
61
|
+
curl -u<USERNAME>:<PASSWORD> \
|
62
|
+
https://na.artifactory.swg-devops.com/artifactory/api/gems/apset-ruby/api/v1/api_key.yaml \
|
63
|
+
> ~/.gem/credentials
|
64
|
+
```
|
65
|
+
|
66
|
+
Build the gem:
|
67
|
+
|
68
|
+
```sh
|
69
|
+
gem build ann.gemspec
|
70
|
+
```
|
71
|
+
|
72
|
+
Install the gem locally: (optional)
|
73
|
+
|
74
|
+
```sh
|
75
|
+
gem install ann-*.gem
|
76
|
+
```
|
77
|
+
|
78
|
+
Push the gem:
|
79
|
+
|
80
|
+
```sh
|
81
|
+
gem push ann-*.gem
|
82
|
+
rm ann-*.gem
|
83
|
+
```
|
84
|
+
|
85
|
+
## License
|
86
|
+
|
87
|
+
Please refer to [LICENSE](LICENSE).
|
88
|
+
|
89
|
+
## Authors
|
90
|
+
|
91
|
+
* Partner Ecosystem Team, IBM Digital Business Group <mailto:imcloud@ca.ibm.com>
|
92
|
+
* Based heavily on [chell-ruby](https://github.ibm.com/cognitive-class/chell-ruby)
|
data/bin/console
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "json"
|
5
|
+
require "ann"
|
6
|
+
|
7
|
+
require "irb"
|
8
|
+
|
9
|
+
instance_variable_set(:@ann,
|
10
|
+
Ann::Client.new(
|
11
|
+
url: "#{ENV.fetch('ANN_URL')}/api",
|
12
|
+
access_key: ENV.fetch("ANN_ACCESS_KEY"),
|
13
|
+
secret_key: ENV.fetch("ANN_SECRET_KEY")
|
14
|
+
))
|
15
|
+
|
16
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/ann.rb
ADDED
data/lib/ann/client.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "oj"
|
2
|
+
require "rest-client"
|
3
|
+
|
4
|
+
module Ann
|
5
|
+
class Client
|
6
|
+
FORMATS = {
|
7
|
+
json: "application/json",
|
8
|
+
gzip: "application/x-gzip"
|
9
|
+
}.freeze
|
10
|
+
|
11
|
+
def initialize(options = {})
|
12
|
+
@access_key = options.fetch(:access_key)
|
13
|
+
@secret_key = options.fetch(:secret_key)
|
14
|
+
@url = options.fetch(:url)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_user_roles(email)
|
18
|
+
path = "/permissions/user?email=#{email}"
|
19
|
+
headers = { accept: FORMATS[:json] }
|
20
|
+
|
21
|
+
response = resource[path].get(headers)
|
22
|
+
parse_json(response.body)
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_user_roles(email, roles)
|
26
|
+
path = "/permissions/user?email=#{email}"
|
27
|
+
headers = { accept: FORMATS[:json] }
|
28
|
+
payload = { roles: roles }
|
29
|
+
response = resource[path].put(payload, headers)
|
30
|
+
parse_json(response.body)
|
31
|
+
end
|
32
|
+
|
33
|
+
# rest-client doesn't allow for delete requests
|
34
|
+
# to have a body, so this one is a bit ugly
|
35
|
+
def remove_user_roles(email, roles)
|
36
|
+
path = "/permissions/user?email=#{email}"
|
37
|
+
headers = { accept: FORMATS[:json] }
|
38
|
+
|
39
|
+
response = RestClient::Request.execute(
|
40
|
+
method: :delete,
|
41
|
+
user: @access_key,
|
42
|
+
password: @secret_key,
|
43
|
+
url: @url + path,
|
44
|
+
headers: headers,
|
45
|
+
payload: { roles: roles }
|
46
|
+
)
|
47
|
+
parse_json(response.body)
|
48
|
+
end
|
49
|
+
|
50
|
+
def certificate_templates
|
51
|
+
path = "/certificates/templates"
|
52
|
+
headers = { accept: FORMATS[:json] }
|
53
|
+
|
54
|
+
response = resource[path].get(headers)
|
55
|
+
parse_json(response.body)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def parse_json(body)
|
61
|
+
Oj.default_options = { mode: :compat, symbol_keys: true }
|
62
|
+
Oj.load(body)
|
63
|
+
end
|
64
|
+
|
65
|
+
def resource
|
66
|
+
@resource ||= RestClient::Resource.new(@url, user: @access_key, password: @secret_key)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/ann/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,177 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sn-ann
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.3.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Partner Ecosystem Team, IBM Digital Business Group
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-10 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.14'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.14'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler-audit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0.5'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '12.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '12.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.4'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.48'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.48'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: simplecov
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.12'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: webmock
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '2.3'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '2.3'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: oj
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '3.3'
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '3.3'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: rest-client
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - "~>"
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '2.0'
|
139
|
+
description: Ann client
|
140
|
+
email:
|
141
|
+
- imcloud@ca.ibm.com
|
142
|
+
executables: []
|
143
|
+
extensions: []
|
144
|
+
extra_rdoc_files: []
|
145
|
+
files:
|
146
|
+
- CHANGELOG.md
|
147
|
+
- LICENSE
|
148
|
+
- README.md
|
149
|
+
- bin/console
|
150
|
+
- bin/setup
|
151
|
+
- lib/ann.rb
|
152
|
+
- lib/ann/client.rb
|
153
|
+
- lib/ann/version.rb
|
154
|
+
homepage: https://github.ibm.com/bdu/ann-ruby
|
155
|
+
licenses: []
|
156
|
+
metadata: {}
|
157
|
+
post_install_message:
|
158
|
+
rdoc_options: []
|
159
|
+
require_paths:
|
160
|
+
- lib
|
161
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
167
|
+
requirements:
|
168
|
+
- - ">="
|
169
|
+
- !ruby/object:Gem::Version
|
170
|
+
version: '0'
|
171
|
+
requirements: []
|
172
|
+
rubyforge_project:
|
173
|
+
rubygems_version: 2.6.14
|
174
|
+
signing_key:
|
175
|
+
specification_version: 4
|
176
|
+
summary: Ann client
|
177
|
+
test_files: []
|