1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[vcloud_director] Support fields,filter,format for packaged queries.

This commit is contained in:
Nick Osborn 2013-10-15 00:13:28 +01:00
parent 7ba02fbe67
commit 22c7d5a110
12 changed files with 282 additions and 71 deletions

View file

@ -15,8 +15,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -28,6 +39,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :CatalogRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -38,12 +54,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-CatalogsFromQuery.html
# @since vCloud API version 1.5
def get_catalogs_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -51,9 +70,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'catalogs/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:CatalogRecord] = [response.body[:CatalogRecord]] if response.body[:CatalogRecord].is_a?(Hash)
response.body[:CatalogRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -15,8 +15,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -28,6 +39,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :DiskRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -38,12 +54,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-DisksFromQuery.html
# @since vCloud API version 1.5
def get_disks_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -51,9 +70,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'disks/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:DiskRecord] = [response.body[:DiskRecord]] if response.body[:DiskRecord].is_a?(Hash)
response.body[:DiskRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -97,8 +97,8 @@ module Fog
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
record = "#{response.body[:name]}Record".to_sym
response.body[record] ||= []
response.body[record] = [response.body[record]] if response.body[record].is_a?(Hash)
response.body[record] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -16,8 +16,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -29,6 +40,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :GroupRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -39,12 +55,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-GroupsFromQuery.html
# @since vCloud API version 1.5
def get_groups_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -52,9 +71,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'admin/groups/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:GroupRecord] = [response.body[:GroupRecord]] if response.body[:GroupRecord].is_a?(Hash)
response.body[:GroupRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -15,8 +15,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -28,6 +39,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :MediaRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -38,12 +54,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-MediasFromQuery.html
# @since vCloud API version 1.5
def get_medias_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -51,9 +70,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'mediaList/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:MediaRecord] = [response.body[:MediaRecord]] if response.body[:MediaRecord].is_a?(Hash)
response.body[:MediaRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -16,8 +16,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -29,6 +40,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :OrganizationRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -39,12 +55,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-OrganizationsFromQuery.html
# @since vCloud API version 1.5
def get_organizations_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -52,9 +71,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'admin/orgs/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:OrganizationRecord] = [response.body[:OrganizationRecord]] if response.body[:OrganizationRecord].is_a?(Hash)
response.body[:OrganizationRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -16,8 +16,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -29,6 +40,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :UserRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -39,12 +55,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-UsersFromQuery-query.html
# @since vCloud API version 1.5
def get_users_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -52,9 +71,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'admin/users/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:UserRecord] = [response.body[:UserRecord]] if response.body[:UserRecord].is_a?(Hash)
response.body[:UserRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -16,8 +16,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -29,6 +40,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :VAppTemplateRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -39,12 +55,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VAppTemplatesFromQuery.html
# @since vCloud API version 1.5
def get_vapp_templates_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -52,9 +71,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'vAppTemplates/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:VAppTemplateRecord] = [response.body[:VAppTemplateRecord]] if response.body[:VAppTemplateRecord].is_a?(Hash)
response.body[:VAppTemplateRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -15,8 +15,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -28,6 +39,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :VAppRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -38,12 +54,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VAppsInLeaseFromQuery.html
# @since vCloud API version 1.5
def get_vapps_in_lease_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -51,9 +70,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'vApps/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:VAppRecord] = [response.body[:VAppRecord]] if response.body[:VAppRecord].is_a?(Hash)
response.body[:VAppRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -15,8 +15,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -28,6 +39,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :OrgVdcRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -38,12 +54,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-55/topic/com.vmware.vcloud.api.reference.doc_55/doc/operations/GET-RightsFromQuery-query.html
# @since vCloud API version 1.5
def get_vdcs_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -51,9 +70,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'admin/vdcs/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:OrgVdcRecord] = [response.body[:OrgVdcRecord]] if response.body[:OrgVdcRecord].is_a?(Hash)
response.body[:OrgVdcRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}

View file

@ -4,6 +4,7 @@ module Fog
class Real
require 'fog/vcloud_director/parsers/compute/vms_by_metadata'
# @see #get_vms_in_lease_by_query
def get_vms_by_metadata(key,value)
request(
:expects => 200,

View file

@ -16,8 +16,19 @@ module Fog
# multiple pages, return this page.
# @option options [Integer] :pageSize (25) Number of results per page,
# to a maximum of 128.
# @option options [String] :format (records) One of the following
# types:
# - *references* Returns a reference to each object, including its
# :name, :type, and :href attributes.
# - *records* Returns all database records for each object, with each
# record as an attribute.
# - *idrecords* Identical to the records format, except that object
# references are returned in :id format rather than :href format.
# @option options [Array<String>] :fields (all static attribute names)
# List of attribute names or metadata key names to return.
# @option options [Integer] :offset (0) Integer value specifying the
# first record to return. Record numbers < offset are not returned.
# @option options [String] :filter (none) Filter expression.
# @return [Excon::Response]
# * hash<~Hash>:
# * :href<~String> - The URI of the entity.
@ -29,6 +40,11 @@ module Fog
# references.
# * :total<~String> - Total number of records or references in the
# container.
# * :Link<~Array<Hash>>:
# * :href<~String> - Contains the URI to the entity.
# * :type<~String> - Contains the type of the entity.
# * :rel<~String> - Defines the relationship of the link to the
# object that contains it.
# * :VMRecord<~Array<Hash>>:
# * TODO
# * :firstPage<~Integer> - First page in the result set.
@ -39,12 +55,15 @@ module Fog
# @see http://pubs.vmware.com/vcd-51/topic/com.vmware.vcloud.api.reference.doc_51/doc/operations/GET-VMsInLeaseFromQuery.html
# @since vCloud API version 1.5
def get_vms_in_lease_from_query(options={})
query = {}
query[:sortAsc] = options[:sortAsc] if options[:sortAsc]
query[:sortDesc] = options[:sortDesc] if options[:sortDesc]
query[:page] = options[:page] if options[:page]
query[:pageSize] = options[:pageSize] if options[:pageSize]
query[:offset] = options[:offset] if options[:offset]
query = []
query << "sortAsc=#{options[:sortAsc]}" if options[:sortAsc]
query << "sortDesc=#{options[:sortDesc]}" if options[:sortDesc]
query << "page=#{options[:page]}" if options[:page]
query << "pageSize=#{options[:pageSize]}" if options[:pageSize]
query << "format=#{options[:format]}" if options[:format]
query << "fields=#{Array(options[:fields]).join(',')}" if options[:fields]
query << "offset=#{options[:offset]}" if options[:offset]
query << "filter=#{options[:filter]}" if options[:filter]
response = request(
:expects => 200,
@ -52,9 +71,11 @@ module Fog
:method => 'GET',
:parser => Fog::ToHashDocument.new,
:path => 'vms/query',
:query => query
:query => query.map {|q| URI.escape(q)}.join('&')
)
response.body[:Link] = [response.body[:Link]] if response.body[:Link].is_a?(Hash)
response.body[:VMRecord] = [response.body[:VMRecord]] if response.body[:VMRecord].is_a?(Hash)
response.body[:VMRecord] ||= []
%w[firstPage previousPage nextPage lastPage].each do |rel|
if link = response.body[:Link].detect {|l| l[:rel] == rel}