Class: OEHClient::Config::Space
- Inherits:
-
Object
- Object
- OEHClient::Config::Space
- Defined in:
- lib/oehclient/config/space.rb
Instance Attribute Summary collapse
-
#api_key ⇒ Object
————- Attributes.
-
#host ⇒ Object
————- Attributes.
-
#meta_password ⇒ Object
————- Attributes.
-
#shared_secret ⇒ Object
————- Attributes.
-
#site_key ⇒ Object
————- Attributes.
-
#username ⇒ Object
————- Attributes.
-
#workspace ⇒ Object
————- Attributes.
Class Method Summary collapse
-
.create(properties = {}) ⇒ Object
create builds a new instance of the Site class, populats the attributes using the properties HASH provided and returns an instance of the class.
Instance Method Summary collapse
-
#get_workspace ⇒ Object
retrieve the workspace meta-data object from the thinstance in realtime.
-
#is_valid? ⇒ Boolean
is_valid determines if the current class has values for all the attributes.
-
#login_url ⇒ Object
return the URL for the posting a login request.
-
#logout_url ⇒ Object
return the URL for posting a logout request.
-
#meta_access? ⇒ Boolean
determines if the space configuration appears to be valid for access to the raw meta-data entities.
-
#meta_credentials ⇒ Object
return the hash that.
-
#oauth_consumer ⇒ Object
return a new instance of the OAuth::Consumer using the details of the space.
-
#token ⇒ Object
token is the method used to generate a new OAuth::AccessToken object based on the configuration of the related space.
Instance Attribute Details
#api_key ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def api_key @api_key end |
#host ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def host @host end |
#meta_password ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def @meta_password end |
#shared_secret ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def shared_secret @shared_secret end |
#site_key ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def site_key @site_key end |
#username ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def username @username end |
#workspace ⇒ Object
————- Attributes
15 16 17 |
# File 'lib/oehclient/config/space.rb', line 15 def workspace @workspace end |
Class Method Details
.create(properties = {}) ⇒ Object
create builds a new instance of the Site class, populats the attributes using the properties HASH provided
and returns an instance of the class.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/oehclient/config/space.rb', line 30 def self.create(properties={}) # create a new instance of the OHEClient::Space class space_instance = OEHClient::Config::Space.new() # assign all attributes from the passed properties hash space_instance.site_key = properties[:site_key] if (properties.has_key?(:site_key)) space_instance.host = properties[:host] if (properties.has_key?(:host)) space_instance.api_key = properties[:api_key] if (properties.has_key?(:api_key)) space_instance.shared_secret = properties[:shared_secret] if (properties.has_key?(:shared_secret)) space_instance.username = properties[:username] if (properties.has_key?(:username)) space_instance. = properties[:meta_password] if (properties.has_key?(:meta_password)) # return the instance of the OEHClient::Site Class space_instance end |
Instance Method Details
#get_workspace ⇒ Object
retrieve the workspace meta-data object from the thinstance in realtime
107 108 109 110 111 112 |
# File 'lib/oehclient/config/space.rb', line 107 def get_workspace() # create an active session with ONE workspace = OEHClient::Meta::Session.attach(self).workspace(site_key) if (workspace.nil?) # return the active workspace object workspace end |
#is_valid? ⇒ Boolean
is_valid determines if the current class has values for all the attributes. Each attribute is required with a non-nul / non-blank value to be considered valid
80 81 82 83 84 |
# File 'lib/oehclient/config/space.rb', line 80 def is_valid?() ((!@site_key.nil? && !@site_key.empty?) && (!@host.nil? && !@host.empty?) && (!@api_key.nil? && !@api_key.empty?) && (!@shared_secret.nil? && !@shared_secret.empty?) && (!@username.nil? && !@username.empty?)) end |
#login_url ⇒ Object
return the URL for the posting a login request
98 99 100 |
# File 'lib/oehclient/config/space.rb', line 98 def login_url() "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}/one/idm_login" end |
#logout_url ⇒ Object
return the URL for posting a logout request
102 103 104 |
# File 'lib/oehclient/config/space.rb', line 102 def logout_url() "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}/one/logout" end |
#meta_access? ⇒ Boolean
determines if the space configuration appears to be valid for access to the raw meta-data entities. The method expects the standard valid attributes from is_valid? as well as the meta_password attribute
89 90 91 |
# File 'lib/oehclient/config/space.rb', line 89 def () self.is_valid? && (!@meta_password.blank?) end |
#meta_credentials ⇒ Object
return the hash that
94 95 96 |
# File 'lib/oehclient/config/space.rb', line 94 def () {:username => @username, :password => @meta_password, :rememberMe => "false"} end |
#oauth_consumer ⇒ Object
return a new instance of the OAuth::Consumer using the details of the space
71 72 73 74 75 76 |
# File 'lib/oehclient/config/space.rb', line 71 def oauth_consumer() OAuth::Consumer.new("#{@api_key}!#{@username}", @shared_secret, {:site => "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}", :scheme => :header}) end |
#token ⇒ Object
token is the method used to generate a new OAuth::AccessToken object based on the configuration of
the space
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/oehclient/config/space.rb', line 56 def token() # raise the OEHClient::InvalidSpaceException the current instance is not valid raise OEHClient::Exception::InvalidSpaceConfigException unless is_valid? # Create the consumer and access token oauth_consumer = OAuth::Consumer.new("#{@api_key}!#{@username}", @shared_secret, {:site => "#{OEHClient::Helper::Request::ONE_PROTOCOL}#{@host}", :scheme => :header}) # return the access token return(OAuth::AccessToken.new(oauth_consumer)) end |