class Unimatrix::BlueprintOperation

Public Class Methods

new( realm_uuid, options = {} ) click to toggle source
Calls superclass method Unimatrix::Operation::new
# File lib/unimatrix/blueprint_operation.rb, line 7
def initialize( realm_uuid, options = {} )
  @realm_uuid = realm_uuid
  super( "/realms/#{ realm_uuid }/blueprints", options )
end

Public Instance Methods

read() click to toggle source
# File lib/unimatrix/blueprint_operation.rb, line 12
def read
  @@blueprints[ @realm_uuid ] ||= begin
    blueprints = []

    offset = 0
    segment_count = 10
    total = nil
    errors = nil

    while total.nil? || offset < total
      operation = self.offset( offset ).include( 'blueprint_attributes' )

      operation.read do | resources, response |

        if !response.body[ 'errors' ].nil?
          errors = response.body[ 'errors' ]
          break
        end

        offset += segment_count
        total = response.body[ '$this' ][ 'unlimited_count' ]

        blueprints += resources
      end

      raise "Error requesting blueprints for realm #{ @realm_uuid }. Error: #{ errors }"  if !errors.nil?
    end

    blueprints
  end
end