cyclid-client 0.3.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.
@@ -0,0 +1,92 @@
1
+ # Copyright 2016 Liqwyd Ltd.
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ require 'yaml'
16
+ require 'cyclid/auth_methods'
17
+
18
+ module Cyclid
19
+ module Client
20
+ # Cyclid client per-organization configuration
21
+ class Config
22
+ attr_reader :auth, :server, :port, :organization, :username, :secret, :password, :token, :path
23
+ # @!attribute [r] auth
24
+ # @return [Fixnum] the authentication method. (Default is AUTH_HMAC)
25
+ # @!attribute [r] server
26
+ # @return [String] the Cyclid server FQDN
27
+ # @!attribute [r] port
28
+ # @return [Integer] the Cyclid server port. (Default is 80)
29
+ # @!attribute [r] organization
30
+ # @return [String] the Cyclid organization that this user is associated with.
31
+ # @!attribute [r] username
32
+ # @return [String] the Cyclid username
33
+ # @!attribute [r] secret
34
+ # @return [String] the users HMAC signing secret
35
+ # @!attribute [r] password
36
+ # @return [String] the users HTTP Basic password
37
+ # @!attribute [r] token
38
+ # @return [String] the users authentication token
39
+ # @!attribute [r] path
40
+ # @return [String] the fully qualified path to the current configuration file.
41
+
42
+ include AuthMethods
43
+
44
+ # @param [Hash] options
45
+ # @option options [String] :path Fully qualified path to the configuration file
46
+ # @option options [FixNum] :auth Authentication method
47
+ # @option options [String] :username Users username.
48
+ # @option options [String] :secret Users secret for use with HMAC authentication.
49
+ # @option options [String] :password Users password for use with HTTP Basic authentication.
50
+ # @option options [String] :token Users API token for use with Token authentication.
51
+ # @option options [String] :server API server address.
52
+ # @option options [Integer] :port API server port.
53
+ # @option options [String] :organization
54
+ def initialize(options = {})
55
+ # Load the config if a path was provided
56
+ @path = options[:path] || nil
57
+ @config = @path.nil? ? nil : YAML.load_file(@path)
58
+
59
+ # Select the authentication type & associated authentication data.
60
+ @auth = options[:auth] || AUTH_HMAC
61
+ case @auth
62
+ when AUTH_NONE
63
+ # Nothing
64
+ when AUTH_HMAC
65
+ @secret = options[:secret] || @config['secret']
66
+ when AUTH_BASIC
67
+ @password = options[:password] || @config['password']
68
+ when AUTH_TOKEN
69
+ @token = options[:token] || @config['token']
70
+ end
71
+
72
+ # Set defaults from the options
73
+ @server = options[:server] || nil
74
+ @port = options[:port] || nil
75
+ @organization = options[:organization] || nil
76
+ @username = options[:username] || nil
77
+
78
+ # Get anything provided in the config file
79
+ if @config
80
+ @server ||= @config['server']
81
+ @port ||= @config['port'] || 8361
82
+ @organization ||= @config['organization']
83
+ @username ||= @config['username']
84
+ end
85
+
86
+ # Server & Username *must* be set
87
+ raise 'server address must be provided' if @server.nil?
88
+ raise 'username must be provided' if @username.nil? and @auth != AUTH_NONE
89
+ end
90
+ end
91
+ end
92
+ end
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cyclid-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.0
5
+ platform: ruby
6
+ authors:
7
+ - Kristian Van Der Vliet
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.19'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.19'
27
+ - !ruby/object:Gem::Dependency
28
+ name: require_all
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: oj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '2.15'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '2.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bcrypt
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.1'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cyclid-core
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
97
+ description: Cyclid command line client for interacting with a Cyclid server and the
98
+ Ruby client library.
99
+ email: vanders@liqwyd.com
100
+ executables:
101
+ - cyclid
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - LICENSE
106
+ - README.md
107
+ - bin/cyclid
108
+ - lib/cyclid/auth_methods.rb
109
+ - lib/cyclid/cli.rb
110
+ - lib/cyclid/cli/admin.rb
111
+ - lib/cyclid/cli/admin/organization.rb
112
+ - lib/cyclid/cli/admin/user.rb
113
+ - lib/cyclid/cli/job.rb
114
+ - lib/cyclid/cli/organization.rb
115
+ - lib/cyclid/cli/organization/config.rb
116
+ - lib/cyclid/cli/organization/member.rb
117
+ - lib/cyclid/cli/secret.rb
118
+ - lib/cyclid/cli/stage.rb
119
+ - lib/cyclid/cli/user.rb
120
+ - lib/cyclid/client.rb
121
+ - lib/cyclid/client/api.rb
122
+ - lib/cyclid/client/api/basic.rb
123
+ - lib/cyclid/client/api/hmac.rb
124
+ - lib/cyclid/client/api/none.rb
125
+ - lib/cyclid/client/api/token.rb
126
+ - lib/cyclid/client/auth.rb
127
+ - lib/cyclid/client/health.rb
128
+ - lib/cyclid/client/job.rb
129
+ - lib/cyclid/client/organization.rb
130
+ - lib/cyclid/client/stage.rb
131
+ - lib/cyclid/client/user.rb
132
+ - lib/cyclid/config.rb
133
+ homepage:
134
+ licenses:
135
+ - Apache-2.0
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.5.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Cyclid command line client & library
157
+ test_files: []