Exemple #1
0
def show(state, alert_id, include_observations):
    """Display the details of a single alert."""
    formatter = OutputFormatter(OutputFormat.TABLE,
                                _get_default_output_header())

    try:
        response = state.sdk.alerts.get_details(alert_id)
    except Py42NotFoundError:
        raise errors.Code42CLIError(f"No alert found with ID '{alert_id}'.")

    alert = response["alerts"][0]
    formatter.echo_formatted_list([alert])

    # Show note details
    note = alert.get("note")
    if note:
        click.echo("\nNote:\n")
        click.echo(format_dict(note))

    if include_observations:
        observations = alert.get("observations")
        if observations:
            click.echo("\nObservations:\n")
            click.echo(format_dict(observations))
        else:
            click.echo("\nNo observations found.")
Exemple #2
0
def _print_request(method, url, params=None, data=None, json=None):
    debug.logger.info(f"{method.ljust(8)}{url}")
    if params:
        debug.logger.debug(format_dict(params, "  params"))
    if json:
        debug.logger.debug(format_dict(json, "  json"))
    if data:
        debug.logger.debug(data, "  data")
Exemple #3
0
 def _is_job_complete(self, job_id):
     response = self._storage_archive_service.get_restore_status(job_id)
     is_done = response["done"]
     percentage_dict = {
         "jobId": job_id,
         "status": response.data.get("status"),
         "percentComplete":
         response["percentComplete"] if not is_done else 100,
     }
     debug.logger.debug(format_dict(percentage_dict))
     return is_done
Exemple #4
0
 def _is_job_complete(self, job_id):
     response = self._storage_archive_client.get_restore_status(job_id)
     is_done = response[u"done"]
     percentage_dict = {
         u"jobId":
         job_id,
         u"status":
         response[u"status"],
         u"percentComplete":
         response[u"percentComplete"] if not is_done else 100,
     }
     debug.logger.debug(format_dict(percentage_dict))
     return is_done
Exemple #5
0
def _print_file_size(size_dict):
    debug.logger.debug(format_dict(size_dict))
Exemple #6
0
def _print_request(method, url, params=None, data=None):
    debug.logger.info(u"{}{}".format(method.ljust(8), url))
    if params:
        debug.logger.debug(format_dict(params, u"  params"))
    if data:
        debug.logger.debug(format_dict(data, u"  data"))