Class: UU::CloudRuntime::Resource

Inherits:
RuntimeBaseClass
  • Object
show all
Defined in:
lib/uu/cloud_runtime/resource.rb

Overview

Resource represents a service or other resource assigned to an application on demand, especially in the area of persistence (e.g. MongoDB, PostgreSQL, ...) or messaging.

Defined Under Namespace

Classes: ResourceType

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(session = nil) ⇒ Resource

Creates a new instance of Resource.

Parameters:

  • session (UU::OS::Security::Session) (defaults to: nil)

    Instance of session representing authenticated user (can be obtained with OS::Security::Session#current_session method).



29
30
31
# File 'lib/uu/cloud_runtime/resource.rb', line 29

def initialize(session = nil)
  @client = UU::OS::CMD::CommandClient.new(PATH, session)
end

Class Method Details

.get_resource_list(app_deployment_uri_or_tid_asid, parameters = {}) ⇒ Hash

Returns a paged list of Resources filterable by resource type. This method is a convenience shortcut for the #get_resource_list instance method.

Parameters:

  • app_deployment_uri_or_tid_asid (String, UU::OS::UESURI, String)

    App deployment uri or tid-asid.

  • parameters (Hash) (defaults to: {})

    Filtering criteria.

Options Hash (parameters):

  • pageIndex (Fixnum)

    Index of page of the result list.

  • pageSize (Fixnum)

    Maximum records count per page

  • resourceType (UU::CloudRuntime::Resource::ResourceType, String)

    Filter records by resource type. May be nil.

Returns:

  • (Hash)

    Structured hash.

See Also:



92
93
94
# File 'lib/uu/cloud_runtime/resource.rb', line 92

def self.get_resource_list(app_deployment_uri_or_tid_asid, parameters = {})
  self.new(UU::OS::Security::Session.current_session).get_resource_list(app_deployment_uri_or_tid_asid, parameters)
end

Instance Method Details

#get_resource_list(app_deployment_uri_or_tid_asid, parameters = {}) ⇒ Hash

Returns a paged list of Resources filterable by resource type.

Examples:

Command call

require 'uu_c3'
UU::OS::Security::Session.('...')
tid_asid = '123-35830958093'

resource = UU::CloudRuntime::Resource.new(UU::OS::Security::Session.current_session)
list = resource.get_resource_list(
  tid_asid,
  :pageIndex => 0,
  :pageSize => 1000
)

Command response

{
  :totalSize => 1,
  :criteria => {
    :pageSize => 1000,
    :pageIndex => 0,
    :resourceType => null
  },
  :pageEntries => [
    {
      :resourceType => "DATA_STORE",
      :id => "v3dphou7k303n2gzfklsxzon9ymlo817",
      :connectionUrl => "mongodb://v3dphou7k303n2gzfklsxzon9ymlo817__b933l3ojvini92p2o9ongo-o-s.eu-n-1.cloud.plus4u.net:27017/v3dphou7k303n2gzfklsxzon9ymlo817"
    },
    {
      :resourceType => "MSG_BUS",
      :messageBusUri => "ues:OT-BT:MESSAGE_BUS_001",
      :queuePairs => ["QUEUE_096", "QUEUE_099"]
    }
  ]
}

Parameters:

  • app_deployment_uri_or_tid_asid (String, UU::OS::UESURI)

    App deployment uri or tid-asid.

  • parameters (Hash) (defaults to: {})

    Filtering criteria.

Options Hash (parameters):

  • pageIndex (Fixnum)

    Index of page of the result list.

  • pageSize (Fixnum)

    Maximum records count per page.

  • resourceType (UU::CloudRuntime::Resource::ResourceType, String)

    Filter records by resource type. May be nil.

Returns:

  • (Hash)

    Structured hash.



76
77
78
# File 'lib/uu/cloud_runtime/resource.rb', line 76

def get_resource_list(app_deployment_uri_or_tid_asid, parameters = {})
  @client.invoke(:getResourceList, app_deployment_uri_or_tid_asid, parameters: parameters)
end