def awscli_initialize(event_handlers): event_handlers.register('load-cli-arg', uri_param) param_shorthand = ParamShorthand() event_handlers.register('process-cli-arg', param_shorthand) # The s3 error mesage needs to registered before the # generic error handler. register_s3_error_msg(event_handlers) error_handler = ErrorHandler() event_handlers.register('after-call', error_handler, unique_id='awscli-error-handler') # # The following will get fired for every option we are # # documenting. It will attempt to add an example_fn on to # # the parameter object if the parameter supports shorthand # # syntax. The documentation event handlers will then use # # the examplefn to generate the sample shorthand syntax # # in the docs. Registering here should ensure that this # # handler gets called first but it still feels a bit brittle. # event_handlers.register('doc-option-example.*.*.*', # param_shorthand.add_example_fn) event_handlers.register('doc-examples.*.*', add_examples) register_cli_input_json(event_handlers) event_handlers.register('building-argument-table.*', add_streaming_output_arg) event_handlers.register('building-argument-table.ec2.run-instances', ec2_add_count) event_handlers.register('building-argument-table.ec2.get-password-data', ec2_add_priv_launch_key) register_parse_global_args(event_handlers) register_pagination(event_handlers) register_secgroup(event_handlers) register_bundleinstance(event_handlers) s3_plugin_initialize(event_handlers) register_runinstances(event_handlers) register_removals(event_handlers) register_preview_commands(event_handlers) register_rds_modify_split(event_handlers) register_put_metric_data(event_handlers) register_ses_send_email(event_handlers) IAMVMFAWrapper(event_handlers) register_arg_renames(event_handlers) register_dryrun_docs(event_handlers) register_configure_cmd(event_handlers) cloudtrail_init(event_handlers) register_bool_params(event_handlers) register_protocol_args(event_handlers) datapipeline.register_customizations(event_handlers) cloudsearch_init(event_handlers) emr_initialize(event_handlers) register_cloudsearchdomain(event_handlers) register_s3_endpoint(event_handlers) register_generate_cli_skeleton(event_handlers) register_assume_role_provider(event_handlers) register_add_waiters(event_handlers) codedeploy_init(event_handlers) register_subscribe(event_handlers) register_get_status(event_handlers) register_rename_config(event_handlers) register_scalar_parser(event_handlers) opsworks_init(event_handlers)
def test_assume_role_provider_registration(self): event_handlers = HierarchicalEmitter() assumerole.register_assume_role_provider(event_handlers) session = mock.Mock() event_handlers.emit('building-command-table.foo', session=session) # Just verifying that anything on the session was called ensures # that our handler was called, as it's the only thing that should # be registered. session.get_component.assert_called_with('credential_provider')
def test_assume_role_provider_registration(self): event_handlers = HierarchicalEmitter() assumerole.register_assume_role_provider(event_handlers) session = mock.Mock() event_handlers.emit('session-initialized', session=session) # Just verifying that anything on the session was called ensures # that our handler was called, as it's the only thing that should # be registered. session.get_component.assert_called_with('credential_provider')
def awscli_initialize(event_handlers): event_handlers.register('session-initialized', register_uri_param_handler) param_shorthand = ParamShorthandParser() event_handlers.register('process-cli-arg', param_shorthand) # The s3 error mesage needs to registered before the # generic error handler. register_s3_error_msg(event_handlers) # # The following will get fired for every option we are # # documenting. It will attempt to add an example_fn on to # # the parameter object if the parameter supports shorthand # # syntax. The documentation event handlers will then use # # the examplefn to generate the sample shorthand syntax # # in the docs. Registering here should ensure that this # # handler gets called first but it still feels a bit brittle. # event_handlers.register('doc-option-example.*.*.*', # param_shorthand.add_example_fn) event_handlers.register('doc-examples.*.*', add_examples) register_cli_input_json(event_handlers) event_handlers.register('building-argument-table.*', add_streaming_output_arg) register_count_events(event_handlers) event_handlers.register('building-argument-table.ec2.get-password-data', ec2_add_priv_launch_key) register_parse_global_args(event_handlers) register_pagination(event_handlers) register_secgroup(event_handlers) register_bundleinstance(event_handlers) s3_plugin_initialize(event_handlers) register_runinstances(event_handlers) register_removals(event_handlers) register_preview_commands(event_handlers) register_rds_modify_split(event_handlers) register_rekognition_detect_labels(event_handlers) register_add_generate_db_auth_token(event_handlers) register_put_metric_data(event_handlers) register_ses_send_email(event_handlers) IAMVMFAWrapper(event_handlers) register_arg_renames(event_handlers) register_configure_cmd(event_handlers) cloudtrail_init(event_handlers) register_ecr_commands(event_handlers) register_bool_params(event_handlers) register_protocol_args(event_handlers) datapipeline.register_customizations(event_handlers) cloudsearch_init(event_handlers) emr_initialize(event_handlers) register_cloudsearchdomain(event_handlers) register_s3_endpoint(event_handlers) register_generate_cli_skeleton(event_handlers) register_assume_role_provider(event_handlers) register_add_waiters(event_handlers) codedeploy_init(event_handlers) register_subscribe(event_handlers) register_get_status(event_handlers) register_rename_config(event_handlers) register_scalar_parser(event_handlers) opsworks_init(event_handlers) register_lambda_create_function(event_handlers) register_fix_kms_create_grant_docs(event_handlers) register_create_hosted_zone_doc_fix(event_handlers) register_modify_put_configuration_recorder(event_handlers) codecommit_init(event_handlers) register_custom_endpoint_note(event_handlers) event_handlers.register( 'building-argument-table.iot.create-keys-and-certificate', register_create_keys_and_cert_arguments) event_handlers.register( 'building-argument-table.iot.create-certificate-from-csr', register_create_keys_from_csr_arguments) register_cloudfront(event_handlers) register_gamelift_commands(event_handlers) register_ec2_page_size_injector(event_handlers) cloudformation_init(event_handlers) register_alias_opsworks_cm(event_handlers) register_alias_mturk_command(event_handlers) register_alias_sagemaker_runtime_command(event_handlers) register_servicecatalog_commands(event_handlers) register_history_mode(event_handlers) register_history_commands(event_handlers) register_event_stream_arg(event_handlers) dlm_initialize(event_handlers) register_ssm_session(event_handlers)
#!/usr/bin/env python # encoding: utf-8 ''' Created on 19 Apr 2015 @author: "Waldemar Zurowski" ''' import logging import botocore.session from botocore.hooks import HierarchicalEmitter from awscli.customizations.assumerole import register_assume_role_provider from awscli.customizations.scalarparse import register_scalar_parser logging.basicConfig(level=logging.DEBUG) emitter = HierarchicalEmitter() session = botocore.session.Session(event_hooks=emitter) register_assume_role_provider(emitter) register_scalar_parser(emitter) session.emit('session-initialized', session=session) client = session.create_client('ec2', region_name='eu-west-1') print session.full_config for reservation in client.describe_instances()['Reservations']: for instance in reservation['Instances']: print instance['InstanceId']
def awscli_initialize(event_handlers): event_handlers.register('load-cli-arg', uri_param) param_shorthand = ParamShorthandParser() event_handlers.register('process-cli-arg', param_shorthand) # The s3 error mesage needs to registered before the # generic error handler. register_s3_error_msg(event_handlers) # # The following will get fired for every option we are # # documenting. It will attempt to add an example_fn on to # # the parameter object if the parameter supports shorthand # # syntax. The documentation event handlers will then use # # the examplefn to generate the sample shorthand syntax # # in the docs. Registering here should ensure that this # # handler gets called first but it still feels a bit brittle. # event_handlers.register('doc-option-example.*.*.*', # param_shorthand.add_example_fn) event_handlers.register('doc-examples.*.*', add_examples) register_cli_input_json(event_handlers) event_handlers.register('building-argument-table.*', add_streaming_output_arg) register_count_events(event_handlers) event_handlers.register('building-argument-table.ec2.get-password-data', ec2_add_priv_launch_key) register_parse_global_args(event_handlers) register_pagination(event_handlers) register_secgroup(event_handlers) register_bundleinstance(event_handlers) s3_plugin_initialize(event_handlers) register_runinstances(event_handlers) register_removals(event_handlers) register_preview_commands(event_handlers) register_rds_modify_split(event_handlers) register_add_generate_db_auth_token(event_handlers) register_put_metric_data(event_handlers) register_ses_send_email(event_handlers) IAMVMFAWrapper(event_handlers) register_arg_renames(event_handlers) register_configure_cmd(event_handlers) cloudtrail_init(event_handlers) register_ecr_commands(event_handlers) register_bool_params(event_handlers) register_protocol_args(event_handlers) datapipeline.register_customizations(event_handlers) cloudsearch_init(event_handlers) emr_initialize(event_handlers) register_cloudsearchdomain(event_handlers) register_s3_endpoint(event_handlers) register_generate_cli_skeleton(event_handlers) register_assume_role_provider(event_handlers) register_add_waiters(event_handlers) codedeploy_init(event_handlers) register_subscribe(event_handlers) register_get_status(event_handlers) register_rename_config(event_handlers) register_scalar_parser(event_handlers) opsworks_init(event_handlers) register_lambda_create_function(event_handlers) register_fix_kms_create_grant_docs(event_handlers) register_create_hosted_zone_doc_fix(event_handlers) register_modify_put_configuration_recorder(event_handlers) codecommit_init(event_handlers) register_custom_endpoint_note(event_handlers) event_handlers.register( 'building-argument-table.iot.create-keys-and-certificate', register_create_keys_and_cert_arguments) event_handlers.register( 'building-argument-table.iot.create-certificate-from-csr', register_create_keys_from_csr_arguments) register_cloudfront(event_handlers) register_gamelift_commands(event_handlers) register_ec2_page_size_injector(event_handlers) cloudformation_init(event_handlers) register_alias_opsworks_cm(event_handlers) register_alias_mturk_command(event_handlers) register_alias_sagemaker_runtime_command(event_handlers) register_servicecatalog_commands(event_handlers) register_history_mode(event_handlers) register_history_commands(event_handlers)