request.go 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. URLParamStackID URLParam = "stack_id"
  38. URLParamReleaseVersion URLParam = "version"
  39. URLParamWildcard URLParam = "*"
  40. URLParamIntegrationID URLParam = "integration_id"
  41. URLParamAPIContractRevisionID URLParam = "contract_revision_id"
  42. )
  43. type Path struct {
  44. Parent *Path
  45. RelativePath string
  46. }
  47. type APIRequestMetadata struct {
  48. Verb APIVerb
  49. Method HTTPVerb
  50. Path *Path
  51. Scopes []PermissionScope
  52. ShouldRedirect bool
  53. // Whether the endpoint should log
  54. Quiet bool
  55. // Whether the endpoint upgrades to a websocket
  56. IsWebsocket bool
  57. // Whether the endpoint should check for a usage limit
  58. CheckUsage bool
  59. // The usage metric that the request should check for, if CheckUsage
  60. UsageMetric UsageMetric
  61. }
  62. const RequestScopeCtxKey = "requestscopes"
  63. type RequestAction struct {
  64. Verb APIVerb
  65. Resource NameOrUInt
  66. }
  67. var RequestCtxWebsocketKey = "websocket"