How to use describe_local_gateway_virtual_interfaces method in localstack

Best Python code snippet using localstack_python

ec2_fixtures.py

Source:ec2_fixtures.py Github

copy

Full Screen

1import boto32import pytest3from moto import mock_ec24from tests.utils import random_str5@pytest.fixture6def gen_ec2_client(aws_setup):7 with mock_ec2():8 yield boto3.client("ec2")9@pytest.fixture10def gen_ec2_resource(aws_setup):11 with mock_ec2():12 yield boto3.resource("ec2")13# ============================14# WAITER15# ============================16@pytest.fixture17def gen_instance_exists_waiter(gen_ec2_client):18 return gen_ec2_client.get_waiter("instance_exists")19@pytest.fixture20def gen_bundle_task_complete_waiter(gen_ec2_client):21 return gen_ec2_client.get_waiter("bundle_task_complete")22@pytest.fixture23def gen_conversion_task_cancelled_waiter(gen_ec2_client):24 return gen_ec2_client.get_waiter("conversion_task_cancelled")25@pytest.fixture26def gen_conversion_task_completed_waiter(gen_ec2_client):27 return gen_ec2_client.get_waiter("conversion_task_completed")28@pytest.fixture29def gen_conversion_task_deleted_waiter(gen_ec2_client):30 return gen_ec2_client.get_waiter("conversion_task_deleted")31@pytest.fixture32def gen_customer_gateway_available_waiter(gen_ec2_client):33 return gen_ec2_client.get_waiter("customer_gateway_available")34@pytest.fixture35def gen_export_task_cancelled_waiter(gen_ec2_client):36 return gen_ec2_client.get_waiter("export_task_cancelled")37@pytest.fixture38def gen_export_task_completed_waiter(gen_ec2_client):39 return gen_ec2_client.get_waiter("export_task_completed")40@pytest.fixture41def gen_image_exists_waiter(gen_ec2_client):42 return gen_ec2_client.get_waiter("image_exists")43@pytest.fixture44def gen_image_available_waiter(gen_ec2_client):45 return gen_ec2_client.get_waiter("image_available")46@pytest.fixture47def gen_instance_running_waiter(gen_ec2_client):48 return gen_ec2_client.get_waiter("instance_running")49@pytest.fixture50def gen_instance_status_ok_waiter(gen_ec2_client):51 return gen_ec2_client.get_waiter("instance_status_ok")52@pytest.fixture53def gen_instance_stopped_waiter(gen_ec2_client):54 return gen_ec2_client.get_waiter("instance_stopped")55@pytest.fixture56def gen_instance_terminated_waiter(gen_ec2_client):57 return gen_ec2_client.get_waiter("instance_terminated")58@pytest.fixture59def gen_key_pair_exists_waiter(gen_ec2_client):60 return gen_ec2_client.get_waiter("key_pair_exists")61@pytest.fixture62def gen_nat_gateway_available_waiter(gen_ec2_client):63 return gen_ec2_client.get_waiter("nat_gateway_available")64@pytest.fixture65def gen_network_interface_available_waiter(gen_ec2_client):66 return gen_ec2_client.get_waiter("network_interface_available")67@pytest.fixture68def gen_password_data_available_waiter(gen_ec2_client):69 return gen_ec2_client.get_waiter("password_data_available")70@pytest.fixture71def gen_snapshot_completed_waiter(gen_ec2_client):72 return gen_ec2_client.get_waiter("snapshot_completed")73@pytest.fixture74def gen_security_group_exists_waiter(gen_ec2_client):75 return gen_ec2_client.get_waiter("security_group_exists")76@pytest.fixture77def gen_spot_instance_request_fulfilled_waiter(gen_ec2_client):78 return gen_ec2_client.get_waiter("spot_instance_request_fulfilled")79@pytest.fixture80def gen_subnet_available_waiter(gen_ec2_client):81 return gen_ec2_client.get_waiter("subnet_available")82@pytest.fixture83def gen_system_status_ok_waiter(gen_ec2_client):84 return gen_ec2_client.get_waiter("system_status_ok")85@pytest.fixture86def gen_volume_available_waiter(gen_ec2_client):87 return gen_ec2_client.get_waiter("volume_available")88@pytest.fixture89def gen_volume_deleted_waiter(gen_ec2_client):90 return gen_ec2_client.get_waiter("volume_deleted")91@pytest.fixture92def gen_volume_in_use_waiter(gen_ec2_client):93 return gen_ec2_client.get_waiter("volume_in_use")94@pytest.fixture95def gen_vpc_available_waiter(gen_ec2_client):96 return gen_ec2_client.get_waiter("vpc_available")97@pytest.fixture98def gen_vpc_exists_waiter(gen_ec2_client):99 return gen_ec2_client.get_waiter("vpc_exists")100@pytest.fixture101def gen_vpn_connection_available_waiter(gen_ec2_client):102 return gen_ec2_client.get_waiter("vpn_connection_available")103@pytest.fixture104def gen_vpn_connection_deleted_waiter(gen_ec2_client):105 return gen_ec2_client.get_waiter("vpn_connection_deleted")106@pytest.fixture107def gen_vpc_peering_connection_exists_waiter(gen_ec2_client):108 return gen_ec2_client.get_waiter("vpc_peering_connection_exists")109@pytest.fixture110def gen_vpc_peering_connection_deleted_waiter(gen_ec2_client):111 return gen_ec2_client.get_waiter("vpc_peering_connection_deleted")112# ============================113# PAGINATOR114# ============================115@pytest.fixture116def gen_describe_route_tables_paginator(gen_ec2_client):117 return gen_ec2_client.get_paginator("describe_route_tables")118@pytest.fixture119def gen_describe_iam_instance_profile_associations_paginator(gen_ec2_client):120 return gen_ec2_client.get_paginator("describe_iam_instance_profile_associations")121@pytest.fixture122def gen_describe_instance_status_paginator(gen_ec2_client):123 return gen_ec2_client.get_paginator("describe_instance_status")124@pytest.fixture125def gen_describe_instances_paginator(gen_ec2_client):126 return gen_ec2_client.get_paginator("describe_instances")127@pytest.fixture128def gen_describe_reserved_instances_offerings_paginator(gen_ec2_client):129 return gen_ec2_client.get_paginator("describe_reserved_instances_offerings")130@pytest.fixture131def gen_describe_reserved_instances_modifications_paginator(gen_ec2_client):132 return gen_ec2_client.get_paginator("describe_reserved_instances_modifications")133@pytest.fixture134def gen_describe_security_groups_paginator(gen_ec2_client):135 return gen_ec2_client.get_paginator("describe_security_groups")136@pytest.fixture137def gen_describe_snapshots_paginator(gen_ec2_client):138 return gen_ec2_client.get_paginator("describe_snapshots")139@pytest.fixture140def gen_describe_spot_fleet_instances_paginator(gen_ec2_client):141 return gen_ec2_client.get_paginator("describe_spot_fleet_instances")142@pytest.fixture143def gen_describe_spot_fleet_requests_paginator(gen_ec2_client):144 return gen_ec2_client.get_paginator("describe_spot_fleet_requests")145@pytest.fixture146def gen_describe_spot_price_history_paginator(gen_ec2_client):147 return gen_ec2_client.get_paginator("describe_spot_price_history")148@pytest.fixture149def gen_describe_tags_paginator(gen_ec2_client):150 return gen_ec2_client.get_paginator("describe_tags")151@pytest.fixture152def gen_describe_volume_status_paginator(gen_ec2_client):153 return gen_ec2_client.get_paginator("describe_volume_status")154@pytest.fixture155def gen_describe_volumes_paginator(gen_ec2_client):156 return gen_ec2_client.get_paginator("describe_volumes")157@pytest.fixture158def gen_describe_nat_gateways_paginator(gen_ec2_client):159 return gen_ec2_client.get_paginator("describe_nat_gateways")160@pytest.fixture161def gen_describe_network_interfaces_paginator(gen_ec2_client):162 return gen_ec2_client.get_paginator("describe_network_interfaces")163@pytest.fixture164def gen_describe_vpc_endpoints_paginator(gen_ec2_client):165 return gen_ec2_client.get_paginator("describe_vpc_endpoints")166@pytest.fixture167def gen_describe_vpc_endpoint_services_paginator(gen_ec2_client):168 return gen_ec2_client.get_paginator("describe_vpc_endpoint_services")169@pytest.fixture170def gen_describe_vpc_endpoint_connections_paginator(gen_ec2_client):171 return gen_ec2_client.get_paginator("describe_vpc_endpoint_connections")172@pytest.fixture173def gen_describe_byoip_cidrs_paginator(gen_ec2_client):174 return gen_ec2_client.get_paginator("describe_byoip_cidrs")175@pytest.fixture176def gen_describe_capacity_reservations_paginator(gen_ec2_client):177 return gen_ec2_client.get_paginator("describe_capacity_reservations")178@pytest.fixture179def gen_describe_classic_link_instances_paginator(gen_ec2_client):180 return gen_ec2_client.get_paginator("describe_classic_link_instances")181@pytest.fixture182def gen_describe_client_vpn_authorization_rules_paginator(gen_ec2_client):183 return gen_ec2_client.get_paginator("describe_client_vpn_authorization_rules")184@pytest.fixture185def gen_describe_client_vpn_connections_paginator(gen_ec2_client):186 return gen_ec2_client.get_paginator("describe_client_vpn_connections")187@pytest.fixture188def gen_describe_client_vpn_endpoints_paginator(gen_ec2_client):189 return gen_ec2_client.get_paginator("describe_client_vpn_endpoints")190@pytest.fixture191def gen_describe_client_vpn_routes_paginator(gen_ec2_client):192 return gen_ec2_client.get_paginator("describe_client_vpn_routes")193@pytest.fixture194def gen_describe_client_vpn_target_networks_paginator(gen_ec2_client):195 return gen_ec2_client.get_paginator("describe_client_vpn_target_networks")196@pytest.fixture197def gen_describe_egress_only_internet_gateways_paginator(gen_ec2_client):198 return gen_ec2_client.get_paginator("describe_egress_only_internet_gateways")199@pytest.fixture200def gen_describe_fleets_paginator(gen_ec2_client):201 return gen_ec2_client.get_paginator("describe_fleets")202@pytest.fixture203def gen_describe_flow_logs_paginator(gen_ec2_client):204 return gen_ec2_client.get_paginator("describe_flow_logs")205@pytest.fixture206def gen_describe_fpga_images_paginator(gen_ec2_client):207 return gen_ec2_client.get_paginator("describe_fpga_images")208@pytest.fixture209def gen_describe_host_reservation_offerings_paginator(gen_ec2_client):210 return gen_ec2_client.get_paginator("describe_host_reservation_offerings")211@pytest.fixture212def gen_describe_host_reservations_paginator(gen_ec2_client):213 return gen_ec2_client.get_paginator("describe_host_reservations")214@pytest.fixture215def gen_describe_hosts_paginator(gen_ec2_client):216 return gen_ec2_client.get_paginator("describe_hosts")217@pytest.fixture218def gen_describe_import_image_tasks_paginator(gen_ec2_client):219 return gen_ec2_client.get_paginator("describe_import_image_tasks")220@pytest.fixture221def gen_describe_import_snapshot_tasks_paginator(gen_ec2_client):222 return gen_ec2_client.get_paginator("describe_import_snapshot_tasks")223@pytest.fixture224def gen_describe_instance_credit_specifications_paginator(gen_ec2_client):225 return gen_ec2_client.get_paginator("describe_instance_credit_specifications")226@pytest.fixture227def gen_describe_launch_template_versions_paginator(gen_ec2_client):228 return gen_ec2_client.get_paginator("describe_launch_template_versions")229@pytest.fixture230def gen_describe_launch_templates_paginator(gen_ec2_client):231 return gen_ec2_client.get_paginator("describe_launch_templates")232@pytest.fixture233def gen_describe_moving_addresses_paginator(gen_ec2_client):234 return gen_ec2_client.get_paginator("describe_moving_addresses")235@pytest.fixture236def gen_describe_network_interface_permissions_paginator(gen_ec2_client):237 return gen_ec2_client.get_paginator("describe_network_interface_permissions")238@pytest.fixture239def gen_describe_prefix_lists_paginator(gen_ec2_client):240 return gen_ec2_client.get_paginator("describe_prefix_lists")241@pytest.fixture242def gen_describe_principal_id_format_paginator(gen_ec2_client):243 return gen_ec2_client.get_paginator("describe_principal_id_format")244@pytest.fixture245def gen_describe_public_ipv4_pools_paginator(gen_ec2_client):246 return gen_ec2_client.get_paginator("describe_public_ipv4_pools")247@pytest.fixture248def gen_describe_scheduled_instance_availability_paginator(gen_ec2_client):249 return gen_ec2_client.get_paginator("describe_scheduled_instance_availability")250@pytest.fixture251def gen_describe_scheduled_instances_paginator(gen_ec2_client):252 return gen_ec2_client.get_paginator("describe_scheduled_instances")253@pytest.fixture254def gen_describe_stale_security_groups_paginator(gen_ec2_client):255 return gen_ec2_client.get_paginator("describe_stale_security_groups")256@pytest.fixture257def gen_describe_transit_gateway_attachments_paginator(gen_ec2_client):258 return gen_ec2_client.get_paginator("describe_transit_gateway_attachments")259@pytest.fixture260def gen_describe_transit_gateway_route_tables_paginator(gen_ec2_client):261 return gen_ec2_client.get_paginator("describe_transit_gateway_route_tables")262@pytest.fixture263def gen_describe_transit_gateway_vpc_attachments_paginator(gen_ec2_client):264 return gen_ec2_client.get_paginator("describe_transit_gateway_vpc_attachments")265@pytest.fixture266def gen_describe_transit_gateways_paginator(gen_ec2_client):267 return gen_ec2_client.get_paginator("describe_transit_gateways")268@pytest.fixture269def gen_describe_volumes_modifications_paginator(gen_ec2_client):270 return gen_ec2_client.get_paginator("describe_volumes_modifications")271@pytest.fixture272def gen_describe_vpc_classic_link_dns_support_paginator(gen_ec2_client):273 return gen_ec2_client.get_paginator("describe_vpc_classic_link_dns_support")274@pytest.fixture275def gen_describe_vpc_endpoint_connection_notifications_paginator(gen_ec2_client):276 return gen_ec2_client.get_paginator(277 "describe_vpc_endpoint_connection_notifications"278 )279@pytest.fixture280def gen_describe_vpc_endpoint_service_configurations_paginator(gen_ec2_client):281 return gen_ec2_client.get_paginator("describe_vpc_endpoint_service_configurations")282@pytest.fixture283def gen_describe_vpc_endpoint_service_permissions_paginator(gen_ec2_client):284 return gen_ec2_client.get_paginator("describe_vpc_endpoint_service_permissions")285@pytest.fixture286def gen_describe_vpc_peering_connections_paginator(gen_ec2_client):287 return gen_ec2_client.get_paginator("describe_vpc_peering_connections")288@pytest.fixture289def gen_get_transit_gateway_attachment_propagations_paginator(gen_ec2_client):290 return gen_ec2_client.get_paginator("get_transit_gateway_attachment_propagations")291@pytest.fixture292def gen_get_transit_gateway_route_table_associations_paginator(gen_ec2_client):293 return gen_ec2_client.get_paginator("get_transit_gateway_route_table_associations")294@pytest.fixture295def gen_get_transit_gateway_route_table_propagations_paginator(gen_ec2_client):296 return gen_ec2_client.get_paginator("get_transit_gateway_route_table_propagations")297@pytest.fixture298def gen_describe_internet_gateways_paginator(gen_ec2_client):299 return gen_ec2_client.get_paginator("describe_internet_gateways")300@pytest.fixture301def gen_describe_network_acls_paginator(gen_ec2_client):302 return gen_ec2_client.get_paginator("describe_network_acls")303@pytest.fixture304def gen_describe_vpcs_paginator(gen_ec2_client):305 return gen_ec2_client.get_paginator("describe_vpcs")306@pytest.fixture307def gen_describe_spot_instance_requests_paginator(gen_ec2_client):308 return gen_ec2_client.get_paginator("describe_spot_instance_requests")309@pytest.fixture310def gen_describe_dhcp_options_paginator(gen_ec2_client):311 return gen_ec2_client.get_paginator("describe_dhcp_options")312@pytest.fixture313def gen_describe_subnets_paginator(gen_ec2_client):314 return gen_ec2_client.get_paginator("describe_subnets")315@pytest.fixture316def gen_describe_traffic_mirror_filters_paginator(gen_ec2_client):317 return gen_ec2_client.get_paginator("describe_traffic_mirror_filters")318@pytest.fixture319def gen_describe_traffic_mirror_sessions_paginator(gen_ec2_client):320 return gen_ec2_client.get_paginator("describe_traffic_mirror_sessions")321@pytest.fixture322def gen_describe_traffic_mirror_targets_paginator(gen_ec2_client):323 return gen_ec2_client.get_paginator("describe_traffic_mirror_targets")324@pytest.fixture325def gen_describe_export_image_tasks_paginator(gen_ec2_client):326 return gen_ec2_client.get_paginator("describe_export_image_tasks")327@pytest.fixture328def gen_describe_fast_snapshot_restores_paginator(gen_ec2_client):329 return gen_ec2_client.get_paginator("describe_fast_snapshot_restores")330@pytest.fixture331def gen_describe_ipv6_pools_paginator(gen_ec2_client):332 return gen_ec2_client.get_paginator("describe_ipv6_pools")333@pytest.fixture334def gen_get_associated_ipv6_pool_cidrs_paginator(gen_ec2_client):335 return gen_ec2_client.get_paginator("get_associated_ipv6_pool_cidrs")336@pytest.fixture337def gen_describe_coip_pools_paginator(gen_ec2_client):338 return gen_ec2_client.get_paginator("describe_coip_pools")339@pytest.fixture340def gen_describe_instance_type_offerings_paginator(gen_ec2_client):341 return gen_ec2_client.get_paginator("describe_instance_type_offerings")342@pytest.fixture343def gen_describe_instance_types_paginator(gen_ec2_client):344 return gen_ec2_client.get_paginator("describe_instance_types")345@pytest.fixture346def gen_describe_local_gateway_route_table_virtual_interface_group_associations_paginator(347 gen_ec2_client,348):349 return gen_ec2_client.get_paginator(350 "describe_local_gateway_route_table_virtual_interface_group_associations"351 )352@pytest.fixture353def gen_describe_local_gateway_route_table_vpc_associations_paginator(gen_ec2_client):354 return gen_ec2_client.get_paginator(355 "describe_local_gateway_route_table_vpc_associations"356 )357@pytest.fixture358def gen_describe_local_gateway_route_tables_paginator(gen_ec2_client):359 return gen_ec2_client.get_paginator("describe_local_gateway_route_tables")360@pytest.fixture361def gen_describe_local_gateway_virtual_interface_groups_paginator(gen_ec2_client):362 return gen_ec2_client.get_paginator(363 "describe_local_gateway_virtual_interface_groups"364 )365@pytest.fixture366def gen_describe_local_gateway_virtual_interfaces_paginator(gen_ec2_client):367 return gen_ec2_client.get_paginator("describe_local_gateway_virtual_interfaces")368@pytest.fixture369def gen_describe_local_gateways_paginator(gen_ec2_client):370 return gen_ec2_client.get_paginator("describe_local_gateways")371@pytest.fixture372def gen_describe_transit_gateway_multicast_domains_paginator(gen_ec2_client):373 return gen_ec2_client.get_paginator("describe_transit_gateway_multicast_domains")374@pytest.fixture375def gen_describe_transit_gateway_peering_attachments_paginator(gen_ec2_client):376 return gen_ec2_client.get_paginator("describe_transit_gateway_peering_attachments")377@pytest.fixture378def gen_get_transit_gateway_multicast_domain_associations_paginator(gen_ec2_client):379 return gen_ec2_client.get_paginator(380 "get_transit_gateway_multicast_domain_associations"381 )382@pytest.fixture383def gen_search_local_gateway_routes_paginator(gen_ec2_client):384 return gen_ec2_client.get_paginator("search_local_gateway_routes")385@pytest.fixture386def gen_search_transit_gateway_multicast_groups_paginator(gen_ec2_client):387 return gen_ec2_client.get_paginator("search_transit_gateway_multicast_groups")388@pytest.fixture389def gen_describe_managed_prefix_lists_paginator(gen_ec2_client):390 return gen_ec2_client.get_paginator("describe_managed_prefix_lists")391@pytest.fixture392def gen_get_managed_prefix_list_associations_paginator(gen_ec2_client):393 return gen_ec2_client.get_paginator("get_managed_prefix_list_associations")394@pytest.fixture395def gen_get_managed_prefix_list_entries_paginator(gen_ec2_client):396 return gen_ec2_client.get_paginator("get_managed_prefix_list_entries")397@pytest.fixture398def gen_get_groups_for_capacity_reservation_paginator(gen_ec2_client):399 return gen_ec2_client.get_paginator("get_groups_for_capacity_reservation")400@pytest.fixture401def gen_describe_carrier_gateways_paginator(gen_ec2_client):402 return gen_ec2_client.get_paginator("describe_carrier_gateways")403@pytest.fixture404def gen_get_transit_gateway_prefix_list_references_paginator(gen_ec2_client):405 return gen_ec2_client.get_paginator("get_transit_gateway_prefix_list_references")406@pytest.fixture407def gen_describe_network_insights_analyses_paginator(gen_ec2_client):408 return gen_ec2_client.get_paginator("describe_network_insights_analyses")409@pytest.fixture410def gen_describe_network_insights_paths_paginator(gen_ec2_client):411 return gen_ec2_client.get_paginator("describe_network_insights_paths")412@pytest.fixture413def gen_describe_transit_gateway_connect_peers_paginator(gen_ec2_client):414 return gen_ec2_client.get_paginator("describe_transit_gateway_connect_peers")415@pytest.fixture416def gen_describe_transit_gateway_connects_paginator(gen_ec2_client):417 return gen_ec2_client.get_paginator("describe_transit_gateway_connects")418@pytest.fixture419def gen_describe_addresses_attribute_paginator(gen_ec2_client):420 return gen_ec2_client.get_paginator("describe_addresses_attribute")421@pytest.fixture422def gen_describe_replace_root_volume_tasks_paginator(gen_ec2_client):423 return gen_ec2_client.get_paginator("describe_replace_root_volume_tasks")424@pytest.fixture425def gen_describe_store_image_tasks_paginator(gen_ec2_client):426 return gen_ec2_client.get_paginator("describe_store_image_tasks")427@pytest.fixture428def gen_describe_security_group_rules_paginator(gen_ec2_client):429 return gen_ec2_client.get_paginator("describe_security_group_rules")430@pytest.fixture431def gen_describe_instance_event_windows_paginator(gen_ec2_client):432 return gen_ec2_client.get_paginator("describe_instance_event_windows")433@pytest.fixture434def gen_describe_trunk_interface_associations_paginator(gen_ec2_client):435 return gen_ec2_client.get_paginator("describe_trunk_interface_associations")436@pytest.fixture437def gen_get_vpn_connection_device_types_paginator(gen_ec2_client):438 return gen_ec2_client.get_paginator("get_vpn_connection_device_types")439@pytest.fixture440def gen_describe_capacity_reservation_fleets_paginator(gen_ec2_client):441 return gen_ec2_client.get_paginator("describe_capacity_reservation_fleets")442@pytest.fixture443def gen_get_instance_types_from_instance_requirements_paginator(gen_ec2_client):444 return gen_ec2_client.get_paginator("get_instance_types_from_instance_requirements")445@pytest.fixture446def gen_get_spot_placement_scores_paginator(gen_ec2_client):447 return gen_ec2_client.get_paginator("get_spot_placement_scores")448# ============================449# RESOURCES450# ============================451@pytest.fixture452def gen_classic_address(gen_ec2_resource):453 return gen_ec2_resource.ClassicAddress(random_str())454@pytest.fixture455def gen_dhcp_options(gen_ec2_resource):456 return gen_ec2_resource.DhcpOptions(random_str())457@pytest.fixture458def gen_image(gen_ec2_resource):459 return gen_ec2_resource.Image(random_str())460@pytest.fixture461def gen_instance(gen_ec2_resource):462 return gen_ec2_resource.Instance(random_str())463@pytest.fixture464def gen_internet_gateway(gen_ec2_resource):465 return gen_ec2_resource.InternetGateway(random_str())466@pytest.fixture467def gen_key_pair(gen_ec2_resource):468 return gen_ec2_resource.KeyPair(random_str())469@pytest.fixture470def gen_network_acl(gen_ec2_resource):471 return gen_ec2_resource.NetworkAcl(random_str())472@pytest.fixture473def gen_network_interface(gen_ec2_resource):474 return gen_ec2_resource.NetworkInterface(random_str())475@pytest.fixture476def gen_network_interface_association(gen_ec2_resource):477 return gen_ec2_resource.NetworkInterfaceAssociation(random_str())478@pytest.fixture479def gen_placement_group(gen_ec2_resource):480 return gen_ec2_resource.PlacementGroup(random_str())481@pytest.fixture482def gen_route(gen_ec2_resource):483 return gen_ec2_resource.Route(random_str(), random_str())484@pytest.fixture485def gen_route_table(gen_ec2_resource):486 return gen_ec2_resource.RouteTable(random_str())487@pytest.fixture488def gen_route_table_association(gen_ec2_resource):489 return gen_ec2_resource.RouteTableAssociation(random_str())490@pytest.fixture491def gen_security_group(gen_ec2_resource):492 return gen_ec2_resource.SecurityGroup(random_str())493@pytest.fixture494def gen_snapshot(gen_ec2_resource):495 return gen_ec2_resource.Snapshot(random_str())496@pytest.fixture497def gen_subnet(gen_ec2_resource):498 return gen_ec2_resource.Subnet(random_str())499@pytest.fixture500def gen_tag(gen_ec2_resource):501 return gen_ec2_resource.Tag(random_str(), random_str(), random_str())502@pytest.fixture503def gen_volume(gen_ec2_resource):504 return gen_ec2_resource.Volume(random_str())505@pytest.fixture506def gen_vpc(gen_ec2_resource):507 return gen_ec2_resource.Vpc(random_str())508@pytest.fixture509def gen_vpc_peering_connection(gen_ec2_resource):510 return gen_ec2_resource.VpcPeeringConnection(random_str())511@pytest.fixture512def gen_vpc_address(gen_ec2_resource):513 return gen_ec2_resource.VpcAddress(random_str())514# ============================515# COLLECTIONS516# ============================517@pytest.fixture518def gen_service_resource_classic_addresses_collection(gen_ec2_resource):519 return gen_ec2_resource.classic_addresses.all()520@pytest.fixture521def gen_service_resource_dhcp_options_sets_collection(gen_ec2_resource):522 return gen_ec2_resource.dhcp_options_sets.all()523@pytest.fixture524def gen_service_resource_images_collection(gen_ec2_resource):525 return gen_ec2_resource.images.all()526@pytest.fixture527def gen_service_resource_instances_collection(gen_ec2_resource):528 return gen_ec2_resource.instances.all()529@pytest.fixture530def gen_service_resource_internet_gateways_collection(gen_ec2_resource):531 return gen_ec2_resource.internet_gateways.all()532@pytest.fixture533def gen_service_resource_key_pairs_collection(gen_ec2_resource):534 return gen_ec2_resource.key_pairs.all()535@pytest.fixture536def gen_service_resource_network_acls_collection(gen_ec2_resource):537 return gen_ec2_resource.network_acls.all()538@pytest.fixture539def gen_service_resource_network_interfaces_collection(gen_ec2_resource):540 return gen_ec2_resource.network_interfaces.all()541@pytest.fixture542def gen_service_resource_placement_groups_collection(gen_ec2_resource):543 return gen_ec2_resource.placement_groups.all()544@pytest.fixture545def gen_service_resource_route_tables_collection(gen_ec2_resource):546 return gen_ec2_resource.route_tables.all()547@pytest.fixture548def gen_service_resource_security_groups_collection(gen_ec2_resource):549 return gen_ec2_resource.security_groups.all()550@pytest.fixture551def gen_service_resource_snapshots_collection(gen_ec2_resource):552 return gen_ec2_resource.snapshots.all()553@pytest.fixture554def gen_service_resource_subnets_collection(gen_ec2_resource):555 return gen_ec2_resource.subnets.all()556@pytest.fixture557def gen_service_resource_volumes_collection(gen_ec2_resource):558 return gen_ec2_resource.volumes.all()559@pytest.fixture560def gen_service_resource_vpc_addresses_collection(gen_ec2_resource):561 return gen_ec2_resource.vpc_addresses.all()562@pytest.fixture563def gen_service_resource_vpc_peering_connections_collection(gen_ec2_resource):564 return gen_ec2_resource.vpc_peering_connections.all()565@pytest.fixture566def gen_service_resource_vpcs_collection(gen_ec2_resource):567 return gen_ec2_resource.vpcs.all()568@pytest.fixture569def gen_instance_volumes_collection(gen_instance):570 return gen_instance.volumes.all()571@pytest.fixture572def gen_instance_vpc_addresses_collection(gen_instance):573 return gen_instance.vpc_addresses.all()574@pytest.fixture575def gen_placement_group_instances_collection(gen_placement_group):576 return gen_placement_group.instances.all()577@pytest.fixture578def gen_subnet_instances_collection(gen_subnet):579 return gen_subnet.instances.all()580@pytest.fixture581def gen_subnet_network_interfaces_collection(gen_subnet):582 return gen_subnet.network_interfaces.all()583@pytest.fixture584def gen_volume_snapshots_collection(gen_volume):585 return gen_volume.snapshots.all()586@pytest.fixture587def gen_vpc_accepted_vpc_peering_connections_collection(gen_vpc):588 return gen_vpc.accepted_vpc_peering_connections.all()589@pytest.fixture590def gen_vpc_instances_collection(gen_vpc):591 return gen_vpc.instances.all()592@pytest.fixture593def gen_vpc_internet_gateways_collection(gen_vpc):594 return gen_vpc.internet_gateways.all()595@pytest.fixture596def gen_vpc_network_acls_collection(gen_vpc):597 return gen_vpc.network_acls.all()598@pytest.fixture599def gen_vpc_network_interfaces_collection(gen_vpc):600 return gen_vpc.network_interfaces.all()601@pytest.fixture602def gen_vpc_requested_vpc_peering_connections_collection(gen_vpc):603 return gen_vpc.requested_vpc_peering_connections.all()604@pytest.fixture605def gen_vpc_route_tables_collection(gen_vpc):606 return gen_vpc.route_tables.all()607@pytest.fixture608def gen_vpc_security_groups_collection(gen_vpc):609 return gen_vpc.security_groups.all()610@pytest.fixture611def gen_vpc_subnets_collection(gen_vpc):...

Full Screen

Full Screen

fetch.py

Source:fetch.py Github

copy

Full Screen

1import logging2import os3from pathlib import Path4import time5from typing import Any, Callable, Dict, Iterator, List, Optional, Tuple6import yaml7import botocore.exceptions8from botocore.session import Session as Boto9from introspector.error import GFInternal10from introspector.models.raw_import import ERROR_KEY11_log = logging.getLogger(__name__)12_THIS_DIR: Path = Path(os.path.dirname(__file__))13KeyFilter = Callable[[str], bool]14class ClientProxy(object):15 def __init__(self, client, service: str):16 self._client = client17 self._patch_client()18 self._service = service19 @property20 def _is_gov(self) -> bool:21 return '-gov-' in self._client.meta.region_name22 def _patch_client(self):23 pass24 def _should_import(self, key: str) -> bool:25 return True26 def resource_names(self) -> Iterator[str]:27 return filter(self._should_import, dir(self._client))28 def _list_args(self, key: str) -> Dict:29 return {}30 def _paginate_args(self, key: str) -> Dict:31 return {}32 def canonical_name(self, py_name: str) -> str:33 return self._client.meta.method_to_api_mapping[py_name]34 def _map_error_code(self, code: str, resource_name: str) -> Optional[str]:35 return None36 def list(self, key: str, kwargs,37 retry_on_throttle) -> Optional[Tuple[str, Any]]:38 prefix = len(key.split('_')[0])39 resource_name = self._client._PY_TO_OP_NAME[key][prefix:]40 extra_kwargs = dict(self._list_args(key), **kwargs)41 try:42 if self._client.can_paginate(key):43 paginator = self._client.get_paginator(key)44 method_args = dict(self._paginate_args(key), **extra_kwargs)45 iterator = paginator.paginate(**method_args)46 result = iterator.build_full_result()47 else:48 op = self._client.meta.method_to_api_mapping[key]49 op_model = self._client.meta.service_model.operation_model(op)50 output = op_model.output_shape51 attr = getattr(self._client, key)52 full_result = attr(**extra_kwargs)53 result = {54 result_key: full_result[result_key]55 for result_key in output.members.keys()56 if result_key in full_result57 }58 return resource_name, result59 except KeyError as e:60 raise GFInternal(61 f'Pagination Exception raise {self._client._PY_TO_OP_NAME[key]}')62 except botocore.exceptions.ParamValidationError as e:63 # TODO: fix this64 _log.debug(f'{key} Needs param input {str(e)}')65 return resource_name, {ERROR_KEY: 'needs param input'}66 except botocore.exceptions.ClientError as e:67 code = e.response.get('Error', {}).get('Code')68 if code == 'UnsupportedOperation':69 _log.info(f'{resource_name} Not supported in this region')70 return resource_name, {ERROR_KEY: 'unsupported in region'}71 elif code == 'MissingParameter':72 return resource_name, {ERROR_KEY: 'missing parameter'}73 elif code == 'OptInRequired':74 return resource_name, {ERROR_KEY: 'missing opt-in'}75 elif code in ('AuthFailure', 'AccessDeniedException',76 'UnauthorizedOperation', 'AccessDenied'):77 _log.warn(f'Missing permissions for {self._service} {key}')78 return resource_name, {ERROR_KEY: 'auth failure'}79 elif code == 'InvalidClientTokenId':80 return resource_name, {ERROR_KEY: 'invalid token'}81 elif code is not None and code.startswith('NoSuch'):82 # No results, return nothing83 return None84 elif code == 'Throttling' or code == 'ThrottlingException':85 if retry_on_throttle:86 _log.warn(f'Throttled for {key}, retrying')87 time.sleep(3)88 return self.list(key, kwargs, retry_on_throttle=False)89 else:90 _log.error(f'Throttled for {key}, not retrying')91 raise e92 else:93 mapped = self._map_error_code(code, resource_name)94 if mapped is not None:95 return resource_name, {ERROR_KEY: mapped}96 raise e97 def get(self, key: str, kwargs):98 try:99 api_call = getattr(self._client, key)100 full_result = api_call(**kwargs)101 op = self._client.meta.method_to_api_mapping[key]102 op_model = self._client.meta.service_model.operation_model(op)103 output = op_model.output_shape104 attr_result = {}105 saw_result = False106 for result_key in output.members.keys():107 value = full_result.get(result_key)108 if value is not None:109 saw_result = True110 attr_result[result_key] = value111 if saw_result:112 return attr_result113 except botocore.exceptions.ClientError as e:114 error = e.response.get('Error', {}).get('Code', '')115 if error.startswith('NoSuch') \116 or error.endswith('NotFoundError') \117 or error.endswith('NotFound') \118 or error == 'ResourceNotFoundException':119 # No results, nothing to return120 return None121 elif error in ('AuthFailure', 'MethodNotAllowed',122 'AccessDeniedException', 'AccessDenied'):123 # Auth failure124 _log.warn(f'Missing permissions for {self._service} {key}')125 else:126 raise e127class EC2ClientProxy(ClientProxy):128 MISSING_PAGINATION = {129 'describe_coip_pools':130 'PoolIds',131 'describe_elastic_gpus':132 'ElasticGpuSet',133 'describe_instance_type_offerings':134 'InstanceTypeOfferings',135 'describe_local_gateway_route_table_virtual_interface_group_associations':136 'LocalGatewayRouteTableVirtualInterfaceGroupAssociationIds',137 'describe_local_gateway_route_table_vpc_associations':138 'LocalGatewayRouteTableVpcAssociations',139 'describe_local_gateway_route_tables':140 'LocalGatewayRouteTableSet',141 'describe_local_gateway_virtual_interface_groups':142 'LocalGatewayVirtualInterfaceGroups',143 'describe_local_gateway_virtual_interfaces':144 'LocalGatewayVirtualInterfaces',145 'describe_local_gateways':146 'LocalGateways',147 'describe_transit_gateway_peering_attachments':148 'TransitGatewayPeeringAttachments',149 'describe_instance_types':150 'InstanceTypes',151 'describe_transit_gateway_multicast_domains':152 'TransitGatewayMulticastDomains'153 }154 SKIPLIST = [155 'describe_reserved_instances_offerings',156 # unsupported157 'describe_transit_gateway_connect_peers',158 'describe_transit_gateway_connects',159 'describe_spot_price_history',160 # Describes services that *can* have VPC endpoints, not ones that do161 'describe_vpc_endpoint_services',162 # TODO: verify this, i think it's about regional support for long ids163 'describe_aggregate_id_format',164 # TODO: look into this165 'describe_moving_addresses',166 # Failing in some cases, and we don't map167 'describe_id_format',168 # not needed, it's on most return values169 'describe_tags',170 # Not top level171 'describe_instance_attribute'172 ]173 GOV_SKIPLIST = [174 'describe_client_vpn_endpoints', 'describe_managed_prefix_lists',175 'describe_network_insights_analyses', 'describe_network_insights_paths'176 ]177 EXTRA_ARGS = {178 'describe_images': {179 'Filters': [{180 'Name': 'is-public',181 'Values': ['false']182 }]183 },184 'describe_snapshots': {185 'OwnerIds': ['self']186 }187 }188 PAGE_SIZES = {189 'describe_ipv6_pools': 10,190 'describe_public_ipv4_pools': 10,191 'describe_reserved_instances_modifications': None192 }193 INVALID_ACTIONS = [194 'FpgaImages', 'TransitGatewayMulticastDomains', 'ByoipCidrs',195 'Ipv6Pools', 'CoipPools',196 'LocalGatewayRouteTableVirtualInterfaceGroupAssociations',197 'LocalGatewayRouteTableVpcAssociations', 'LocalGatewayRouteTables',198 'LocalGatewayVirtualInterfaceGroups', 'LocalGatewayVirtualInterfaces',199 'LocalGateways'200 ]201 def __init__(self, *args, **kwargs):202 super().__init__(*args, **kwargs)203 ec2_svc_file = _THIS_DIR / 'svcs' / 'ec2.yml'204 with ec2_svc_file.open('r') as f:205 self._spec = yaml.safe_load(f)206 def _patch_client(self):207 # Force loading of the pagination config208 self._client.can_paginate('describe_instances')209 assert 'page_config' in self._client._cache210 for py_name, result_key in self.MISSING_PAGINATION.items():211 op_name = self._client._PY_TO_OP_NAME[py_name]212 self._client._cache['page_config'][op_name] = {213 'input_token': 'NextToken',214 'output_token': 'NextToken',215 'limit_key': 'MaxResults',216 'result_key': result_key217 }218 def _should_import(self, key: str) -> bool:219 return key.startswith('describe_') and key not in self.SKIPLIST and not (220 self._is_gov and key in self.GOV_SKIPLIST)221 def _list_args(self, key: str) -> Dict:222 return self.EXTRA_ARGS.get(key, {})223 def _paginate_args(self, key: str) -> Dict:224 # TODO: key this off of output shape225 page_size = self.PAGE_SIZES.get(key, 100)226 return {'PaginationConfig': {'PageSize': page_size}}227 def _map_error_code(self, code: str, resource_name: str) -> Optional[str]:228 if code == 'InvalidSpotDatafeed.NotFound':229 return 'Missing subscription'230 elif code == 'InvalidAction' and resource_name in self.INVALID_ACTIONS:231 return 'Missing Input params'232 return None233class S3ClientProxy(ClientProxy):234 MISSING_PAGINATION = {235 'list_bucket_analytics_configurations': 'AnalyticsConfigurationList',236 'list_bucket_inventory_configurations': 'InventoryConfigurationList',237 'list_bucket_metrics_configurations': 'MetricsConfigurationList'238 }239 GET_PREFIX = 'get_bucket_'240 LIST_PREFIX = 'list_bucket_'241 SKIPLIST = [242 # deprecated methods covered by other calls243 'get_bucket_notification',244 'get_bucket_lifecycle',245 'list_bucket_intelligent_tiering_configurations'246 ]247 GOV_SKIPLIST = ['get_bucket_accelerate_configuration']248 def _patch_client(self):249 # Force loading of the pagination config250 self._client.can_paginate('list_bucket_analytics_configurations')251 for py_name, result_key in self.MISSING_PAGINATION.items():252 op_name = self._client._PY_TO_OP_NAME[py_name]253 self._client._cache['page_config'][op_name] = {254 'input_token': 'ContinuationToken',255 'output_token': 'NextContinuationToken',256 'result_key': result_key257 }258 def _should_import(self, key: str) -> bool:259 if key in self.SKIPLIST:260 return False261 elif self._is_gov and key in self.GOV_SKIPLIST:262 return False263 elif key.startswith(self.LIST_PREFIX):264 return True265 elif key.startswith(self.GET_PREFIX):266 # Only return true if there is not a corresponding list call267 item = key[len(self.GET_PREFIX):]268 list_op = f'list_bucket_{item}s'269 return not hasattr(self._client, list_op)270 else:271 return False272class ELBClientProxy(ClientProxy):273 SKIPLIST = [274 'describe_load_balancers', 'describe_account_limits',275 'describe_instance_health', 'describe_load_balancer_policy_types'276 ]277 def _should_import(self, key: str) -> bool:278 return key.startswith('describe_') and key not in self.SKIPLIST279class LambdaClientProxy(ClientProxy):280 SKIPLIST: List[str] = []281 def _should_import(self, key: str) -> bool:282 return key.startswith('list_') and key not in self.SKIPLIST283class CloudtrailClientProxy(ClientProxy):284 SKIPLIST: List[str] = []285 def _should_import(self, key: str) -> bool:286 return key.startswith('describe_') and key not in self.SKIPLIST287class RDSClientProxy(ClientProxy):288 SKIPLIST = [289 'describe_custom_availability_zones',290 'describe_installation_media',291 'describe_export_tasks',292 'describe_reserved_db_instances_offerings',293 'describe_db_engine_versions',294 'describe_valid_db_instance_modifications',295 'describe_option_group_options',296 'describe_db_proxies', # Not sure why this comes back with unknown297 'describe_global_clusters',298 # migrating away299 'describe_db_snapshots',300 'describe_db_cluster_snapshots'301 ]302 def _should_import(self, key: str) -> bool:303 return key.startswith('describe_') and key not in self.SKIPLIST304class IAMClientProxy(ClientProxy):305 SKIPLIST: List[str] = []306 MISSING_PAGINATION = {'list_user_tags': 'Tags', 'list_role_tags': 'Tags'}307 def _should_import(self, key: str) -> bool:308 return key.startswith('list_') and key not in self.SKIPLIST309 def _patch_client(self):310 # Force loading of the pagination config311 self._client.can_paginate('list_users')312 for py_name, result_key in self.MISSING_PAGINATION.items():313 op_name = self._client._PY_TO_OP_NAME[py_name]314 self._client._cache['page_config'][op_name] = {315 'input_token': 'Marker',316 'limit_key': 'MaxItems',317 'more_results': 'IsTruncated',318 'output_token': 'Marker',319 'result_key': result_key320 }321class AWSFetch(object):322 SVC_CLASS = {323 'ec2': EC2ClientProxy,324 's3': S3ClientProxy,325 'elb': ELBClientProxy,326 'iam': IAMClientProxy,327 'rds': RDSClientProxy,328 'lambda': LambdaClientProxy,329 'cloudtrail': CloudtrailClientProxy330 }331 def __init__(self, boto: Boto):332 self._boto = boto333 def client(self,334 service: str,335 region: Optional[str] = None) -> 'ClientProxy':336 client_class = self.SVC_CLASS.get(service, ClientProxy)337 kwargs = {}338 if region is not None:339 kwargs['region_name'] = region340 client = self._boto.create_client(service, **kwargs)341 return client_class(client, service)342class ServiceProxy(object):343 def __init__(self, impl: ClientProxy):344 self._impl = impl345 def resource_names(self) -> Iterator[str]:346 return self._impl.resource_names()347 def list(self, resource: str, **kwargs) -> Optional[Tuple[str, Any]]:348 _log.debug(f'calling list {resource} {kwargs}')349 return self._impl.list(resource, kwargs, retry_on_throttle=True)350 def get(self, resource: str, **kwargs):351 _log.debug(f'calling get {resource} {kwargs}')352 return self._impl.get(resource, kwargs)353 def canonical_name(self, py_name: str) -> str:354 return self._impl.canonical_name(py_name)355class Proxy(object):356 @classmethod357 def build(cls, boto: Boto, patch_id: Optional[int] = None) -> 'Proxy':358 return cls(AWSFetch(boto))359 @classmethod360 def dummy(cls, boto: Boto) -> 'Proxy':361 return cls(AWSFetch(boto))362 def __init__(self, aws: AWSFetch):363 self._aws = aws364 def service(self,365 service: str,366 region: Optional[str] = None) -> ServiceProxy:...

Full Screen

Full Screen

events.py

Source:events.py Github

copy

Full Screen

...36 response = client_ec2.describe_ipv6_pools()37 return response38 39 elif selector == 8:40 response = client_events.describe_local_gateway_virtual_interfaces()41 return response42 43 elif selector == 9:44 response = client_kinesis.list_streams()45 return response46 47 elif selector == 10:48 response = client_sms.list_apps()49 return response50 51 elif selector == 11:52 response = client_ec2.describe_tags()53 return response54 else:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful