class OnappMarket::Instance

Represent a generic resource available on the market The instance will have the #local_id of the instance as created on the supplied resource and an #instance_id for reference within the market.

Constants

ACTIVE

State representing an instance which is fully built and ready for use

BUILDING

State representing an instance which is being built

DELETED

State representing an instance which has been deleted

FAILED

State representing an instance which could not be created

ID
TYPE

Attributes

api[RW]

The API used to manage this resource

build_state[RW]

Build state of instance - must include:

  • OnappMarket::Instance::BUILDING - Build of resource in progress

  • OnappMarket::Instance::ACTIVE - Resource is built

  • OnappMarket::Instance::FAILED - Resource could not be built (Deleted state)

  • OnappMarket::Instance::DELETED - Resource has been deleted (it’s details should remain) (Deleted State)

created_at[RW]

Creation date (CO favours Unix Timestamp)

deleted[RW]

Deleted

deleted_at[RW]

Deletion date (UNIX Timestamp)

description[RW]

Description - user note or information about this instance

instance_id[RW]

The instance id within the market

label[RW]

Label - user summary

local_id[RW]

The local id of the instance on the original resource

resource_id[RW]

The resource id that this instance was created upon

supplier_id[RW]

User.user_id of supplier

supplier_local_id[RW]

User.local_id of supplier

transaction_id[RW]

Transaction ID

type[RW]

The type

user_id[RW]

The user id of the creator of this resource

user_local_id[RW]

User.local_id of creator

Public Class Methods

namespace() click to toggle source

All instances shall share the same namespace

# File lib/onapp_market/instance.rb, line 63
def self.namespace
  Instance::TYPE
end
new(hash = {}, type = nil) click to toggle source

Create a resource instance object

Attributes

  • hash - Hash of attributes to apply

  • type - type for serialization help

# File lib/onapp_market/instance.rb, line 72
def initialize(hash = {}, type = nil)
  super(hash, type)
  # Restrict access
  restrict [:user_id, :user_local_id], :admin
  restrict [:local_id, :supplier_id, :supplier_local_id],  [:admin, :supplier, :ro_admin]
end

Public Instance Methods

remove() click to toggle source

Remove an instance from a resource

Returns

Roles

trader, admin

# File lib/onapp_market/instance.rb, line 87
def remove
  @api.delete("/instance/#{self.instance_id.url_safe}")
end
status() click to toggle source

Get additional status information about an instance In the future specific status information

Returns

Roles

trader, admin

# File lib/onapp_market/instance.rb, line 100
def status
  @api.get("/instance/#{self.instance_id.url_safe}/status")
end