Class: IBM::Cloud::SDK::VPC::VPCCollection

Inherits:
IBM::Cloud::SDKHTTP::BaseCollection show all
Includes:
VpcHTTP
Defined in:
lib/ibm/cloud/sdk/vpc/http/vpc_collection.rb

Overview

Container that encapsulates the VPC API. This class is used as a base for collection APIs.

Instance Attribute Summary

Attributes included from IBM::Cloud::SDKHTTP::BaseHTTPMixin

#endpoint

Attributes inherited from IBM::Cloud::SDKHTTP::BaseCollection

#connection, #endpoint, #logger, #token

Instance Method Summary collapse

Methods included from VpcHTTP

#metadata

Methods included from IBM::Cloud::SDKHTTP::BaseHTTPMixin

#adhoc, #delete, #get, #metadata, #patch, #post, #put, #unchecked_response, #url

Methods inherited from IBM::Cloud::SDKHTTP::BaseCollection

#all, #create, #data, #fetch, #initialize, #reset_params

Constructor Details

This class inherits a constructor from IBM::Cloud::SDKHTTP::BaseCollection

Instance Method Details

#countInteger

Get the total count if it exists in the response. Returns nil otherwise.

Returns:

  • (Integer)

    The total count reuturned by the server.



42
43
44
# File 'lib/ibm/cloud/sdk/vpc/http/vpc_collection.rb', line 42

def count
  fetch.json&.[](:total_count)
end

#has_count?Boolean

Determine if the collection has a total_count key in its response.

Returns:

  • (Boolean)


36
37
38
# File 'lib/ibm/cloud/sdk/vpc/http/vpc_collection.rb', line 36

def has_count?
  fetch.json&.key?(:total_count)
end

#params(start: nil, limit: nil, resource_group: nil) ⇒ BaseCollection

A chainable method to set query filters on the collection.

Examples:

vpc.images.params(limit: 1).all

Parameters:

  • start (String) (defaults to: nil)

    A server-supplied token determining what resource to start the page on.

  • limit (Integer) (defaults to: nil)

    The number of resources to return on a page allowed values are between 1 and 100

  • resource_group (String) (defaults to: nil)

    Filters the collection to resources within one of the resource groups identified in a comma-separated list of resource group identifiers

Returns:

  • (BaseCollection)

    This class with the param instance variable set.



27
28
29
30
31
32
# File 'lib/ibm/cloud/sdk/vpc/http/vpc_collection.rb', line 27

def params(start: nil, limit: nil, resource_group: nil)
  @params[:start] = start if start
  @params[:limit] = limit if limit
  @params[:resource_group] = resource_group if resource_group
  self
end