resource.dhall 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. let Types = ../types/package.dhall
  2. let Prelude = ../lib/prelude.dhall
  3. let JSON = Prelude.JSON
  4. let RenderOptional = ./optionals/package.dhall
  5. let typeName
  6. : Types.ResourceType → Text
  7. = λ(t : Types.ResourceType)
  8. → merge
  9. { InBuilt = λ(n : Text) → n
  10. , Custom = λ(c : Types.CustomResourceType) → c.name
  11. }
  12. t
  13. let render
  14. : Types.Resource → JSON.Type
  15. = λ(r : Types.Resource)
  16. → JSON.object
  17. ( toMap
  18. { name = JSON.string r.name
  19. , type = JSON.string (typeName r.type)
  20. , icon = RenderOptional.text r.icon
  21. , source = RenderOptional.jsonObject r.source
  22. , version = RenderOptional.textTextMap r.version
  23. , check_every = RenderOptional.text r.check_every
  24. , tags = RenderOptional.lists.text r.tags
  25. , public = RenderOptional.bool r.public
  26. , webhook_token = RenderOptional.text r.webhook_token
  27. }
  28. )
  29. in render