File: route_entrys.rb

package info (click to toggle)
ruby-fog-aliyun 0.4.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 720 kB
  • sloc: ruby: 5,804; makefile: 6; sh: 3
file content (43 lines) | stat: -rw-r--r-- 1,176 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# frozen_string_literal: true

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

module Fog
  module Compute
    class Aliyun
      class RouteEntrys < Fog::Collection
        attribute :route_table

        model Fog::Compute::Aliyun::RouteEntry

        def all(options = {})
          requires :route_table
          options[:routeTableId] = route_table.id
          data = Fog::JSON.decode(service.list_route_tables(route_table.v_router_id, options).body)['RouteTables']['RouteTable'][0]['RouteEntrys']['RouteEntry']
          load(data)
        end

        def get(cidr_block)
          requires :route_table
          data = self.class.new(service: service, route_table: route_table).all
          result = nil
          data.each do |i|
            if i.cidr_block == cidr_block
              result = i
              break
            end
          end
          result
        end

        # def get(routeTableId)
        #   requires :v_router
        #   if routeTableId
        #     self.class.new(:service => service,:v_router=>v_router).all(:routeTableId=>routeTableId)[0]
        #   end
        # end
      end
    end
  end
end