request.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. URLParamDatastoreType URLParam = "datastore_type"
  48. URLParamDatastoreName URLParam = "datastore_name"
  49. URLParamPaymentMethodID URLParam = "payment_method_id"
  50. URLParamNotificationConfigID URLParam = "notification_config_id"
  51. URLParamNotificationID URLParam = "notification_id"
  52. URLParamCloudProviderType URLParam = "cloud_provider_type"
  53. URLParamCloudProviderID URLParam = "cloud_provider_id"
  54. URLParamDeploymentTargetID URLParam = "deployment_target_id"
  55. // URLParamDeploymentTargetIdentifier can be either the deployment target id or deployment target name
  56. URLParamDeploymentTargetIdentifier URLParam = "deployment_target_identifier"
  57. URLParamWebhookID URLParam = "webhook_id"
  58. URLParamJobRunName URLParam = "job_run_name"
  59. )
  60. type Path struct {
  61. Parent *Path
  62. RelativePath string
  63. }
  64. type APIRequestMetadata struct {
  65. Verb APIVerb
  66. Method HTTPVerb
  67. Path *Path
  68. Scopes []PermissionScope
  69. ShouldRedirect bool
  70. // Whether the endpoint should log
  71. Quiet bool
  72. // Whether the endpoint upgrades to a websocket
  73. IsWebsocket bool
  74. // Whether the endpoint should check for a usage limit
  75. CheckUsage bool
  76. // The usage metric that the request should check for, if CheckUsage
  77. UsageMetric UsageMetric
  78. }
  79. const RequestScopeCtxKey = "requestscopes"
  80. type RequestAction struct {
  81. Verb APIVerb
  82. Resource NameOrUInt
  83. }
  84. var RequestCtxWebsocketKey = "websocket"