Sha256: 9739718dbc4ec2ab71c8361a2896ede5e74cfe677eefffd7b3482902e192d9a8

Contents?: true

Size: 873 Bytes

Versions: 4

Compression:

Stored size: 873 Bytes

Contents

require 'fog/huaweicloud/models/collection'
require 'fog/identity/huaweicloud/v2/models/tenant'

module Fog
  module Identity
    class HuaweiCloud
      class V2
        class Tenants < Fog::HuaweiCloud::Collection
          model Fog::Identity::HuaweiCloud::V2::Tenant

          def all(options = {})
            load_response(service.list_tenants(options), 'tenants')
          end

          def find_by_id(id)
            cached_tenant = find { |tenant| tenant.id == id }
            return cached_tenant if cached_tenant
            tenant_hash = service.get_tenant(id).body['tenant']
            Fog::Identity::HuaweiCloud::V2::Tenant.new(
              tenant_hash.merge(:service => service)
            )
          end

          def destroy(id)
            tenant = find_by_id(id)
            tenant.destroy
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/identity/huaweicloud/v2/models/tenants.rb
fog-huaweicloud-0.0.2 lib/fog/identity/huaweicloud/v2/models/tenants.rb
fog-huaweicloud-0.1.3 lib/fog/identity/huaweicloud/v2/models/tenants.rb
fog-huaweicloud-0.1.2 lib/fog/identity/huaweicloud/v2/models/tenants.rb