Class: UU::OperationRegistry::Resource

Inherits:
BaseMethods
  • Object
show all
Defined in:
lib/uu/operation_registry/resource.rb

Overview

Resource.

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)

    Session to use for remote calls.



18
19
20
# File 'lib/uu/operation_registry/resource.rb', line 18

def initialize(session = nil)
  super
end

Class Method Details

.create(resource_group_uri, attributes) ⇒ UU::OS::UESURI

Creates a new resource. This method is a convenience shortcut for the #create instance method.

Parameters:

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

    ResourceGroup URI.

  • attributes (Hash)

    Resource attributes.

Returns:

  • (UU::OS::UESURI)

    UESURI of the created resource.



# File 'lib/uu/operation_registry/resource.rb', line 33

.delete(resource_uri, parameters = {}) ⇒ void

This method returns an undefined value.

Deletes the specified resource from the registry. This method is a convenience shortcut for the #delete instance method.

Parameters:

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

    Resource URI.



100
101
102
# File 'lib/uu/operation_registry/resource.rb', line 100

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

.get_attributes(resource_uri) ⇒ Hash

Gets the attributes of the resource specified by resource URI and returns its detail. This method is a convenience shortcut for the #get_attributes instance method.

Parameters:

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

    Resource URI.

Returns:

  • (Hash)

    Resource attributes.



# File 'lib/uu/operation_registry/resource.rb', line 46

.get_resource_list(resource_uri, criteria = {}) ⇒ UU::OS::Persistence::PagedResult<Hash>

Returns list of resources. This method is a convenience shortcut for the #get_resource_list instance method.

Returns:

  • (UU::OS::Persistence::PagedResult<Hash>)

    Paged result set.

See Also:



126
127
128
# File 'lib/uu/operation_registry/resource.rb', line 126

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

.set_attributes(resource_uri, attributes) ⇒ UU::OS::UESURI

Sets attributes of an resource. This method is a convenience shortcut for the #set_attributes instance method.

Parameters:

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

    Resource URI.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated resource.



# File 'lib/uu/operation_registry/resource.rb', line 66

Instance Method Details

#create(resource_group_uri, attributes) ⇒ Object

Creates a new resource.

Parameters:

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

    Host URI.

  • attributes (Hash)

    Resource attributes.

Options Hash (attributes):

  • name (String)

    Resource name. May be nil.

  • code (String)

    Resource code. May be nil.

  • description (String)

    Resource description. May be nil.

  • slaStage (String)

    stage of Service Level Agreement (SLA). May be PROD or DEV.

  • type (String)

    type of resource. May be GATEWAY. (Other resource types will be added in the future.)



# File 'lib/uu/operation_registry/resource.rb', line 22

#delete(resource_uri, parameters = {}) ⇒ void

This method returns an undefined value.

Deletes the specified resource from the registry.

Resource can be successfully deleted if all these conditions are met:

  1. no GatewayDomainLink exists referencing this resource (via gatewayUri)

Examples:

Resource deletion

require "uu_operation_registry"

UU::OS::Security::Session.("operation_registry_authority")

resource = UU::OperationRegistry::Resource.new(UU::OS::Security::Session.current_session)
resource.delete("ues:OT-BT[99923616732452117]:UUOS9[5819e14581e8a357881e5996]")

Parameters:

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

    Resource URI.



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

def delete(resource_uri, parameters = {})
  client.invoke(:delete, resource_uri, parameters: parameters)
end

#get_attributes(resource_uri) ⇒ Hash

Gets the attributes of the resource specified by resource URI and returns its detail.

Parameters:

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

    Resource URI.

Returns:

  • (Hash)

    Resource attributes.



# File 'lib/uu/operation_registry/resource.rb', line 40

#get_resource_list(resource_group_uri, criteria = {}) ⇒ UU::OS::Persistence::PagedResult<Hash>

Returns a list of resources at the given resourceGroup. Command does not return all resources, only a sublist. The list of returned resources could be filtered using Mongo Query.

Parameters:

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

    ResourceGroup URI.

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

    Criteria for listing resources.

Options Hash (criteria):

  • query (String)

    Mongo Query to filter the result set. See Mongo Query tutorial. Allowed query filter document fields: code, type, slaStage, resourcePoolUri

  • pageIndex (Fixnum)

    Result set page index.

  • pageSize (Fixnum)

    Result set page size.

Returns:

  • (UU::OS::Persistence::PagedResult<Hash>)

    Paged result set.



117
118
119
# File 'lib/uu/operation_registry/resource.rb', line 117

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

#set_attributes(resource_uri, attributes) ⇒ UU::OS::UESURI

Sets attributes of an resource.

Parameters:

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

    Resource URI.

  • attributes (Hash)

    Resource attributes.

Options Hash (attributes):

  • name (String)

    Resource name. May be nil.

  • code (String)

    Resource code. May be nil.

  • description (String)

    Resource description. May be nil.

  • type (String)

    Type of Resource. One of GATEWAY or DATA_STORE

  • slaStage (String)

    Stage of Service Level Agreement (SLA), one of PROD or DEV. Default PROD.

  • attributes (Hash)

    type-specific attributes of the resource.

Returns:

  • (UU::OS::UESURI)

    UESURI of the updated resource.



# File 'lib/uu/operation_registry/resource.rb', line 53