request.go 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. package types
  2. type APIVerb string
  3. const (
  4. APIVerbGet APIVerb = "get"
  5. APIVerbCreate APIVerb = "create"
  6. APIVerbList APIVerb = "list"
  7. APIVerbUpdate APIVerb = "update"
  8. APIVerbDelete APIVerb = "delete"
  9. )
  10. type APIVerbGroup []APIVerb
  11. func ReadVerbGroup() APIVerbGroup {
  12. return []APIVerb{APIVerbGet, APIVerbList}
  13. }
  14. func ReadWriteVerbGroup() APIVerbGroup {
  15. return []APIVerb{APIVerbGet, APIVerbList, APIVerbCreate, APIVerbUpdate, APIVerbDelete}
  16. }
  17. type HTTPVerb string
  18. const (
  19. HTTPVerbGet HTTPVerb = "GET"
  20. HTTPVerbPost HTTPVerb = "POST"
  21. HTTPVerbPut HTTPVerb = "PUT"
  22. HTTPVerbPatch HTTPVerb = "PATCH"
  23. HTTPVerbDelete HTTPVerb = "DELETE"
  24. )
  25. type URLParam string
  26. const (
  27. URLParamProjectID URLParam = "project_id"
  28. URLParamClusterID URLParam = "cluster_id"
  29. URLParamRegistryID URLParam = "registry_id"
  30. URLParamHelmRepoID URLParam = "helm_repo_id"
  31. URLParamGitInstallationID URLParam = "git_installation_id"
  32. URLParamInfraID URLParam = "infra_id"
  33. URLParamOperationID URLParam = "operation_id"
  34. URLParamInviteID URLParam = "invite_id"
  35. URLParamNamespace URLParam = "namespace"
  36. URLParamReleaseName URLParam = "name"
  37. URLParamPorterAppID URLParam = "porter_app_id"
  38. URLParamStackID URLParam = "stack_id"
  39. URLParamReleaseVersion URLParam = "version"
  40. URLParamWildcard URLParam = "*"
  41. URLParamIntegrationID URLParam = "integration_id"
  42. URLParamAPIContractRevisionID URLParam = "contract_revision_id"
  43. URLParamStackEventID URLParam = "stack_event_id"
  44. URLParamPorterAppName URLParam = "porter_app_name"
  45. URLParamPorterAppEventID URLParam = "porter_app_event_id"
  46. URLParamAppRevisionID URLParam = "app_revision_id"
  47. URLParamDeploymentTargetID URLParam = "deployment_target_id"
  48. URLParamWebhookID URLParam = "webhook_id"
  49. )
  50. type Path struct {
  51. Parent *Path
  52. RelativePath string
  53. }
  54. type APIRequestMetadata struct {
  55. Verb APIVerb
  56. Method HTTPVerb
  57. Path *Path
  58. Scopes []PermissionScope
  59. ShouldRedirect bool
  60. // Whether the endpoint should log
  61. Quiet bool
  62. // Whether the endpoint upgrades to a websocket
  63. IsWebsocket bool
  64. // Whether the endpoint should check for a usage limit
  65. CheckUsage bool
  66. // The usage metric that the request should check for, if CheckUsage
  67. UsageMetric UsageMetric
  68. }
  69. const RequestScopeCtxKey = "requestscopes"
  70. type RequestAction struct {
  71. Verb APIVerb
  72. Resource NameOrUInt
  73. }
  74. var RequestCtxWebsocketKey = "websocket"