def list_components(ctx): """ List components """ return query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='list_components' )
def list_tiers(ctx): """ List tiers """ return query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='list_tiers' )
def list_occurrences(ctx, **query_params): """ List occurrences """ return query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='list_occurrences', query_params=query_params )
def get(ctx, query_text): """ JMESPath query """ result = query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_text=query_text ) click.echo(json.dumps(result, indent=4))
def describe_occurrence_resources(ctx): """ Describes occurrence resources """ result = query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='describe_occurrence_resources', query_params=ctx.obj['query_params'] ) click.echo(json.dumps(result, indent=4))
def describe_occurrence_attributes(ctx): """ Describes occurrence attributes """ result = query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='describe_occurrence_attributes', query_params=ctx.obj['query_params'] ) return result
def describe_occurrence_get(ctx, query_text): """ JMESPath subquery on the described occurrence data """ result = query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='describe_occurrence', query_params=ctx.obj['query_params'], sub_query_text=query_text ) click.echo(json.dumps(result, indent=4))
def query_info_output(options, query, query_params=None, sub_query_text=None): query_args = { **options.opts, "generation_entrance": "info", "output_filename": "info.json", "use_cache": False, } query_result = query_backend.run(**query_args, cwd=os.getcwd(), query_text=query, query_params=query_params, sub_query_text=sub_query_text) return query_result
def describe_occurrence(ctx, **query_params): """ Describes occurrence """ if ctx.invoked_subcommand is not None: ctx.obj['query_params'] = query_params return result = query_backend.run( **ctx.obj['blueprint'], cwd=os.getcwd(), query_name='describe_occurrence', query_params=query_params ) click.echo(json.dumps(result, indent=4))
def list_diagram_types(options): """ Lists the types of diagrams available """ args = { **options.opts, "generation_input_source": "mock", "generation_entrance": "diagraminfo", "output_filename": "diagraminfo.json", "use_cache": False, } return query_backend.run( **args, cwd=os.getcwd(), query_text=LIST_DIAGRAM_TYPES_QUERY )
def get_automation_properties(**kwargs): query_args = { **kwargs, "generation_entrance": "releaseinfo", "output_filename": "releaseinfo-config.json", "output_format": "default", "use_cache": False, } automation_properties = query_backend.run( **query_args, cwd=os.getcwd(), query_text=GET_PROPERTIES_ENVIRONMENT_QUERY) return automation_properties
def list_entrances(options): """ List available entrances """ args = { **options.opts, "generation_input_source": "mock", "generation_entrance": "info", "output_filename": "info.json", "use_cache": False, } return query_backend.run(**args, cwd=os.getcwd(), query_text=LIST_ENTRANCES_QUERY)
def find_schemas_from_options(options, schema): query_args = { **options.opts, "deployment_mode": None, "generation_entrance": "schemalist", "output_filename": "schemalist-schemacontract.json", "use_cache": False, } available_schemas = query_backend.run(**query_args, cwd=os.getcwd(), query_text=LIST_SCHEMAS_QUERY) schemas = [] for available_schema in available_schemas: if re.fullmatch(schema, available_schema["Schema"]): schemas.append(available_schema) return schemas
def find_diagrams_from_options(options, ids): query_args = { **options.opts, "generation_entrance": "diagraminfo", "output_filename": "diagraminfo.json", "use_cache": False, } available_diagrams = query_backend.run( **query_args, cwd=os.getcwd(), query_text=LIST_DIAGRAMS_QUERY ) diagrams = [] for diagram in available_diagrams: for id in ids: if re.fullmatch(id, diagram["Id"]): diagrams.append(diagram) return diagrams
def find_deployments( deployment_mode, deployment_group, deployment_units, deployment_states=["deployed", "notdeployed"], districts=["segment"], **kwargs, ): query_args = { **kwargs, "deployment_mode": deployment_mode, "generation_entrance": "unitlist", "output_filename": "unitlist-managementcontract.json", "use_cache": False, } available_deployments = query_backend.run( **query_args, cwd=os.getcwd(), query_text=LIST_DEPLOYMENTS_QUERY) deployments = [] for deployment in available_deployments: if "District" not in deployment: if deployment["DeploymentGroup"] == "account": deployment["District"] = "account" else: deployment["District"] = "segment" if deployment["District"] in districts: if re.fullmatch(deployment_group, deployment["DeploymentGroup"]): for deployment_unit in deployment_units: if re.fullmatch(deployment_unit, deployment["DeploymentUnit"]): if deployment["CurrentState"] in deployment_states: deployments.append(deployment) return deployments
def run_runbook(options, name, confirm, silent, inputs, **kwargs): """ Run a runbook Runbook inputs are provided as Key=Value inputs """ runbook_description = query_runbookinfo_state( options=options, query=DESCRIBE_RUNBOOK_QUERY, query_params={"name": name}, ) if runbook_description is None: raise exceptions.CommandError("No runbooks found with the provided name") if not silent: click.echo("") click.secho(f"[*] {name}", bold=True, fg="green") if runbook_description["Description"] != "": click.secho( f"[*] {runbook_description['Description']}", bold=True, fg="green" ) click.echo("") if not silent or ((confirm and click.confirm("Start Runbook?")) or not confirm): query_args = { **options.opts, "generation_entrance": "runbook", "generation_entrance_parameter": ( f"RunBook={name}", f"RunBookInputs={json.dumps(inputs)}", ), "output_filename": "runbook-contract.json", "use_cache": False, } contract = query_backend.run(**query_args, cwd=os.getcwd(), query=None) contract_backend.run(contract, silent)