awspec 1.18.3 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bb0f0d41e833307fa113f79242db844f92839b8957cda778037099ae996fd07e
4
- data.tar.gz: ef50e4986fb63cfbb75cf7227b34c524864e0728c51d0e56ab5bf4f5dc671051
3
+ metadata.gz: 18795d83f853defad01b4fba21d8c37adde28239a88695fc6092c9cd3c7bda52
4
+ data.tar.gz: 4f1e5ca8c45bf66e2eef19db079c68930895b2f8cf4fee283bfb2d09138211e0
5
5
  SHA512:
6
- metadata.gz: 1073d5248b672be4cfeea40672c2f06ade383bc1ea402d952183f906ed6d32241754c126a542ed30f5bd2d16083fbfe98810db03ec96b1f3689e7878ca71dd86
7
- data.tar.gz: 74ca0db14930a8ebe0a5de40c1631800a88be27ee9cc4efdd0f8f667eca514073e8673a1176bfcf6b0678729c904c83055b082f3bf53472d738938f15f1af68d
6
+ metadata.gz: 17ce9cd02aca06f1ce991448a4e74776d9c795242dfe4297d971cf2cdb97124c4009509c4f2927202081800a3c940aeae627d1548cbd18e9317659b2445ebd92
7
+ data.tar.gz: e8a3945166922c258860cc332d802872b47c1dd8551165ec70520cdfaa92734edace4ad9a2b941688771b656a88db2de9bdd313ac75a5f1922d6cdb540a9fce4
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
29
29
  spec.add_runtime_dependency 'rspec-its'
30
30
  spec.add_runtime_dependency 'term-ansicolor'
31
31
  spec.add_runtime_dependency 'thor'
32
+ spec.add_runtime_dependency 'addressable'
32
33
  spec.add_development_dependency 'bundler', '>= 1.9', '< 3.0'
33
34
  spec.add_development_dependency 'octorelease'
34
35
  spec.add_development_dependency 'pry'
@@ -267,7 +267,7 @@ end
267
267
 
268
268
  ### have_tag
269
269
 
270
- ### its(:architecture), its(:creation_date), its(:image_id), its(:image_location), its(:image_type), its(:public), its(:kernel_id), its(:owner_id), its(:platform), its(:ramdisk_id), its(:state), its(:description), its(:ena_support), its(:hypervisor), its(:image_owner_alias), its(:name), its(:root_device_name), its(:root_device_type), its(:sriov_net_support), its(:state_reason), its(:virtualization_type)
270
+ ### its(:architecture), its(:creation_date), its(:image_id), its(:image_location), its(:image_type), its(:public), its(:kernel_id), its(:owner_id), its(:platform), its(:platform_details), its(:usage_operation), its(:ramdisk_id), its(:state), its(:description), its(:ena_support), its(:hypervisor), its(:image_owner_alias), its(:name), its(:root_device_name), its(:root_device_type), its(:sriov_net_support), its(:state_reason), its(:virtualization_type)
271
271
  ### :unlock: Advanced use
272
272
 
273
273
  `ami` can use `Aws::EC2::Image` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Image.html).
@@ -284,6 +284,14 @@ describe apigateway('my-apigateway') do
284
284
  end
285
285
  ```
286
286
 
287
+ ### have_integration_method
288
+
289
+ ### have_integration_path
290
+
291
+ ### have_method
292
+
293
+ ### have_path
294
+
287
295
  ### its(:id), its(:name), its(:description), its(:created_date), its(:version), its(:warnings), its(:binary_media_types), its(:minimum_compression_size), its(:api_key_source), its(:policy), its(:tags)
288
296
  ## <a name="autoscaling_group">autoscaling_group</a>
289
297
 
@@ -894,7 +902,7 @@ end
894
902
  ```
895
903
 
896
904
 
897
- ### its(:availability_zone), its(:create_time), its(:encrypted), its(:kms_key_id), its(:outpost_arn), its(:size), its(:snapshot_id), its(:state), its(:volume_id), its(:iops), its(:volume_type), its(:fast_restored)
905
+ ### its(:availability_zone), its(:create_time), its(:encrypted), its(:kms_key_id), its(:outpost_arn), its(:size), its(:snapshot_id), its(:state), its(:volume_id), its(:iops), its(:volume_type), its(:fast_restored), its(:multi_attach_enabled)
898
906
  ### :unlock: Advanced use
899
907
 
900
908
  `ebs` can use `Aws::EC2::Volume` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Volume.html).
@@ -1319,7 +1327,7 @@ describe eks('my-eks') do
1319
1327
  end
1320
1328
  ```
1321
1329
 
1322
- ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags)
1330
+ ### its(:name), its(:arn), its(:created_at), its(:version), its(:endpoint), its(:role_arn), its(:logging), its(:identity), its(:status), its(:client_request_token), its(:platform_version), its(:tags), its(:encryption_config)
1323
1331
  ## <a name="elasticache">elasticache</a>
1324
1332
 
1325
1333
  Elasticache resource type.
@@ -1388,7 +1396,7 @@ describe elasticache('my-rep-group-001') do
1388
1396
  end
1389
1397
  ```
1390
1398
 
1391
- ### its(:cache_cluster_id), its(:configuration_endpoint), its(:client_download_landing_page), its(:cache_node_type), its(:engine), its(:engine_version), its(:cache_cluster_status), its(:num_cache_nodes), its(:preferred_availability_zone), its(:cache_cluster_create_time), its(:preferred_maintenance_window), its(:notification_configuration), its(:cache_security_groups), its(:cache_subnet_group_name), its(:cache_nodes), its(:auto_minor_version_upgrade), its(:replication_group_id), its(:snapshot_retention_limit), its(:snapshot_window), its(:auth_token_enabled), its(:auth_token_last_modified_date), its(:transit_encryption_enabled), its(:at_rest_encryption_enabled)
1399
+ ### its(:cache_cluster_id), its(:configuration_endpoint), its(:client_download_landing_page), its(:cache_node_type), its(:engine), its(:engine_version), its(:cache_cluster_status), its(:num_cache_nodes), its(:preferred_availability_zone), its(:cache_cluster_create_time), its(:preferred_maintenance_window), its(:notification_configuration), its(:cache_security_groups), its(:cache_subnet_group_name), its(:cache_nodes), its(:auto_minor_version_upgrade), its(:replication_group_id), its(:snapshot_retention_limit), its(:snapshot_window), its(:auth_token_enabled), its(:auth_token_last_modified_date), its(:transit_encryption_enabled), its(:at_rest_encryption_enabled), its(:arn)
1392
1400
  ## <a name="elasticache_cache_parameter_group">elasticache_cache_parameter_group</a>
1393
1401
 
1394
1402
  ElasticacheCacheParameterGroup resource type.
@@ -1467,7 +1475,7 @@ end
1467
1475
  ```
1468
1476
 
1469
1477
 
1470
- ### its(:domain_id), its(:domain_name), its(:arn), its(:created), its(:deleted), its(:endpoint), its(:endpoints), its(:processing), its(:upgrade_processing), its(:elasticsearch_version), its(:access_policies), its(:snapshot_options), its(:vpc_options), its(:cognito_options), its(:encryption_at_rest_options), its(:node_to_node_encryption_options), its(:advanced_options), its(:log_publishing_options), its(:service_software_options), its(:domain_endpoint_options)
1478
+ ### its(:domain_id), its(:domain_name), its(:arn), its(:created), its(:deleted), its(:endpoint), its(:endpoints), its(:processing), its(:upgrade_processing), its(:elasticsearch_version), its(:access_policies), its(:snapshot_options), its(:vpc_options), its(:cognito_options), its(:encryption_at_rest_options), its(:node_to_node_encryption_options), its(:advanced_options), its(:log_publishing_options), its(:service_software_options), its(:domain_endpoint_options), its(:advanced_security_options)
1471
1479
  ## <a name="elastictranscoder_pipeline">elastictranscoder_pipeline</a>
1472
1480
 
1473
1481
  ElastictranscoderPipeline resource type.
@@ -1612,7 +1620,7 @@ describe emr('my-emr') do
1612
1620
  end
1613
1621
  ```
1614
1622
 
1615
- ### its(:id), its(:name), its(:instance_collection_type), its(:log_uri), its(:requested_ami_version), its(:running_ami_version), its(:release_label), its(:auto_terminate), its(:termination_protected), its(:visible_to_all_users), its(:service_role), its(:normalized_instance_hours), its(:master_public_dns_name), its(:configurations), its(:security_configuration), its(:auto_scaling_role), its(:scale_down_behavior), its(:custom_ami_id), its(:ebs_root_volume_size), its(:repo_upgrade_on_boot), its(:cluster_arn), its(:step_concurrency_level), its(:outpost_arn)
1623
+ ### its(:id), its(:name), its(:instance_collection_type), its(:log_uri), its(:requested_ami_version), its(:running_ami_version), its(:release_label), its(:auto_terminate), its(:termination_protected), its(:visible_to_all_users), its(:service_role), its(:normalized_instance_hours), its(:master_public_dns_name), its(:configurations), its(:security_configuration), its(:auto_scaling_role), its(:scale_down_behavior), its(:custom_ami_id), its(:ebs_root_volume_size), its(:repo_upgrade_on_boot), its(:cluster_arn), its(:outpost_arn), its(:step_concurrency_level)
1616
1624
  ## <a name="firehose">firehose</a>
1617
1625
 
1618
1626
  Firehose resource type.
@@ -3381,7 +3389,7 @@ end
3381
3389
  ```
3382
3390
 
3383
3391
 
3384
- ### its(:name), its(:type), its(:key_id), its(:last_modified_date), its(:last_modified_user), its(:description), its(:allowed_pattern), its(:version), its(:tier), its(:policies)
3392
+ ### its(:name), its(:type), its(:key_id), its(:last_modified_date), its(:last_modified_user), its(:description), its(:allowed_pattern), its(:version), its(:tier), its(:policies), its(:data_type)
3385
3393
  ### :unlock: Advanced use
3386
3394
 
3387
3395
  ```ruby
@@ -3425,7 +3433,7 @@ end
3425
3433
  ```
3426
3434
 
3427
3435
 
3428
- ### its(:availability_zone), its(:availability_zone_id), its(:available_ip_address_count), its(:cidr_block), its(:default_for_az), its(:map_public_ip_on_launch), its(:state), its(:subnet_id), its(:vpc_id), its(:owner_id), its(:assign_ipv_6_address_on_creation), its(:ipv_6_cidr_block_association_set), its(:subnet_arn), its(:outpost_arn)
3436
+ ### its(:availability_zone), its(:availability_zone_id), its(:available_ip_address_count), its(:cidr_block), its(:default_for_az), its(:map_public_ip_on_launch), its(:map_customer_owned_ip_on_launch), its(:customer_owned_ipv_4_pool), its(:state), its(:subnet_id), its(:vpc_id), its(:owner_id), its(:assign_ipv_6_address_on_creation), its(:ipv_6_cidr_block_association_set), its(:subnet_arn), its(:outpost_arn)
3429
3437
  ### :unlock: Advanced use
3430
3438
 
3431
3439
  `subnet` can use `Aws::EC2::Subnet` resource (see http://docs.aws.amazon.com/sdkforruby/api/Aws/EC2/Subnet.html).
@@ -2,7 +2,7 @@ require 'awspec/config'
2
2
 
3
3
  module Awspec::Helper
4
4
  class ClientWrap
5
- attr_reader :client, :backoff, :iteration, :backoff_limit, :symbol
5
+ attr_reader :client, :backoff, :iteration, :backoff_limit, :symbol1, :symbol2
6
6
  def initialize(real_client = nil)
7
7
  raise ArgumentError, 'Client can not be nil' if real_client.nil?
8
8
  config = Awspec::Config.instance
@@ -14,7 +14,8 @@ module Awspec::Helper
14
14
  @backoff_limit = config[:client_backoff_limit]
15
15
  # build the symbol we'll use to compare to any errors caught in method_missing
16
16
  # below.
17
- @symbol = real_client.class.to_s.split('::').shift(2).push('Errors', 'RequestLimitExceeded').join('::').to_sym
17
+ @symbol1 = real_client.class.to_s.split('::').shift(2).push('Errors', 'RequestLimitExceeded').join('::').to_sym
18
+ @symbol2 = real_client.class.to_s.split('::').shift(2).push('Errors', 'Throttling').join('::').to_sym
18
19
  end
19
20
 
20
21
  protected
@@ -28,7 +29,7 @@ module Awspec::Helper
28
29
  begin
29
30
  results = client.send(m, *args, &block)
30
31
  rescue Exception => e # rubocop:disable Lint/RescueException
31
- raise unless e.class.to_s == symbol.to_s && backoff < backoff_limit
32
+ raise unless (e.class.to_s == symbol1.to_s || e.class.to_s == symbol2.to_s) && backoff < backoff_limit
32
33
 
33
34
  @backoff = backoff + (iteration * iteration * 0.5)
34
35
  @iteration += 1
@@ -3,8 +3,8 @@ module Awspec::Helper
3
3
  module Acm
4
4
  def find_certificate(id)
5
5
  selected = []
6
+ req = {}
6
7
  loop do
7
- req = {}
8
8
  res = acm_client.list_certificates(req)
9
9
  selected += res.certificate_summary_list.select do |c|
10
10
  c.certificate_arn == id || c.domain_name == id
@@ -19,8 +19,8 @@ module Awspec::Helper
19
19
 
20
20
  def select_all_certificates
21
21
  certs = []
22
+ req = {}
22
23
  loop do
23
- req = {}
24
24
  res = acm_client.list_certificates(req)
25
25
  res.certificate_summary_list.each do |c|
26
26
  certs << c.certificate_arn
@@ -6,7 +6,7 @@ module Awspec::Helper
6
6
  res.load_balancers.select do |lb|
7
7
  lb.type == 'application'
8
8
  end.single_resource(id)
9
- rescue
9
+ rescue Aws::ElasticLoadBalancingV2::Errors::LoadBalancerNotFound
10
10
  return nil
11
11
  end
12
12
 
@@ -20,7 +20,7 @@ module Awspec::Helper
20
20
  def find_alb_listener(arn)
21
21
  res = elbv2_client.describe_listeners({ listener_arns: [arn] })
22
22
  res.listeners.single_resource(arn)
23
- rescue
23
+ rescue StandardError
24
24
  return nil
25
25
  end
26
26
 
@@ -40,7 +40,7 @@ module Awspec::Helper
40
40
  res.target_groups.select do |tg|
41
41
  %w(HTTP HTTPS).include?(tg.protocol)
42
42
  end.single_resource(id)
43
- rescue
43
+ rescue StandardError
44
44
  return nil
45
45
  end
46
46
 
@@ -60,7 +60,7 @@ module Awspec::Helper
60
60
  res.tag_descriptions.select do |resource|
61
61
  resource.resource_arn == id
62
62
  end.first.tags
63
- rescue
63
+ rescue StandardError
64
64
  return nil
65
65
  end
66
66
  end
@@ -2,20 +2,34 @@ module Awspec::Helper
2
2
  module Finder
3
3
  module Apigateway
4
4
  def find_apigateway_by_id(id)
5
- rest_apis = apigateway_client.get_rest_apis
6
- rest_apis.items.each do |item|
7
- return item if item.id == id
5
+ apis = []
6
+ apigateway_client.get_rest_apis(limit: 500).each do |response|
7
+ apis += response.items
8
+ end
9
+ apis.each do |api|
10
+ return api if api.id == id
8
11
  end
9
12
  nil
10
13
  end
11
14
 
12
15
  def find_apigateway_by_name(name)
13
- rest_apis = apigateway_client.get_rest_apis
14
- rest_apis.items.each do |item|
15
- return item if item.name == name
16
+ apis = []
17
+ apigateway_client.get_rest_apis(limit: 500).each do |response|
18
+ apis += response.items
19
+ end
20
+ apis.each do |api|
21
+ return api if api.name == name
16
22
  end
17
23
  nil
18
24
  end
25
+
26
+ def find_api_resources_by_id(api_id)
27
+ all_resources = []
28
+ apigateway_client.get_resources(rest_api_id: api_id, limit: 500, embed: ['methods']).each do |response|
29
+ all_resources += response.items
30
+ end
31
+ all_resources != [] ? all_resources : nil
32
+ end
19
33
  end
20
34
  end
21
35
  end
@@ -16,7 +16,7 @@ module Awspec::Helper
16
16
  break unless res.is_truncated
17
17
  res = iam_client.send(
18
18
  'list_' + type.pluralize,
19
- { marker => res.marker }
19
+ { marker: res.marker }
20
20
  )
21
21
  end
22
22
 
@@ -70,6 +70,45 @@ Aws.config[:apigateway] = {
70
70
  }
71
71
  }
72
72
  ]
73
+ },
74
+ get_resources: {
75
+ position: '1',
76
+ items: [
77
+ {
78
+ path: '/proxy',
79
+ resource_methods: {
80
+ 'GET' => {
81
+ http_method: 'GET',
82
+ method_integration: { http_method: 'POST', uri: 'http://127.0.0.1:8080/hockey' }
83
+ }
84
+ }
85
+ },
86
+ {
87
+ path: '/zambonis',
88
+ resource_methods: {
89
+ 'POST' => {
90
+ http_method: 'POST',
91
+ method_integration: { http_method: 'POST',
92
+ uri: 'http://127.0.0.1:8080/zambonis/{arena}?arena=Saddledome' }
93
+ }
94
+ }
95
+ },
96
+ {
97
+ path: '/zambonis/123',
98
+ resource_methods: {
99
+ 'POST' => {
100
+ http_method: 'POST',
101
+ method_integration: { http_method: 'AWS',
102
+ uri: 'arn:aws:apigateway:us-east-1:cognito-idp:action/ListUsers' }
103
+ },
104
+ 'GET' => {
105
+ http_method: 'GET',
106
+ method_integration: { http_method: 'AWS',
107
+ uri: 'arn:aws:apigateway:us-east-1:cognito-idp:action/SignUp?username=test' }
108
+ }
109
+ }
110
+ }
111
+ ]
73
112
  }
74
113
  }
75
114
  }
@@ -15,11 +15,13 @@ module Awspec::Type
15
15
 
16
16
  STATES.each do |state|
17
17
  define_method state + '?' do
18
+ check_existence
18
19
  resource_via_client.state.code == state
19
20
  end
20
21
  end
21
22
 
22
23
  def has_security_group?(sg_id)
24
+ check_existence
23
25
  sgs = resource_via_client.security_groups
24
26
  ret = sgs.find do |sg|
25
27
  sg == sg_id
@@ -31,6 +33,7 @@ module Awspec::Type
31
33
  end
32
34
 
33
35
  def has_subnet?(subnet_id)
36
+ check_existence
34
37
  azs = resource_via_client.availability_zones
35
38
  ret = azs.find do |az|
36
39
  az.subnet_id == subnet_id
@@ -1,3 +1,5 @@
1
+ require 'addressable/uri'
2
+
1
3
  module Awspec::Type
2
4
  class Apigateway < ResourceBase
3
5
  aws_resource Aws::APIGateway::Client
@@ -11,5 +13,53 @@ module Awspec::Type
11
13
  def id
12
14
  @id ||= resource_via_client.id if resource_via_client
13
15
  end
16
+
17
+ def api_resources
18
+ @api_resources.nil? ? @api_resources = find_api_resources_by_id(@id) : @api_resources
19
+ end
20
+
21
+ def has_path?(path)
22
+ check_existence
23
+ self.api_resources.each do |resource|
24
+ return resource if resource.path == path
25
+ end
26
+ nil
27
+ end
28
+
29
+ def has_integration_path?(path)
30
+ check_existence
31
+ self.api_resources.each do |resource|
32
+ next if resource.resource_methods.nil?
33
+ resource.resource_methods.each do |_, method|
34
+ if method.method_integration.http_method == 'AWS'
35
+ aws_path = method.method_integration.uri.match(%r{(\/[^\?]+)\??.*$}).captures[0] # Matches for ARN type path
36
+ return resource if aws_path == path
37
+ end
38
+ uri = Addressable::URI.parse(method.method_integration.uri)
39
+ return resource if uri.path == path
40
+ end
41
+ end
42
+ nil
43
+ end
44
+
45
+ def has_method?(path, http_method)
46
+ check_existence
47
+ resource_to_check = has_path?(path)
48
+ return nil if resource_to_check.nil?
49
+ resource_to_check.resource_methods.each do |_, method|
50
+ return resource_to_check if method.http_method == http_method
51
+ end
52
+ nil
53
+ end
54
+
55
+ def has_integration_method?(integration_path, http_method)
56
+ check_existence
57
+ integration_resource_to_check = has_integration_path?(integration_path)
58
+ return nil if integration_resource_to_check.nil?
59
+ integration_resource_to_check.resource_methods.each do |_, method|
60
+ return integration_resource_to_check if method.method_integration.http_method == http_method
61
+ end
62
+ nil
63
+ end
14
64
  end
15
65
  end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '1.18.3'
2
+ VERSION = '1.19.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.3
4
+ version: 1.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-16 00:00:00.000000000 Z
11
+ date: 2020-05-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: addressable
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: bundler
127
141
  requirement: !ruby/object:Gem::Requirement