@@ -373,6 +373,11 @@ instance ToJSON Data where
373373 , "instances" .= is
374374 ]
375375
376+dataName :: Data -> Name
377+dataName = \case
378+ Sum n _ _ -> n
379+ Prod n _ _ _ _ _ -> n
380+
376381data Action = Action
377382 { _actName :: Name
378383 , _actPrettyName :: Text
@@ -382,6 +387,9 @@ data Action = Action
382387 , _actData :: Data
383388 }
384389
390+actionTypeName :: Action -> Name
391+actionTypeName = dataName . _actData
392+
385393instance ToJSON Action where
386394 toJSON Action {..} = object
387395 [ "name" .= Syn _actName
@@ -396,6 +404,7 @@ data API = API
396404 { _apiName :: Name
397405 , _apiDecl :: Rendered
398406 , _apiActions :: Map Name Action
407+ , _apiURL :: Fun
399408 }
400409
401410instance ToJSON API where
@@ -403,6 +412,7 @@ instance ToJSON API where
403412 [ "name" .= Syn _apiName
404413 , "decl" .= _apiDecl
405414 , "actions" .= sortOn _actName (Map.elems _apiActions)
415+ , "url" .= _apiURL
406416 ]
407417
408418data Method a = Method
@@ -504,17 +514,18 @@ type Flattened = Service [Id] [Param Id] (Resource Id)
504514type Typed = Service [Solved] [Param Solved] (Resource Solved)
505515type Printed = Service [Data] () API
506516
507−svcAbbrev :: Service s p r -> Text
517+svcAbbrev, svcURL :: Service s p r -> Text
508518svcAbbrev = upperHead . renameAbbrev . _svcCanonicalName
519+svcURL = (<> "URL") . lowerHead . svcAbbrev
509520
510521svcActions :: Service s p API -> [Action]
511522svcActions = Map.elems . _apiActions . _svcApi
512523
513524typeImports, prodImports, sumImports, actionImports :: Service s p r -> [NS]
514−typeImports s = sort ["Network.Google.Prelude", prodNS s, sumNS s]
515−prodImports s = sort ["Network.Google.Prelude", sumNS s]
516−sumImports _ = sort ["Network.Google.Prelude"]
517−actionImports = typeImports
525+typeImports s = sort ["Network.Google.Prelude", prodNS s, sumNS s]
526+prodImports s = sort ["Network.Google.Prelude", sumNS s]
527+sumImports _ = sort ["Network.Google.Prelude"]
528+actionImports s = sort ["Network.Google.Prelude", typesNS s]
518529
519530tocNS, typesNS, prodNS, sumNS :: Service s p r -> NS
520531tocNS s = NS $ "Network" : "Google" : Text.split (== '.') (_svcCanonicalName s)
@@ -522,8 +533,8 @@ typesNS = (<> "Types") . tocNS
522533prodNS = (<> "Product") . typesNS
523534sumNS = (<> "Sum") . typesNS
524535
525−actionNS :: Service s p r -> Local -> Local -> NS
526−actionNS s x y = tocNS s <> NS [upperHead (local x), upperHead (local y)]
536+actionNS :: [Text] -> NS
537+actionNS = mappend (NS ["Network", "Google", "API"]) . NS
527538
528539exposedModules :: Service s p API -> [NS]
529540exposedModules s = sort (tocNS s : typesNS s : map _actNS (svcActions s))