RunWhen slos API

The slos API from RunWhen — 4 operation(s) for slos.

OpenAPI Specification

runwhen-slos-api-openapi.yml Raw ↑
openapi: 3.1.0
info:
  title: papi alert-query-proxy slos API
  description: RunWhen Platform API
  version: 2.0.0
tags:
- name: slos
paths:
  /api/v1/workspaces/{workspace_name}/slxs/{slx_short_name}/slo:
    get:
      tags:
      - slos
      summary: Get the SLO for an SLX
      description: "Get the SLO for an SLX.\n\nSLX and SLO have a 1:1 relationship. This endpoint returns the single\nSLO associated with the specified SLX, or 404 if no SLO exists.\n\nArgs:\n    workspace_name: The workspace name.\n    slx_short_name: The SLX short name.\n    _detail: Django parity query param (ignored).\n    session: Database session.\n    current_user: The authenticated user.\n\nReturns:\n    The SLO details.\n\nRaises:\n    HTTPException: 404 if workspace, SLX, or SLO not found."
      operationId: get_slx_slo_api_v1_workspaces__workspace_name__slxs__slx_short_name__slo_get
      parameters:
      - name: workspace_name
        in: path
        required: true
        schema:
          type: string
          title: Workspace Name
      - name: slx_short_name
        in: path
        required: true
        schema:
          type: string
          title: Slx Short Name
      - name: detail
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Accepted for Django parity; ignored (always returns full detail)
          title: Detail
        description: Accepted for Django parity; ignored (always returns full detail)
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/papi__schemas__slo__SloResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
      - BearerAuth: []
  /api/v1/workspaces/{workspace_name}/slxs/{slx_short_name}/slo/objective-recommendation:
    get:
      tags:
      - slos
      summary: Get SLO objective recommendation for an SLX
      description: 'Calculate a recommended SLO objective for an SLX.


        Two paths:

        - **Has SLO:** Recommends based on the current month''s error budget burn rate.

        - **No SLO:** Recommends based on 30 days of historical SLI healthiness data.


        Mirrors Django''s SloViewSet.slo_objective_recommendation().'
      operationId: objective_recommendation_api_v1_workspaces__workspace_name__slxs__slx_short_name__slo_objective_recommendation_get
      parameters:
      - name: workspace_name
        in: path
        required: true
        schema:
          type: string
          title: Workspace Name
      - name: slx_short_name
        in: path
        required: true
        schema:
          type: string
          title: Slx Short Name
      - name: baseline
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: PromQL timestring defining the baseline window for the burn-rate calculation (e.g. '2h', '1d'). Defaults to hours elapsed since the 1st of the current month. Only used when an SLO exists. Must not exceed hours since month start.
          title: Baseline
        description: PromQL timestring defining the baseline window for the burn-rate calculation (e.g. '2h', '1d'). Defaults to hours elapsed since the 1st of the current month. Only used when an SLO exists. Must not exceed hours since month start.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectiveRecommendationResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
      - BearerAuth: []
  /api/v3/workspaces/{workspace_name}/slxs/{slx_short_name}/slo:
    get:
      tags:
      - slos
      summary: Get the SLO for an SLX
      description: "Get the SLO for an SLX.\n\nSLX and SLO have a 1:1 relationship. This endpoint returns the single\nSLO associated with the specified SLX, or 404 if no SLO exists.\n\nArgs:\n    workspace_name: The workspace name.\n    slx_short_name: The SLX short name.\n    _detail: Django parity query param (ignored).\n    session: Database session.\n    current_user: The authenticated user.\n\nReturns:\n    The SLO details.\n\nRaises:\n    HTTPException: 404 if workspace, SLX, or SLO not found."
      operationId: get_slx_slo_api_v3_workspaces__workspace_name__slxs__slx_short_name__slo_get
      parameters:
      - name: workspace_name
        in: path
        required: true
        schema:
          type: string
          title: Workspace Name
      - name: slx_short_name
        in: path
        required: true
        schema:
          type: string
          title: Slx Short Name
      - name: detail
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: Accepted for Django parity; ignored (always returns full detail)
          title: Detail
        description: Accepted for Django parity; ignored (always returns full detail)
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/papi__schemas__slo__SloResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
      - BearerAuth: []
  /api/v3/workspaces/{workspace_name}/slxs/{slx_short_name}/slo/objective-recommendation:
    get:
      tags:
      - slos
      summary: Get SLO objective recommendation for an SLX
      description: 'Calculate a recommended SLO objective for an SLX.


        Two paths:

        - **Has SLO:** Recommends based on the current month''s error budget burn rate.

        - **No SLO:** Recommends based on 30 days of historical SLI healthiness data.


        Mirrors Django''s SloViewSet.slo_objective_recommendation().'
      operationId: objective_recommendation_api_v3_workspaces__workspace_name__slxs__slx_short_name__slo_objective_recommendation_get
      parameters:
      - name: workspace_name
        in: path
        required: true
        schema:
          type: string
          title: Workspace Name
      - name: slx_short_name
        in: path
        required: true
        schema:
          type: string
          title: Slx Short Name
      - name: baseline
        in: query
        required: false
        schema:
          anyOf:
          - type: string
          - type: 'null'
          description: PromQL timestring defining the baseline window for the burn-rate calculation (e.g. '2h', '1d'). Defaults to hours elapsed since the 1st of the current month. Only used when an SLO exists. Must not exceed hours since month start.
          title: Baseline
        description: PromQL timestring defining the baseline window for the burn-rate calculation (e.g. '2h', '1d'). Defaults to hours elapsed since the 1st of the current month. Only used when an SLO exists. Must not exceed hours since month start.
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ObjectiveRecommendationResponse'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
      - BearerAuth: []
components:
  schemas:
    ObjectiveRecommendationResponse:
      properties:
        currentErrorBudget:
          anyOf:
          - type: number
          - type: 'null'
          title: Currenterrorbudget
          description: Most recent error budget reading. None when no SLO exists.
        monthProgress:
          type: number
          title: Monthprogress
          description: Fraction of the current calendar month elapsed (0.0–1.0).
        projectedEndOfMonth:
          anyOf:
          - type: number
          - type: 'null'
          title: Projectedendofmonth
          description: Projected error budget at end of month assuming linear burn rate. None when no SLO exists. May be negative when burn rate exceeds 100%.
        currentObjective:
          anyOf:
          - type: number
          - type: 'null'
          title: Currentobjective
          description: Current SLO objective percentage (e.g. 99.9). None when no SLO exists.
        recommendedObjective:
          type: number
          title: Recommendedobjective
          description: Recommended SLO objective percentage, clamped to [0.5, 99.99].
        baselinePeriod:
          type: string
          title: Baselineperiod
          description: PromQL timestring used as the calculation baseline (e.g. '168h', '30d'). '30d' for SLI-based recommendations.
        hasSlo:
          type: boolean
          title: Hasslo
          description: True when an SLO exists for this SLX.
        recommendationSource:
          type: string
          title: Recommendationsource
          description: 'How the recommendation was derived: ''error_budget'' (SLO burn rate), ''sli_data'' (historical SLI healthiness), or ''default'' (insufficient data).'
      type: object
      required:
      - monthProgress
      - recommendedObjective
      - baselinePeriod
      - hasSlo
      - recommendationSource
      title: ObjectiveRecommendationResponse
      description: 'SLO objective recommendation response.


        Matches Django''s SloViewSet.slo_objective_recommendation() response shape exactly.

        Used by agentfarm''s papi_client.fetch_slo_recommendation().


        Django''s DRF uses djangorestframework-camel-case to auto-convert snake_case → camelCase.

        We replicate that with alias_generator so agentfarm''s SLORecommendation(extra="forbid")

        receives the expected camelCase keys.'
    papi__schemas__slo__SloResponse:
      properties:
        slxId:
          type: integer
          title: Slxid
        sloSpecType:
          type: string
          title: Slospectype
          default: simple-mwmb
        objective:
          type: number
          title: Objective
          default: 99.9
        threshold:
          type: integer
          title: Threshold
          default: 9
        operand:
          type: string
          title: Operand
          default: eq
        codeBundleRepoUrl:
          anyOf:
          - type: string
          - type: 'null'
          title: Codebundlerepourl
        codeBundleRef:
          anyOf:
          - type: string
          - type: 'null'
          title: Codebundleref
        codeBundlePathToYaml:
          anyOf:
          - type: string
          - type: 'null'
          title: Codebundlepathtoyaml
        repositoryId:
          anyOf:
          - type: integer
          - type: 'null'
          title: Repositoryid
        generation:
          type: integer
          title: Generation
          default: 0
        generationChecksum:
          anyOf:
          - type: string
          - type: 'null'
          title: Generationchecksum
        ruleGroups:
          anyOf:
          - items:
              additionalProperties: true
              type: object
            type: array
          - type: 'null'
          title: Rulegroups
        firingAlerts:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Firingalerts
        lastSevenDaysAlerts:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Lastsevendaysalerts
        alertCount:
          items:
            additionalProperties: true
            type: object
          type: array
          title: Alertcount
        monthErrorBudgetRemaining:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Montherrorbudgetremaining
        thirtyDayErrorBudgetRemaining:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Thirtydayerrorbudgetremaining
        recent:
          anyOf:
          - additionalProperties: true
            type: object
          - type: 'null'
          title: Recent
        created:
          type: string
          format: date-time
          title: Created
          description: Creation timestamp
        modified:
          type: string
          format: date-time
          title: Modified
          description: Last update timestamp
        spec:
          additionalProperties: true
          type: object
          title: Spec
          description: Spec dict matching Django CoreModelSerializer shape.
          readOnly: true
        status:
          additionalProperties: true
          type: object
          title: Status
          description: Status dict matching Django CoreModelSerializer shape.
          readOnly: true
      type: object
      required:
      - slxId
      - created
      - modified
      - spec
      - status
      title: SloResponse
      description: "Legacy V1/V3 shape: V4 fields + computed ``spec`` and ``status`` for Django-era consumers.\n\nSubclassing keeps flat fields in lock-step with V4. Computed fields rebuild the\nCRD-shape sub-objects from flat ones at serialization time. Sunset path: when\nexternal consumers fully migrate to /api/v4, delete this subclass.\n\nLegacy wire keys preserved by overriding aliased timestamp fields:\n  - ``created_at`` → alias ``created``   (was ``createdAt`` in V4)\n  - ``modified_at`` → alias ``modified``  (was ``modifiedAt`` in V4)"
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
            - type: string
            - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
        input:
          title: Input
        ctx:
          type: object
          title: Context
      type: object
      required:
      - loc
      - msg
      - type
      title: ValidationError
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: JWT access token from /api/v3/token/ or Auth0 login