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.
16 17 18 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 16 def initialize(attributes = {}) super end |
Instance Method Details
#all ⇒ Object
64 65 66 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 64 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
34 35 36 37 38 39 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 34 def destroy requires :id service.delete_vswitch(id) true end |
#ready? ⇒ Boolean
20 21 22 23 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 20 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.
52 53 54 55 56 57 58 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 52 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
60 61 62 |
# File 'lib/fog/aliyun/models/compute/vswitch.rb', line 60 def vpc $vpc end |