Class: Fog::Compute::Aliyun::Vswitch
- Inherits:
-
Model
- Object
- Model
- Fog::Compute::Aliyun::Vswitch
- Defined in:
- lib/fog/aliyun/models/compute/vswitch.rb
Instance Method Summary collapse
- #all ⇒ Object
-
#destroy ⇒ Object
Removes an existing vpc.
-
#initialize(attributes = {}) ⇒ Vswitch
constructor
A new instance of Vswitch.
- #ready? ⇒ Boolean
-
#save(options = {}) ⇒ Object
Create a vpc.
- #vpc ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ Vswitch
Returns a new instance of Vswitch.
18 19 20 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 18 def initialize(attributes = {}) super end |
Instance Method Details
#all ⇒ Object
66 67 68 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 66 def all Fog::JSON.decode(service.list_vswitchs(vpc_id).body)['VSwitches']['VSwitch'] end |
#destroy ⇒ Object
Removes an existing vpc
vpc.destroy
Returns
True or false depending on the result
36 37 38 39 40 41 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 36 def destroy requires :id service.delete_vswitch(id) true end |
#ready? ⇒ Boolean
22 23 24 25 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 22 def ready? requires :state state == 'Available' end |
#save(options = {}) ⇒ Object
Create a vpc
>> g = Aliyun.vpcs.new(:cidr_block => “10.1.2.0/24”) >> g.save
Returns:
True or an exception depending on the result. Keep in mind that this creates a new vpc. As such, it yields an InvalidGroup.Duplicate exception if you attempt to save an existing vpc.
54 55 56 57 58 59 60 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 54 def save( = {}) requires :vpc, :cidr_block [:name] = name if name [:description] = description if description Fog::JSON.decode(service.create_vswitch(vpc.id, cidr_block, ).body) true end |
#vpc ⇒ Object
62 63 64 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 62 def vpc $vpc end |