{-
   Alertmanager API
   API of the Prometheus Alertmanager (https://github.com/prometheus/alertmanager)

   OpenAPI spec version: 0.0.1

   NOTE: This file is auto generated by the openapi-generator.
   https://github.com/openapitools/openapi-generator.git
   Do not edit this file manually.
-}


module Data.GettableAlert exposing (GettableAlert, decoder, encoder)

import Data.AlertStatus as AlertStatus exposing (AlertStatus)
import Data.Receiver as Receiver exposing (Receiver)
import DateTime exposing (DateTime)
import Dict exposing (Dict)
import Json.Decode as Decode exposing (Decoder)
import Json.Decode.Pipeline exposing (optional, required)
import Json.Encode as Encode


type alias GettableAlert =
    { labels : Dict String String
    , generatorURL : Maybe String
    , annotations : Dict String String
    , receivers : List Receiver
    , fingerprint : String
    , startsAt : DateTime
    , updatedAt : DateTime
    , endsAt : DateTime
    , status : AlertStatus
    }


decoder : Decoder GettableAlert
decoder =
    Decode.succeed GettableAlert
        |> required "labels" (Decode.dict Decode.string)
        |> optional "generatorURL" (Decode.nullable Decode.string) Nothing
        |> required "annotations" (Decode.dict Decode.string)
        |> required "receivers" (Decode.list Receiver.decoder)
        |> required "fingerprint" Decode.string
        |> required "startsAt" DateTime.decoder
        |> required "updatedAt" DateTime.decoder
        |> required "endsAt" DateTime.decoder
        |> required "status" AlertStatus.decoder


encoder : GettableAlert -> Encode.Value
encoder model =
    Encode.object
        [ ( "labels", Encode.dict identity Encode.string model.labels )
        , ( "generatorURL", Maybe.withDefault Encode.null (Maybe.map Encode.string model.generatorURL) )
        , ( "annotations", Encode.dict identity Encode.string model.annotations )
        , ( "receivers", Encode.list Receiver.encoder model.receivers )
        , ( "fingerprint", Encode.string model.fingerprint )
        , ( "startsAt", DateTime.encoder model.startsAt )
        , ( "updatedAt", DateTime.encoder model.updatedAt )
        , ( "endsAt", DateTime.encoder model.endsAt )
        , ( "status", AlertStatus.encoder model.status )
        ]
