Skip to content

Commit

Permalink
Regenerating with improved nullary enum FromText instances
Browse files Browse the repository at this point in the history
  • Loading branch information
brendanhay committed Nov 24, 2014
1 parent 316b0bb commit e87cb27
Show file tree
Hide file tree
Showing 35 changed files with 2,218 additions and 1,477 deletions.
52 changes: 29 additions & 23 deletions amazonka-autoscaling/gen/Network/AWS/AutoScaling/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2012,19 +2012,22 @@ data LifecycleState
instance Hashable LifecycleState

instance FromText LifecycleState where
parser = match "Detached" Detached
<|> match "Detaching" Detaching
<|> match "EnteringStandby" EnteringStandby
<|> match "InService" InService
<|> match "Pending" Pending
<|> match "Pending:Proceed" PendingProceed
<|> match "Pending:Wait" PendingWait
<|> match "Quarantined" Quarantined
<|> match "Standby" Standby
<|> match "Terminated" Terminated
<|> match "Terminating" Terminating
<|> match "Terminating:Proceed" TerminatingProceed
<|> match "Terminating:Wait" TerminatingWait
parser = takeText >>= \case
"Detached" -> pure Detached
"Detaching" -> pure Detaching
"EnteringStandby" -> pure EnteringStandby
"InService" -> pure InService
"Pending" -> pure Pending
"Pending:Proceed" -> pure PendingProceed
"Pending:Wait" -> pure PendingWait
"Quarantined" -> pure Quarantined
"Standby" -> pure Standby
"Terminated" -> pure Terminated
"Terminating" -> pure Terminating
"Terminating:Proceed" -> pure TerminatingProceed
"Terminating:Wait" -> pure TerminatingWait
e -> fail $
"Failure parsing LifecycleState from " ++ show e

instance ToText LifecycleState where
toText = \case
Expand Down Expand Up @@ -2159,16 +2162,19 @@ data ScalingActivityStatusCode
instance Hashable ScalingActivityStatusCode

instance FromText ScalingActivityStatusCode where
parser = match "Cancelled" Cancelled
<|> match "Failed" Failed
<|> match "InProgress" InProgress
<|> match "MidLifecycleAction" MidLifecycleAction
<|> match "PreInService" PreInService
<|> match "Successful" Successful
<|> match "WaitingForELBConnectionDraining" WaitingForELBConnectionDraining
<|> match "WaitingForInstanceId" WaitingForInstanceId
<|> match "WaitingForSpotInstanceId" WaitingForSpotInstanceId
<|> match "WaitingForSpotInstanceRequestId" WaitingForSpotInstanceRequestId
parser = takeText >>= \case
"Cancelled" -> pure Cancelled
"Failed" -> pure Failed
"InProgress" -> pure InProgress
"MidLifecycleAction" -> pure MidLifecycleAction
"PreInService" -> pure PreInService
"Successful" -> pure Successful
"WaitingForELBConnectionDraining" -> pure WaitingForELBConnectionDraining
"WaitingForInstanceId" -> pure WaitingForInstanceId
"WaitingForSpotInstanceId" -> pure WaitingForSpotInstanceId
"WaitingForSpotInstanceRequestId" -> pure WaitingForSpotInstanceRequestId
e -> fail $
"Failure parsing ScalingActivityStatusCode from " ++ show e

instance ToText ScalingActivityStatusCode where
toText = \case
Expand Down
79 changes: 47 additions & 32 deletions amazonka-cloudformation/gen/Network/AWS/CloudFormation/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -252,22 +252,25 @@ data StackStatus
instance Hashable StackStatus

instance FromText StackStatus where
parser = match "CREATE_COMPLETE" CreateComplete
<|> match "CREATE_FAILED" CreateFailed
<|> match "CREATE_IN_PROGRESS" CreateInProgress
<|> match "DELETE_COMPLETE" DeleteComplete
<|> match "DELETE_FAILED" DeleteFailed
<|> match "DELETE_IN_PROGRESS" DeleteInProgress
<|> match "ROLLBACK_COMPLETE" RollbackComplete
<|> match "ROLLBACK_FAILED" RollbackFailed
<|> match "ROLLBACK_IN_PROGRESS" RollbackInProgress
<|> match "UPDATE_COMPLETE" UpdateComplete
<|> match "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS" UpdateCompleteCleanupInProgress
<|> match "UPDATE_IN_PROGRESS" UpdateInProgress
<|> match "UPDATE_ROLLBACK_COMPLETE" UpdateRollbackComplete
<|> match "UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS" UpdateRollbackCompleteCleanupInProgress
<|> match "UPDATE_ROLLBACK_FAILED" UpdateRollbackFailed
<|> match "UPDATE_ROLLBACK_IN_PROGRESS" UpdateRollbackInProgress
parser = takeText >>= \case
"CREATE_COMPLETE" -> pure CreateComplete
"CREATE_FAILED" -> pure CreateFailed
"CREATE_IN_PROGRESS" -> pure CreateInProgress
"DELETE_COMPLETE" -> pure DeleteComplete
"DELETE_FAILED" -> pure DeleteFailed
"DELETE_IN_PROGRESS" -> pure DeleteInProgress
"ROLLBACK_COMPLETE" -> pure RollbackComplete
"ROLLBACK_FAILED" -> pure RollbackFailed
"ROLLBACK_IN_PROGRESS" -> pure RollbackInProgress
"UPDATE_COMPLETE" -> pure UpdateComplete
"UPDATE_COMPLETE_CLEANUP_IN_PROGRESS" -> pure UpdateCompleteCleanupInProgress
"UPDATE_IN_PROGRESS" -> pure UpdateInProgress
"UPDATE_ROLLBACK_COMPLETE" -> pure UpdateRollbackComplete
"UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS" -> pure UpdateRollbackCompleteCleanupInProgress
"UPDATE_ROLLBACK_FAILED" -> pure UpdateRollbackFailed
"UPDATE_ROLLBACK_IN_PROGRESS" -> pure UpdateRollbackInProgress
e -> fail $
"Failure parsing StackStatus from " ++ show e

instance ToText StackStatus where
toText = \case
Expand Down Expand Up @@ -678,16 +681,19 @@ data ResourceStatus
instance Hashable ResourceStatus

instance FromText ResourceStatus where
parser = match "CREATE_COMPLETE" RSCreateComplete
<|> match "CREATE_FAILED" RSCreateFailed
<|> match "CREATE_IN_PROGRESS" RSCreateInProgress
<|> match "DELETE_COMPLETE" RSDeleteComplete
<|> match "DELETE_FAILED" RSDeleteFailed
<|> match "DELETE_IN_PROGRESS" RSDeleteInProgress
<|> match "DELETE_SKIPPED" RSDeleteSkipped
<|> match "UPDATE_COMPLETE" RSUpdateComplete
<|> match "UPDATE_FAILED" RSUpdateFailed
<|> match "UPDATE_IN_PROGRESS" RSUpdateInProgress
parser = takeText >>= \case
"CREATE_COMPLETE" -> pure RSCreateComplete
"CREATE_FAILED" -> pure RSCreateFailed
"CREATE_IN_PROGRESS" -> pure RSCreateInProgress
"DELETE_COMPLETE" -> pure RSDeleteComplete
"DELETE_FAILED" -> pure RSDeleteFailed
"DELETE_IN_PROGRESS" -> pure RSDeleteInProgress
"DELETE_SKIPPED" -> pure RSDeleteSkipped
"UPDATE_COMPLETE" -> pure RSUpdateComplete
"UPDATE_FAILED" -> pure RSUpdateFailed
"UPDATE_IN_PROGRESS" -> pure RSUpdateInProgress
e -> fail $
"Failure parsing ResourceStatus from " ++ show e

instance ToText ResourceStatus where
toText = \case
Expand Down Expand Up @@ -1101,7 +1107,10 @@ data Capability
instance Hashable Capability

instance FromText Capability where
parser = match "CAPABILITY_IAM" CapabilityIam
parser = takeText >>= \case
"CAPABILITY_IAM" -> pure CapabilityIam
e -> fail $
"Failure parsing Capability from " ++ show e

instance ToText Capability where
toText CapabilityIam = "CAPABILITY_IAM"
Expand All @@ -1122,8 +1131,11 @@ data ResourceSignalStatus
instance Hashable ResourceSignalStatus

instance FromText ResourceSignalStatus where
parser = match "FAILURE" Failure
<|> match "SUCCESS" Success
parser = takeText >>= \case
"FAILURE" -> pure Failure
"SUCCESS" -> pure Success
e -> fail $
"Failure parsing ResourceSignalStatus from " ++ show e

instance ToText ResourceSignalStatus where
toText = \case
Expand Down Expand Up @@ -1315,9 +1327,12 @@ data OnFailure
instance Hashable OnFailure

instance FromText OnFailure where
parser = match "DELETE" Delete'
<|> match "DO_NOTHING" DoNothing
<|> match "ROLLBACK" Rollback
parser = takeText >>= \case
"DELETE" -> pure Delete'
"DO_NOTHING" -> pure DoNothing
"ROLLBACK" -> pure Rollback
e -> fail $
"Failure parsing OnFailure from " ++ show e

instance ToText OnFailure where
toText = \case
Expand Down
67 changes: 44 additions & 23 deletions amazonka-cloudfront/gen/Network/AWS/CloudFront/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -584,8 +584,11 @@ data SSLSupportMethod
instance Hashable SSLSupportMethod

instance FromText SSLSupportMethod where
parser = match "sni-only" SniOnly
<|> match "vip" Vip
parser = takeText >>= \case
"sni-only" -> pure SniOnly
"vip" -> pure Vip
e -> fail $
"Failure parsing SSLSupportMethod from " ++ show e

instance ToText SSLSupportMethod where
toText = \case
Expand Down Expand Up @@ -776,9 +779,12 @@ data ViewerProtocolPolicy
instance Hashable ViewerProtocolPolicy

instance FromText ViewerProtocolPolicy where
parser = match "allow-all" AllowAll
<|> match "https-only" HttpsOnly
<|> match "redirect-to-https" RedirectToHttps
parser = takeText >>= \case
"allow-all" -> pure AllowAll
"https-only" -> pure HttpsOnly
"redirect-to-https" -> pure RedirectToHttps
e -> fail $
"Failure parsing ViewerProtocolPolicy from " ++ show e

instance ToText ViewerProtocolPolicy where
toText = \case
Expand Down Expand Up @@ -1115,8 +1121,11 @@ data OriginProtocolPolicy
instance Hashable OriginProtocolPolicy

instance FromText OriginProtocolPolicy where
parser = match "http-only" HttpOnly
<|> match "match-viewer" MatchViewer
parser = takeText >>= \case
"http-only" -> pure HttpOnly
"match-viewer" -> pure MatchViewer
e -> fail $
"Failure parsing OriginProtocolPolicy from " ++ show e

instance ToText OriginProtocolPolicy where
toText = \case
Expand Down Expand Up @@ -2109,9 +2118,12 @@ data PriceClass
instance Hashable PriceClass

instance FromText PriceClass where
parser = match "PriceClass_100" PriceClass100
<|> match "PriceClass_200" PriceClass200
<|> match "PriceClass_All" PriceClassAll
parser = takeText >>= \case
"PriceClass_100" -> pure PriceClass100
"PriceClass_200" -> pure PriceClass200
"PriceClass_All" -> pure PriceClassAll
e -> fail $
"Failure parsing PriceClass from " ++ show e

instance ToText PriceClass where
toText = \case
Expand Down Expand Up @@ -2515,13 +2527,16 @@ data Method
instance Hashable Method

instance FromText Method where
parser = match "DELETE" Delete'
<|> match "GET" Get
<|> match "HEAD" Head'
<|> match "OPTIONS" Options
<|> match "PATCH" Patch
<|> match "POST" Post
<|> match "PUT" Put
parser = takeText >>= \case
"DELETE" -> pure Delete'
"GET" -> pure Get
"HEAD" -> pure Head'
"OPTIONS" -> pure Options
"PATCH" -> pure Patch
"POST" -> pure Post
"PUT" -> pure Put
e -> fail $
"Failure parsing Method from " ++ show e

instance ToText Method where
toText = \case
Expand Down Expand Up @@ -2657,9 +2672,12 @@ data ItemSelection
instance Hashable ItemSelection

instance FromText ItemSelection where
parser = match "all" All
<|> match "none" None
<|> match "whitelist" Whitelist
parser = takeText >>= \case
"all" -> pure All
"none" -> pure None
"whitelist" -> pure Whitelist
e -> fail $
"Failure parsing ItemSelection from " ++ show e

instance ToText ItemSelection where
toText = \case
Expand Down Expand Up @@ -3547,9 +3565,12 @@ data GeoRestrictionType
instance Hashable GeoRestrictionType

instance FromText GeoRestrictionType where
parser = match "blacklist" GRTBlacklist
<|> match "none" GRTNone
<|> match "whitelist" GRTWhitelist
parser = takeText >>= \case
"blacklist" -> pure GRTBlacklist
"none" -> pure GRTNone
"whitelist" -> pure GRTWhitelist
e -> fail $
"Failure parsing GeoRestrictionType from " ++ show e

instance ToText GeoRestrictionType where
toText = \case
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,13 @@ data QueryParser
instance Hashable QueryParser

instance FromText QueryParser where
parser = match "dismax" Dismax
<|> match "lucene" Lucene
<|> match "simple" Simple
<|> match "structured" Structured
parser = takeText >>= \case
"dismax" -> pure Dismax
"lucene" -> pure Lucene
"simple" -> pure Simple
"structured" -> pure Structured
e -> fail $
"Failure parsing QueryParser from " ++ show e

instance ToText QueryParser where
toText = \case
Expand Down Expand Up @@ -535,8 +538,11 @@ data ContentType
instance Hashable ContentType

instance FromText ContentType where
parser = match "application/json" ApplicationJson
<|> match "application/xml" ApplicationXml
parser = takeText >>= \case
"application/json" -> pure ApplicationJson
"application/xml" -> pure ApplicationXml
e -> fail $
"Failure parsing ContentType from " ++ show e

instance ToText ContentType where
toText = \case
Expand Down
Loading

0 comments on commit e87cb27

Please sign in to comment.