def select_service_and_operation(): service_names = Session().get_available_services() service_completer = WordCompleter(service_names) service_name = prompt(u'Select service: ', completer=service_completer) if service_name not in service_names: click.secho(u'{} is not valid service'.format(service_name), fg='red') raise click.Abort() moto_client = get_moto_implementation(service_name) real_client = boto3.client(service_name, region_name='us-east-1') implemented = [] not_implemented = [] operation_names = [xform_name(op) for op in real_client.meta.service_model.operation_names] for op in operation_names: if moto_client and op in dir(moto_client): implemented.append(op) else: not_implemented.append(op) operation_completer = WordCompleter(operation_names) click.echo('==Current Implementation Status==') for operation_name in operation_names: check = 'X' if operation_name in implemented else ' ' click.secho('[{}] {}'.format(check, operation_name)) click.echo('=================================') operation_name = prompt(u'Select Operation: ', completer=operation_completer) if operation_name not in operation_names: click.secho('{} is not valid operation'.format(operation_name), fg='red') raise click.Abort() if operation_name in implemented: click.secho('{} is already implemented'.format(operation_name), fg='red') raise click.Abort() return service_name, operation_name
def get_operations(service_name): try: moto_client, _name = get_moto_implementation(service_name) except ModuleNotFoundError: moto_client = None real_client = boto3.client(service_name, region_name="us-east-1") implemented = [] operation_names = [ xform_name(op) for op in real_client.meta.service_model.operation_names ] for operation in operation_names: if moto_client and operation in dir(moto_client): implemented.append(operation) return implemented, operation_names
def select_service_and_operation(): service_names = Session().get_available_services() service_completer = WordCompleter(service_names) service_name = prompt("Select service: ", completer=service_completer) if service_name not in service_names: click.secho("{} is not valid service".format(service_name), fg="red") raise click.Abort() moto_client = get_moto_implementation(service_name) real_client = boto3.client(service_name, region_name="us-east-1") implemented = [] not_implemented = [] operation_names = [ xform_name(op) for op in real_client.meta.service_model.operation_names ] for operation in operation_names: if moto_client and operation in dir(moto_client): implemented.append(operation) else: not_implemented.append(operation) operation_completer = WordCompleter(operation_names) click.echo("==Current Implementation Status==") for operation_name in operation_names: check = "X" if operation_name in implemented else " " click.secho("[{}] {}".format(check, operation_name)) click.echo("=================================") operation_name = prompt("Select Operation: ", completer=operation_completer) if operation_name not in operation_names: click.secho("{} is not valid operation".format(operation_name), fg="red") raise click.Abort() if operation_name in implemented: click.secho("{} is already implemented".format(operation_name), fg="red") raise click.Abort() return service_name, operation_name