mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-23 04:50:45 -06:00
457 lines
14 KiB
Go
457 lines
14 KiB
Go
// Package GraphV0 provides primitives to interact with the openapi HTTP API.
|
|
//
|
|
// Code generated by github.com/deepmap/oapi-codegen DO NOT EDIT.
|
|
package GraphV0
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/deepmap/oapi-codegen/pkg/runtime"
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
// ServerInterface represents all server handlers.
|
|
type ServerInterface interface {
|
|
// Delete navigation property root for drive
|
|
// (DELETE /drive/root)
|
|
MeDriveRootDeleteRoot(w http.ResponseWriter, r *http.Request, params MeDriveRootDeleteRootParams)
|
|
// Get root from drive
|
|
// (GET /drive/root)
|
|
MeDriveRootGetRoot(w http.ResponseWriter, r *http.Request, params MeDriveRootGetRootParams)
|
|
// Update the navigation property root in drive
|
|
// (PATCH /drive/root)
|
|
MeDriveRootUpdateRoot(w http.ResponseWriter, r *http.Request)
|
|
// Get drives from me
|
|
// (GET /me/drives)
|
|
MeListDrives(w http.ResponseWriter, r *http.Request, params MeListDrivesParams)
|
|
// Create new navigation property to drives for me
|
|
// (POST /me/drives)
|
|
MeCreateDrives(w http.ResponseWriter, r *http.Request)
|
|
// Delete a specific navigation property drive
|
|
// (DELETE /me/drives/{drive-id})
|
|
MeDrivesDeleteDrive(w http.ResponseWriter, r *http.Request, driveId string, params MeDrivesDeleteDriveParams)
|
|
// Get drive by id
|
|
// (GET /me/drives/{drive-id})
|
|
MeDrivesGetDrive(w http.ResponseWriter, r *http.Request, driveId string, params MeDrivesGetDriveParams)
|
|
// Update the navigation property of a specific drive
|
|
// (PATCH /me/drives/{drive-id})
|
|
MeDrivesUpdateDrive(w http.ResponseWriter, r *http.Request, driveId string)
|
|
}
|
|
|
|
// ServerInterfaceWrapper converts contexts to parameters.
|
|
type ServerInterfaceWrapper struct {
|
|
Handler ServerInterface
|
|
HandlerMiddlewares []MiddlewareFunc
|
|
}
|
|
|
|
type MiddlewareFunc func(http.HandlerFunc) http.HandlerFunc
|
|
|
|
// MeDriveRootDeleteRoot operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDriveRootDeleteRoot(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params MeDriveRootDeleteRootParams
|
|
|
|
headers := r.Header
|
|
|
|
// ------------- Optional header parameter "If-Match" -------------
|
|
if valueList, found := headers[http.CanonicalHeaderKey("If-Match")]; found {
|
|
var IfMatch string
|
|
n := len(valueList)
|
|
if n != 1 {
|
|
http.Error(w, fmt.Sprintf("Expected one value for If-Match, got %d", n), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
err = runtime.BindStyledParameter("simple", false, "If-Match", valueList[0], &IfMatch)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter If-Match: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
params.IfMatch = &IfMatch
|
|
|
|
}
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDriveRootDeleteRoot(w, r, params)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeDriveRootGetRoot operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDriveRootGetRoot(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params MeDriveRootGetRootParams
|
|
|
|
// ------------- Optional query parameter "$select" -------------
|
|
if paramValue := r.URL.Query().Get("$select"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", false, false, "$select", r.URL.Query(), ¶ms.Select)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $select: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDriveRootGetRoot(w, r, params)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeDriveRootUpdateRoot operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDriveRootUpdateRoot(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDriveRootUpdateRoot(w, r)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeListDrives operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeListDrives(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params MeListDrivesParams
|
|
|
|
// ------------- Optional query parameter "$top" -------------
|
|
if paramValue := r.URL.Query().Get("$top"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "$top", r.URL.Query(), ¶ms.Top)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $top: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$skip" -------------
|
|
if paramValue := r.URL.Query().Get("$skip"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "$skip", r.URL.Query(), ¶ms.Skip)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $skip: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$search" -------------
|
|
if paramValue := r.URL.Query().Get("$search"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "$search", r.URL.Query(), ¶ms.Search)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $search: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$filter" -------------
|
|
if paramValue := r.URL.Query().Get("$filter"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "$filter", r.URL.Query(), ¶ms.Filter)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $filter: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$count" -------------
|
|
if paramValue := r.URL.Query().Get("$count"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", true, false, "$count", r.URL.Query(), ¶ms.Count)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $count: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$select" -------------
|
|
if paramValue := r.URL.Query().Get("$select"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", false, false, "$select", r.URL.Query(), ¶ms.Select)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $select: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$expand" -------------
|
|
if paramValue := r.URL.Query().Get("$expand"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", false, false, "$expand", r.URL.Query(), ¶ms.Expand)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $expand: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeListDrives(w, r, params)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeCreateDrives operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeCreateDrives(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeCreateDrives(w, r)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeDrivesDeleteDrive operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDrivesDeleteDrive(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
// ------------- Path parameter "drive-id" -------------
|
|
var driveId string
|
|
|
|
err = runtime.BindStyledParameter("simple", false, "drive-id", chi.URLParam(r, "drive-id"), &driveId)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter drive-id: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params MeDrivesDeleteDriveParams
|
|
|
|
headers := r.Header
|
|
|
|
// ------------- Optional header parameter "If-Match" -------------
|
|
if valueList, found := headers[http.CanonicalHeaderKey("If-Match")]; found {
|
|
var IfMatch string
|
|
n := len(valueList)
|
|
if n != 1 {
|
|
http.Error(w, fmt.Sprintf("Expected one value for If-Match, got %d", n), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
err = runtime.BindStyledParameter("simple", false, "If-Match", valueList[0], &IfMatch)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter If-Match: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
params.IfMatch = &IfMatch
|
|
|
|
}
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDrivesDeleteDrive(w, r, driveId, params)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeDrivesGetDrive operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDrivesGetDrive(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
// ------------- Path parameter "drive-id" -------------
|
|
var driveId string
|
|
|
|
err = runtime.BindStyledParameter("simple", false, "drive-id", chi.URLParam(r, "drive-id"), &driveId)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter drive-id: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
// Parameter object where we will unmarshal all parameters from the context
|
|
var params MeDrivesGetDriveParams
|
|
|
|
// ------------- Optional query parameter "$select" -------------
|
|
if paramValue := r.URL.Query().Get("$select"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", false, false, "$select", r.URL.Query(), ¶ms.Select)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $select: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
// ------------- Optional query parameter "$expand" -------------
|
|
if paramValue := r.URL.Query().Get("$expand"); paramValue != "" {
|
|
|
|
}
|
|
|
|
err = runtime.BindQueryParameter("form", false, false, "$expand", r.URL.Query(), ¶ms.Expand)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter $expand: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDrivesGetDrive(w, r, driveId, params)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// MeDrivesUpdateDrive operation middleware
|
|
func (siw *ServerInterfaceWrapper) MeDrivesUpdateDrive(w http.ResponseWriter, r *http.Request) {
|
|
ctx := r.Context()
|
|
|
|
var err error
|
|
|
|
// ------------- Path parameter "drive-id" -------------
|
|
var driveId string
|
|
|
|
err = runtime.BindStyledParameter("simple", false, "drive-id", chi.URLParam(r, "drive-id"), &driveId)
|
|
if err != nil {
|
|
http.Error(w, fmt.Sprintf("Invalid format for parameter drive-id: %s", err), http.StatusBadRequest)
|
|
return
|
|
}
|
|
|
|
ctx = context.WithValue(ctx, BearerAuthScopes, []string{""})
|
|
|
|
var handler = func(w http.ResponseWriter, r *http.Request) {
|
|
siw.Handler.MeDrivesUpdateDrive(w, r, driveId)
|
|
}
|
|
|
|
for _, middleware := range siw.HandlerMiddlewares {
|
|
handler = middleware(handler)
|
|
}
|
|
|
|
handler(w, r.WithContext(ctx))
|
|
}
|
|
|
|
// Handler creates http.Handler with routing matching OpenAPI spec.
|
|
func Handler(si ServerInterface) http.Handler {
|
|
return HandlerWithOptions(si, ChiServerOptions{})
|
|
}
|
|
|
|
type ChiServerOptions struct {
|
|
BaseURL string
|
|
BaseRouter chi.Router
|
|
Middlewares []MiddlewareFunc
|
|
}
|
|
|
|
// HandlerFromMux creates http.Handler with routing matching OpenAPI spec based on the provided mux.
|
|
func HandlerFromMux(si ServerInterface, r chi.Router) http.Handler {
|
|
return HandlerWithOptions(si, ChiServerOptions{
|
|
BaseRouter: r,
|
|
})
|
|
}
|
|
|
|
func HandlerFromMuxWithBaseURL(si ServerInterface, r chi.Router, baseURL string) http.Handler {
|
|
return HandlerWithOptions(si, ChiServerOptions{
|
|
BaseURL: baseURL,
|
|
BaseRouter: r,
|
|
})
|
|
}
|
|
|
|
// HandlerWithOptions creates http.Handler with additional options
|
|
func HandlerWithOptions(si ServerInterface, options ChiServerOptions) http.Handler {
|
|
r := options.BaseRouter
|
|
|
|
if r == nil {
|
|
r = chi.NewRouter()
|
|
}
|
|
wrapper := ServerInterfaceWrapper{
|
|
Handler: si,
|
|
HandlerMiddlewares: options.Middlewares,
|
|
}
|
|
|
|
r.Group(func(r chi.Router) {
|
|
r.Delete(options.BaseURL+"/drive/root", wrapper.MeDriveRootDeleteRoot)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Get(options.BaseURL+"/drive/root", wrapper.MeDriveRootGetRoot)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Patch(options.BaseURL+"/drive/root", wrapper.MeDriveRootUpdateRoot)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Get(options.BaseURL+"/me/drives", wrapper.MeListDrives)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Post(options.BaseURL+"/me/drives", wrapper.MeCreateDrives)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Delete(options.BaseURL+"/me/drives/{drive-id}", wrapper.MeDrivesDeleteDrive)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Get(options.BaseURL+"/me/drives/{drive-id}", wrapper.MeDrivesGetDrive)
|
|
})
|
|
r.Group(func(r chi.Router) {
|
|
r.Patch(options.BaseURL+"/me/drives/{drive-id}", wrapper.MeDrivesUpdateDrive)
|
|
})
|
|
|
|
return r
|
|
}
|