Sha256: 699bbc38de8bf2ac64542bdec300f53623e3a80f5e554ea82bac4c353eb73a88

Contents?: true

Size: 1.92 KB

Versions: 14

Compression:

Stored size: 1.92 KB

Contents

# frozen_string_literal: true

require 'fog/core/collection'
require 'fog/aliyun/models/compute/vpc'

module Fog
  module Compute
    class Aliyun
      class Vpcs < Fog::Collection
        model Fog::Compute::Aliyun::VPC

        # Creates a new VPC
        #
        # Aliyun.vpcs.new
        #
        # ==== Returns
        #
        # Returns the details of the new VPC
        #
        # >> Aliyun.vpcs.new
        # <Fog::Aliyun::VPC::VPC
        # id=nil,
        # state=nil,
        # cidr_block=nil,
        # dhcp_options_id=nil
        # tags=nil
        # tenancy=nil
        # >
        #

        # Returns an array of all VPCs that have been created
        #
        # Aliyun.vpcs.all
        #
        # ==== Returns
        #
        # Returns an array of all VPCs
        #
        # >> Aliyun.vpcs.all
        # <Fog::Aliyun::VPC::VPCs
        # [
        # <Fog::Aliyun::VPC::VPC
        # id="vpc-12345678",
        # TODO
        # >
        # ]
        # >
        #

        def all(filters_arg = {})
          unless filters_arg.is_a?(Hash)
            Fog::Logger.warning("all with #{filters_arg.class} param is deprecated, use all('vpcId' => []) instead [light_black](#{caller.first})[/]")
            filters_arg = { 'vpcId' => [*filters_arg] }
          end
          data = Fog::JSON.decode(service.list_vpcs(filters_arg).body)['Vpcs']['Vpc']
          load(data)
        end

        # Used to retrieve a VPC
        # vpc_id is required to get the associated VPC information.
        #
        # You can run the following command to get the details:
        # Aliyun.vpcs.get("vpc-12345678")
        #
        # ==== Returns
        #
        # >> Aliyun.vpcs.get("vpc-12345678")
        # <Fog::Aliyun::Compute::VPC
        # id="vpc-12345678",
        # TODO
        # >
        #

        def get(vpcId)
          $vpc = self.class.new(service: service).all(:vpcId => vpcId)[0] if vpcId
        end
      end
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
fog-aliyun-0.4.0 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.19 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.18 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.17 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.16 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.15 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.13 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.12 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.11 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.10 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.9 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.8 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.7 lib/fog/aliyun/models/compute/vpcs.rb
fog-aliyun-0.3.6 lib/fog/aliyun/models/compute/vpcs.rb