module Croesus
A library for supporting connections to the Delphix API.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
The version number of the Croesus
Gem
@return [String]
@api public
Author: Stefano Harding <riddopic@gmail.com>
Copyright © 2014 Stefano Harding
Licensed under the Apache License, Version
2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Constants
- APIError
- API_ENDPOINT
API_VERSION = { type: ‘APIVersion’, major: 1, minor: 3, micro: 2 }
- CoercionError
- ConfigurationError
- HTTP_HEADERS
- InvalidArgumentCount
- InvalidMethodError
- InvalidStateError
- NotFound
- Undefined
Represents an undefined parameter used by auto-generated option methods
- VERSION
- ValidationError
Attributes
@!attribute [rw] api_passwd
@return [String] password for authentication
@!attribute [rw] api_user
@return [String] username to authenticate with
@!attribute [rw] last_request
@return [Hash] retruns the last request
@!attribute [rw] last_response
@return [Hash] retruns the last response
@!attribute [rw] server
@return [String] Delphix server address
@!attribute [rw] session
@return [Hash] retruns current session state @return [#code] the response code from Delphix engine @return [#headers] beautified with symbols and underscores @return [#body] parsed response body @return [#raw_body] un-parsed response body
@!attribute [rw] verbose
@return [Nothing] enables verbosity
Public Class Methods
Returns the API endpoint for a given resource namespace by combining the server address with the appropriate HTTP headers.
@param resource [Resource] namespace
@return [URL] return the URL for the API endpoint
@api public
# File lib/croesus.rb, line 156 def self.api_url(resource = nil) 'http://' + @server + resource end
# File lib/croesus/web_client/web_client.rb, line 78 def self.clear_default_headers @@default_headers = {} end
# File lib/croesus/web_client/web_client.rb, line 74 def self.default_header(name, value) @@default_headers[name] = value end
Authenticates the session so that API calls can be made. Only supports basic password authentication.
@param [String] user
user name to authenticate with
@param [String] passwd
password to authenticate with
@return [Fixnum, code]
the response code from Delphix engine
@return [Hash, headers]
headers, beautified with symbols and underscores
@return [Hash, body] body
parsed response body where applicable (JSON responses are parsed to Objects/Associative Arrays)
@return [Hash, raw_body] raw_body
un-parsed response body
@api public
# File lib/croesus.rb, line 199 def self.login(user = @api_user, passwd = @api_passwd) Croesus.post login_url, { type: 'LoginRequest', username: user, password: passwd } end
# File lib/croesus.rb, line 224 def self.many(validation) Validations::Many.new(validation) end
# File lib/croesus.rb, line 220 def self.optional(validation) Validations::Optional.new(validation) end
# File lib/croesus/web_client/web_client.rb, line 82 def self.timeout(seconds) @@timeout = seconds end
@!visibility private
# File lib/croesus.rb, line 229 def self.to_s "<#{self.class.name}:#{self.name}:#{object_id} @session=#{@session}>" end
# File lib/croesus.rb, line 216 def self.validate(*args) Base.validate(*args) end
Private Class Methods
Hooks into the mixin process to add Croesus
components to the given parent automatically.
@param [Class] parent the object this is being mixed into
# File lib/croesus.rb, line 238 def self.included(parent) parent.class_eval do include InstanceMethods extend ClassMethods "<#{self.class.name}:#{self.name}:#{object_id} @session=#{@session}>" end end
Public Instance Methods
From where forth do ye descend!
# File lib/croesus.rb, line 248 def descendants ObjectSpace.each_object(::Class).select {|klass| klass < self } end