Sha256: a6cefaf281c0c0ecd502035e9db75e66b1289c8b3ea5d3f64bbb6d8ddd9cbf8f

Contents?: true

Size: 1.02 KB

Versions: 23

Compression:

Stored size: 1.02 KB

Contents

module Unimatrix

  class BlueprintOperation < Unimatrix::Operation

    @@blueprints = {}

    def initialize( realm_uuid, options = {} )
      @realm_uuid = realm_uuid
      super( "/realms/#{ realm_uuid }/blueprints", options )
    end

    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

  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
unimatrix-3.4.0 lib/unimatrix/blueprint_operation.rb
unimatrix-3.3.4 lib/unimatrix/blueprint_operation.rb
unimatrix-3.3.3 lib/unimatrix/blueprint_operation.rb
unimatrix-3.3.2 lib/unimatrix/blueprint_operation.rb
unimatrix-3.3.1 lib/unimatrix/blueprint_operation.rb
unimatrix-3.3.0 lib/unimatrix/blueprint_operation.rb
unimatrix-3.2.0 lib/unimatrix/blueprint_operation.rb
unimatrix-3.1.0 lib/unimatrix/blueprint_operation.rb
unimatrix-3.0.0 lib/unimatrix/blueprint_operation.rb
unimatrix-2.9.0 lib/unimatrix/blueprint_operation.rb
unimatrix-2.8.0 lib/unimatrix/blueprint_operation.rb
unimatrix-2.7.1 lib/unimatrix/blueprint_operation.rb
unimatrix-2.7.0 lib/unimatrix/blueprint_operation.rb
unimatrix-2.6.1 lib/unimatrix/blueprint_operation.rb
unimatrix-2.6.0 lib/unimatrix/blueprint_operation.rb
unimatrix-2.5.5 lib/unimatrix/blueprint_operation.rb
unimatrix-2.5.4 lib/unimatrix/blueprint_operation.rb
unimatrix-2.5.3 lib/unimatrix/blueprint_operation.rb
unimatrix-2.5.2 lib/unimatrix/blueprint_operation.rb
unimatrix-2.5.1 lib/unimatrix/blueprint_operation.rb