casaos_api.go 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. // Package codegen provides primitives to interact with the openapi HTTP API.
  2. //
  3. // Code generated by github.com/deepmap/oapi-codegen version v1.12.4 DO NOT EDIT.
  4. package codegen
  5. import (
  6. "bytes"
  7. "compress/gzip"
  8. "encoding/base64"
  9. "fmt"
  10. "net/url"
  11. "path"
  12. "strings"
  13. "github.com/getkin/kin-openapi/openapi3"
  14. "github.com/labstack/echo/v4"
  15. )
  16. const (
  17. Access_tokenScopes = "access_token.Scopes"
  18. )
  19. // BaseResponse defines model for BaseResponse.
  20. type BaseResponse struct {
  21. // Message message returned by server side if there is any
  22. Message *string `json:"message,omitempty"`
  23. }
  24. // HealthServices defines model for HealthServices.
  25. type HealthServices struct {
  26. NotRunning *[]string `json:"not_running,omitempty"`
  27. Running *[]string `json:"running,omitempty"`
  28. }
  29. // GetHealthServicesOK defines model for GetHealthServicesOK.
  30. type GetHealthServicesOK struct {
  31. Data *HealthServices `json:"data,omitempty"`
  32. // Message message returned by server side if there is any
  33. Message *string `json:"message,omitempty"`
  34. }
  35. // ResponseInternalServerError defines model for ResponseInternalServerError.
  36. type ResponseInternalServerError = BaseResponse
  37. // ServerInterface represents all server handlers.
  38. type ServerInterface interface {
  39. // Get service status
  40. // (GET /health/services)
  41. GetHealthServices(ctx echo.Context) error
  42. }
  43. // ServerInterfaceWrapper converts echo contexts to parameters.
  44. type ServerInterfaceWrapper struct {
  45. Handler ServerInterface
  46. }
  47. // GetHealthServices converts echo context to params.
  48. func (w *ServerInterfaceWrapper) GetHealthServices(ctx echo.Context) error {
  49. var err error
  50. ctx.Set(Access_tokenScopes, []string{""})
  51. // Invoke the callback with all the unmarshalled arguments
  52. err = w.Handler.GetHealthServices(ctx)
  53. return err
  54. }
  55. // This is a simple interface which specifies echo.Route addition functions which
  56. // are present on both echo.Echo and echo.Group, since we want to allow using
  57. // either of them for path registration
  58. type EchoRouter interface {
  59. CONNECT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  60. DELETE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  61. GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  62. HEAD(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  63. OPTIONS(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  64. PATCH(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  65. POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  66. PUT(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  67. TRACE(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
  68. }
  69. // RegisterHandlers adds each server route to the EchoRouter.
  70. func RegisterHandlers(router EchoRouter, si ServerInterface) {
  71. RegisterHandlersWithBaseURL(router, si, "")
  72. }
  73. // Registers handlers, and prepends BaseURL to the paths, so that the paths
  74. // can be served under a prefix.
  75. func RegisterHandlersWithBaseURL(router EchoRouter, si ServerInterface, baseURL string) {
  76. wrapper := ServerInterfaceWrapper{
  77. Handler: si,
  78. }
  79. router.GET(baseURL+"/health/services", wrapper.GetHealthServices)
  80. }
  81. // Base64 encoded, gzipped, json marshaled Swagger object
  82. var swaggerSpec = []string{
  83. "H4sIAAAAAAAC/7xVUW/jNgz+KwK3h3Zw46DFgMHAPfR2W68ohgzrARvQBDlGZmxdbUkj5bRZ4f8+yHIv",
  84. "S7IV3YDdUyKR/L6PNEk9gXatd5ZsECiegEm8s0LD4YrCe8Im1LfEG6NJZjfxWjsbyIb4F71vjMZgnM0/",
  85. "ibPxTnRNLQ7Wppmtobh7gq+Z1lDAV/mOLU9+kr9FoV9GWuizJ/DsPHEwSUSJYQB7CWJfJfR9v+j7PoOS",
  86. "RLPxUR4UMLuBPoNnqmsbiC02MYr4B2bH/yq516d0rOSZWyVyldij34gQCfZAisOytCSC1WDYxx4Niil0",
  87. "bKlUq62SRCOmJGXWKtTEpIwotFvIgB6x9Q1BAZABE5Yz22yhCNxRBmHro0UCG1ulXA6qfSTNurDkztoY",
  88. "UDyBCdQO9zsejYJOJpIg4Ijl8wUy4zaeX4N3VmGgB9y+HndIR0h3bML2NpY+ZYBak8gyuHsavrqJha0J",
  89. "S2LIwGIbMS67UDs2fwwNsuNCb25omypl7Nodf6F5N51eaG906JiGA82tUkolg7iONamWSoNv5nDimdbE",
  90. "cqZd4/hsaBAqVIl8fzoHJayFwps51CF4KfKc8WFSmVB3q06Ix3aeaNfm15p+rbGhD6TrvHGVy1s0Nk/F",
  91. "G3+WK7SWeBnhl9ZUdVh+N536x4m31Rz+q9gmAv2PasODGSiWq6ajlwWbtlLYRAnfo+DsNon68oqSmvyg",
  92. "C+Y2qVKXP18rz25jShLVGtHUNGjJdaJaCrUrRa0dq9Ks18RkgxJNFtk4mUSUHx0rI9JRnPFSlUZ0J2Kc",
  93. "lUz5hlBIbYyYEFeBursy4X23UkzeiQmOt4uT52qkShynn2SeKsfqkzNW3bmO1Tsj2nG5iy7TxaSq8nv7",
  94. "++Vq9XZFv51O5sO4mDDM7i5hyGBDLGlINudxXJ0ni95AAReT6eQCMvAY6mFG83pYQ7n8ZQ9VFI7H7YqC",
  95. "GteHkoChE+XWilDX6uO4OL75qEaYCQykPAz1dZnCDxZetv9Knk+n//QefPbL/+4p7TP49jWxL71YwwLr",
  96. "2hZ5O6Y6JjKmGguNlUBxN67t5/aBxd7yG17p/bV3t+gX0SGSyWDvuIEC8s352OwQHUb4w6qffJi9m53u",
  97. "tuUBe4x8PAtYXbHrfAIYPX8aXV5Qvuj/DAAA//9MfhiluAgAAA==",
  98. }
  99. // GetSwagger returns the content of the embedded swagger specification file
  100. // or error if failed to decode
  101. func decodeSpec() ([]byte, error) {
  102. zipped, err := base64.StdEncoding.DecodeString(strings.Join(swaggerSpec, ""))
  103. if err != nil {
  104. return nil, fmt.Errorf("error base64 decoding spec: %s", err)
  105. }
  106. zr, err := gzip.NewReader(bytes.NewReader(zipped))
  107. if err != nil {
  108. return nil, fmt.Errorf("error decompressing spec: %s", err)
  109. }
  110. var buf bytes.Buffer
  111. _, err = buf.ReadFrom(zr)
  112. if err != nil {
  113. return nil, fmt.Errorf("error decompressing spec: %s", err)
  114. }
  115. return buf.Bytes(), nil
  116. }
  117. var rawSpec = decodeSpecCached()
  118. // a naive cached of a decoded swagger spec
  119. func decodeSpecCached() func() ([]byte, error) {
  120. data, err := decodeSpec()
  121. return func() ([]byte, error) {
  122. return data, err
  123. }
  124. }
  125. // Constructs a synthetic filesystem for resolving external references when loading openapi specifications.
  126. func PathToRawSpec(pathToFile string) map[string]func() ([]byte, error) {
  127. var res = make(map[string]func() ([]byte, error))
  128. if len(pathToFile) > 0 {
  129. res[pathToFile] = rawSpec
  130. }
  131. return res
  132. }
  133. // GetSwagger returns the Swagger specification corresponding to the generated code
  134. // in this file. The external references of Swagger specification are resolved.
  135. // The logic of resolving external references is tightly connected to "import-mapping" feature.
  136. // Externally referenced files must be embedded in the corresponding golang packages.
  137. // Urls can be supported but this task was out of the scope.
  138. func GetSwagger() (swagger *openapi3.T, err error) {
  139. var resolvePath = PathToRawSpec("")
  140. loader := openapi3.NewLoader()
  141. loader.IsExternalRefsAllowed = true
  142. loader.ReadFromURIFunc = func(loader *openapi3.Loader, url *url.URL) ([]byte, error) {
  143. var pathToFile = url.String()
  144. pathToFile = path.Clean(pathToFile)
  145. getSpec, ok := resolvePath[pathToFile]
  146. if !ok {
  147. err1 := fmt.Errorf("path not found: %s", pathToFile)
  148. return nil, err1
  149. }
  150. return getSpec()
  151. }
  152. var specData []byte
  153. specData, err = rawSpec()
  154. if err != nil {
  155. return
  156. }
  157. swagger, err = loader.LoadFromData(specData)
  158. if err != nil {
  159. return
  160. }
  161. return
  162. }