content: module Io.Superposition.Command.GetContextFromCondition (
      GetContextFromConditionError (..),
      getContextFromCondition
  ) where
  import qualified Data.Aeson
  import qualified Data.Maybe
  import qualified Data.Text
  import qualified GHC.Generics
  import qualified GHC.Show
  import qualified Io.Superposition.Model.GetContextFromConditionInput
  import qualified Io.Superposition.Model.GetContextFromConditionOutput
  import qualified Io.Superposition.Model.InternalServerError
  import qualified Io.Superposition.Model.ResourceNotFound
  import qualified Io.Superposition.SuperpositionClient
  import qualified Io.Superposition.Utility
  
  data GetContextFromConditionError =
      ResourceNotFound Io.Superposition.Model.ResourceNotFound.ResourceNotFound
      | InternalServerError Io.Superposition.Model.InternalServerError.InternalServerError
      | BuilderError Data.Text.Text
      | DeSerializationError Io.Superposition.Utility.HttpMetadata Data.Text.Text
      | UnexpectedError (Data.Maybe.Maybe Io.Superposition.Utility.HttpMetadata) Data.Text.Text
         deriving (GHC.Generics.Generic, GHC.Show.Show)
  
  instance Data.Aeson.ToJSON GetContextFromConditionError
  instance Io.Superposition.Utility.OperationError GetContextFromConditionError where
      mkBuilderError = BuilderError
      mkDeSerializationError = DeSerializationError
      mkUnexpectedError = UnexpectedError
  
      getErrorParser status
          | status == (Io.Superposition.Utility.expectedStatus @Io.Superposition.Model.ResourceNotFound.ResourceNotFound) = Just (fmap ResourceNotFound (Io.Superposition.Utility.responseParser @Io.Superposition.Model.ResourceNotFound.ResourceNotFound))
          | status == (Io.Superposition.Utility.expectedStatus @Io.Superposition.Model.InternalServerError.InternalServerError) = Just (fmap InternalServerError (Io.Superposition.Utility.responseParser @Io.Superposition.Model.InternalServerError.InternalServerError))
          | otherwise = Nothing
  
  
  getContextFromCondition :: Io.Superposition.SuperpositionClient.SuperpositionClient -> Io.Superposition.Model.GetContextFromConditionInput.GetContextFromConditionInputBuilder () -> IO (Either GetContextFromConditionError Io.Superposition.Model.GetContextFromConditionOutput.GetContextFromConditionOutput)
  getContextFromCondition client builder =
      let endpoint = Io.Superposition.SuperpositionClient.endpointUri client
          manager = Io.Superposition.SuperpositionClient.httpManager client
          token = Io.Superposition.SuperpositionClient.token client
          setAuth = Io.Superposition.Utility.serHeader "Authorization" ("Bearer " <> token)
      in Io.Superposition.Utility.runOperation endpoint manager setAuth (Io.Superposition.Model.GetContextFromConditionInput.build builder)
  
  