{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE TypeApplications #-}

module Hercules.API.Labels where

import Control.Lens ((?~))
import Data.Aeson (Value)
import Data.Function ((&))
import Data.Swagger
import Hercules.API.Prelude

newtype Labels = Labels {Labels -> Map Text Value
fromLabels :: Map Text Value}
  deriving newtype (Int -> Labels -> ShowS
[Labels] -> ShowS
Labels -> String
(Int -> Labels -> ShowS)
-> (Labels -> String) -> ([Labels] -> ShowS) -> Show Labels
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Labels] -> ShowS
$cshowList :: [Labels] -> ShowS
show :: Labels -> String
$cshow :: Labels -> String
showsPrec :: Int -> Labels -> ShowS
$cshowsPrec :: Int -> Labels -> ShowS
Show, Labels -> Labels -> Bool
(Labels -> Labels -> Bool)
-> (Labels -> Labels -> Bool) -> Eq Labels
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Labels -> Labels -> Bool
$c/= :: Labels -> Labels -> Bool
== :: Labels -> Labels -> Bool
$c== :: Labels -> Labels -> Bool
Eq, Labels -> ()
(Labels -> ()) -> NFData Labels
forall a. (a -> ()) -> NFData a
rnf :: Labels -> ()
$crnf :: Labels -> ()
NFData, [Labels] -> Encoding
[Labels] -> Value
Labels -> Encoding
Labels -> Value
(Labels -> Value)
-> (Labels -> Encoding)
-> ([Labels] -> Value)
-> ([Labels] -> Encoding)
-> ToJSON Labels
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
toEncodingList :: [Labels] -> Encoding
$ctoEncodingList :: [Labels] -> Encoding
toJSONList :: [Labels] -> Value
$ctoJSONList :: [Labels] -> Value
toEncoding :: Labels -> Encoding
$ctoEncoding :: Labels -> Encoding
toJSON :: Labels -> Value
$ctoJSON :: Labels -> Value
ToJSON, Value -> Parser [Labels]
Value -> Parser Labels
(Value -> Parser Labels)
-> (Value -> Parser [Labels]) -> FromJSON Labels
forall a.
(Value -> Parser a) -> (Value -> Parser [a]) -> FromJSON a
parseJSONList :: Value -> Parser [Labels]
$cparseJSONList :: Value -> Parser [Labels]
parseJSON :: Value -> Parser Labels
$cparseJSON :: Value -> Parser Labels
FromJSON)

instance ToSchema Labels where
  declareNamedSchema :: Proxy Labels -> Declare (Definitions Schema) NamedSchema
declareNamedSchema Proxy Labels
_p = do
    NamedSchema -> Declare (Definitions Schema) NamedSchema
forall (m :: * -> *) a. Monad m => a -> m a
return (NamedSchema -> Declare (Definitions Schema) NamedSchema)
-> NamedSchema -> Declare (Definitions Schema) NamedSchema
forall a b. (a -> b) -> a -> b
$
      Maybe Text -> Schema -> NamedSchema
NamedSchema (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
"Labels") (Schema -> NamedSchema) -> Schema -> NamedSchema
forall a b. (a -> b) -> a -> b
$
        Schema
forall a. Monoid a => a
mempty
          Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (Maybe (SwaggerType 'SwaggerKindSchema)
 -> Identity (Maybe (SwaggerType 'SwaggerKindSchema)))
-> Schema -> Identity Schema
forall s a. HasType s a => Lens' s a
type_ ((Maybe (SwaggerType 'SwaggerKindSchema)
  -> Identity (Maybe (SwaggerType 'SwaggerKindSchema)))
 -> Schema -> Identity Schema)
-> SwaggerType 'SwaggerKindSchema -> Schema -> Schema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ SwaggerType 'SwaggerKindSchema
SwaggerObject
          Schema -> (Schema -> Schema) -> Schema
forall a b. a -> (a -> b) -> b
& (Maybe AdditionalProperties
 -> Identity (Maybe AdditionalProperties))
-> Schema -> Identity Schema
forall s a. HasAdditionalProperties s a => Lens' s a
additionalProperties ((Maybe AdditionalProperties
  -> Identity (Maybe AdditionalProperties))
 -> Schema -> Identity Schema)
-> AdditionalProperties -> Schema -> Schema
forall s t a b. ASetter s t a (Maybe b) -> b -> s -> t
?~ (Bool -> AdditionalProperties
AdditionalPropertiesAllowed Bool
True)