request.go 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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 = "PUT"
  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. URLParamInviteID URLParam = "invite_id"
  34. URLParamNamespace URLParam = "namespace"
  35. URLParamReleaseName URLParam = "name"
  36. URLParamReleaseVersion URLParam = "version"
  37. URLParamWildcard URLParam = "*"
  38. )
  39. type Path struct {
  40. Parent *Path
  41. RelativePath string
  42. }
  43. type APIRequestMetadata struct {
  44. Verb APIVerb
  45. Method HTTPVerb
  46. Path *Path
  47. Scopes []PermissionScope
  48. ShouldRedirect bool
  49. }
  50. const RequestScopeCtxKey = "requestscopes"
  51. type RequestAction struct {
  52. Verb APIVerb
  53. Resource NameOrUInt
  54. }