Class: Infrawrench::IncidentsNamespace

Inherits:
Object
  • Object
show all
Defined in:
lib/infrawrench/client.rb,
sig/infrawrench/sdk.rbs

Overview

client.incidents

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(transport) ⇒ IncidentsNamespace

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of IncidentsNamespace.

Parameters:



7897
7898
7899
7900
7901
# File 'lib/infrawrench/client.rb', line 7897

def initialize(transport)
  @transport = transport
  @get = IncidentsGetNamespace.new(@transport)
  @notes = IncidentsNotesNamespace.new(@transport)
end

Instance Attribute Details

#getIncidentsGetNamespace (readonly)

Returns client.incidents.get.

Returns:



7891
7892
7893
# File 'lib/infrawrench/client.rb', line 7891

def get
  @get
end

#notesIncidentsNotesNamespace (readonly)

Returns client.incidents.notes.

Returns:



7893
7894
7895
# File 'lib/infrawrench/client.rb', line 7893

def notes
  @notes
end

Instance Method Details

#create(org_id: nil, body: nil, request_options: nil) ⇒ Hash

Declare an incident

Record the incident and perform the opted-in side effects. The incident row is written first and alone: a 201 means it exists, and the artifacts array on the response says what else happened. No side effect can lose the declaration, and none is swallowed. Audit-logged.

Requires permission: incidents:write.

POST /api/org/orgId/incidents

Raises on 400: Bad request

Raises on 403: Forbidden

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as IncidentDeclare.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • org_id: (String, nil) (defaults to: nil)
  • body: (incident_declare, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Incident — see sig/infrawrench/sdk.rbs.

Raises:



7924
7925
7926
7927
7928
7929
7930
7931
7932
# File 'lib/infrawrench/client.rb', line 7924

def create(org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/incidents",
    path_params: { "orgId" => org_id },
    body: body,
    request_options: request_options
  )
end

#delete(incident_id:, org_id: nil, request_options: nil) ⇒ nil

Delete an incident

Removes the incident, its notes and its artefact records. It does not lift a freeze or close a status-page update — resolve for that; deleting is for a mis-declaration. Audit-logged.

Requires permission: incidents:write.

DELETE /api/org/orgId/incidents/incidentId

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • incident_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • incident_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (nil)

    This endpoint returns no content.

Raises:



7952
7953
7954
7955
7956
7957
7958
7959
7960
# File 'lib/infrawrench/client.rb', line 7952

def delete(incident_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "DELETE",
    path: "/api/org/{orgId}/incidents/{incidentId}",
    path_params: { "orgId" => org_id, "incidentId" => incident_id },
    accept: :empty,
    request_options: request_options
  )
end

#postmortem(incident_id:, org_id: nil, request_options: nil) ⇒ Hash

Export a pre-filled postmortem

Markdown with the timeline, the affected resources, the duration, the time to mitigate and the notes already filled in. The analysis headings — impact, root cause, action items — are deliberately left blank: a generated document that guesses at a root cause is worse than one that leaves a heading.

Requires permission: incidents:read.

GET /api/org/orgId/incidents/incidentId/postmortem

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • incident_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • incident_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as IncidentPostmortem — see sig/infrawrench/sdk.rbs.

Raises:



7983
7984
7985
7986
7987
7988
7989
7990
# File 'lib/infrawrench/client.rb', line 7983

def postmortem(incident_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/incidents/{incidentId}/postmortem",
    path_params: { "orgId" => org_id, "incidentId" => incident_id },
    request_options: request_options
  )
end

#retry_artifacts(incident_id:, org_id: nil, request_options: nil) ⇒ Hash

Retry the artefacts that failed

Re-runs only the side effects whose artefact is in a failure state, replacing each failure rather than queueing a second attempt beside it. A failed artefact is re-created; a close_failed one is re-closed — re-creating the latter would open a second change freeze or post a duplicate public notice. A status-page retry reuses the components recorded on the artefact's request, so the announcement keeps its original scope. Its own endpoint rather than a flag on PATCH, because it writes into three external systems. Audit-logged.

Requires permission: incidents:write.

POST /api/org/orgId/incidents/incidentId/retry-artifacts

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • incident_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • incident_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Incident — see sig/infrawrench/sdk.rbs.

Raises:



8015
8016
8017
8018
8019
8020
8021
8022
# File 'lib/infrawrench/client.rb', line 8015

def retry_artifacts(incident_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "POST",
    path: "/api/org/{orgId}/incidents/{incidentId}/retry-artifacts",
    path_params: { "orgId" => org_id, "incidentId" => incident_id },
    request_options: request_options
  )
end

#timeline(incident_id:, org_id: nil, request_options: nil) ⇒ Hash

Assemble the incident's timeline

Merged on read from what is already recorded between the incident's start and its resolution: resource changes, deployments, cost anomalies, provider status incidents, audit entries, change freezes and workflow runs (all via the same union the Moment screen uses), plus probe state transitions, metric-alert firings, the incident's own life events, its artefacts and its operator notes. Nothing is copied — a correction upstream shows up here on the next read.

Probe transitions are an approximation: synthetic_probes keeps only a single lastStateChangeAt, so a probe that flapped twice inside the window contributes its most recent flip and no more.

Requires permission: incidents:read.

GET /api/org/orgId/incidents/incidentId/timeline

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • incident_id (String)
  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • incident_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as IncidentTimeline — see sig/infrawrench/sdk.rbs.

Raises:



8050
8051
8052
8053
8054
8055
8056
8057
# File 'lib/infrawrench/client.rb', line 8050

def timeline(incident_id:, org_id: nil, request_options: nil)
  @transport.request(
    http_method: "GET",
    path: "/api/org/{orgId}/incidents/{incidentId}/timeline",
    path_params: { "orgId" => org_id, "incidentId" => incident_id },
    request_options: request_options
  )
end

#update(incident_id:, org_id: nil, body: nil, request_options: nil) ⇒ Hash

Edit or transition an incident

Omitted fields keep their value. Setting status stamps the matching timestamp, and resolving undoes exactly what this incident created — the freeze whose id is on its own artefact, not whatever freeze happens to be in effect. Resolving an incident that was never marked mitigated back-fills mitigatedAt from resolvedAt. Audit-logged.

Requires permission: incidents:write.

PATCH /api/org/orgId/incidents/incidentId

Raises on 400: Bad request

Raises on 404: Not found

Parameters:

  • org_id (String, nil) (defaults to: nil)

    Organization id. Defaults to the org_id the client was constructed with.

  • incident_id (String)
  • body (Hash, nil) (defaults to: nil)

    Request body, shaped as IncidentPatch.

  • request_options (Hash, nil) (defaults to: nil)

    Per-call :headers, :timeout and :open_timeout.

  • incident_id: (String)
  • org_id: (String, nil) (defaults to: nil)
  • body: (incident_patch, nil) (defaults to: nil)
  • request_options: (Hash[Symbol, untyped], nil) (defaults to: nil)

Returns:

  • (Hash)

    Parsed JSON, shaped as Incident — see sig/infrawrench/sdk.rbs.

Raises:



8082
8083
8084
8085
8086
8087
8088
8089
8090
# File 'lib/infrawrench/client.rb', line 8082

def update(incident_id:, org_id: nil, body: nil, request_options: nil)
  @transport.request(
    http_method: "PATCH",
    path: "/api/org/{orgId}/incidents/{incidentId}",
    path_params: { "orgId" => org_id, "incidentId" => incident_id },
    body: body,
    request_options: request_options
  )
end