api

package
v0.0.0-...-760764c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 23, 2025 License: AGPL-3.0 Imports: 29 Imported by: 0

Documentation

Overview

Package api is a reverse proxy.

It translates gRPC into RESTful JSON APIs.

Index

Constants

View Source
const (
	VMControl_Start_FullMethodName   = "/slumber.api.v1.VMControl/Start"
	VMControl_Stop_FullMethodName    = "/slumber.api.v1.VMControl/Stop"
	VMControl_Pause_FullMethodName   = "/slumber.api.v1.VMControl/Pause"
	VMControl_Unpause_FullMethodName = "/slumber.api.v1.VMControl/Unpause"
	VMControl_Status_FullMethodName  = "/slumber.api.v1.VMControl/Status"
)

Variables

View Source
var File_command_api_api_proto protoreflect.FileDescriptor
View Source
var VMControl_ServiceDesc = grpc.ServiceDesc{
	ServiceName: "slumber.api.v1.VMControl",
	HandlerType: (*VMControlServer)(nil),
	Methods: []grpc.MethodDesc{
		{
			MethodName: "Start",
			Handler:    _VMControl_Start_Handler,
		},
		{
			MethodName: "Stop",
			Handler:    _VMControl_Stop_Handler,
		},
		{
			MethodName: "Pause",
			Handler:    _VMControl_Pause_Handler,
		},
		{
			MethodName: "Unpause",
			Handler:    _VMControl_Unpause_Handler,
		},
		{
			MethodName: "Status",
			Handler:    _VMControl_Status_Handler,
		},
	},
	Streams:  []grpc.StreamDesc{},
	Metadata: "command/api/api.proto",
}

VMControl_ServiceDesc is the grpc.ServiceDesc for VMControl service. It's only intended for direct use with grpc.RegisterService, and not to be introspected or modified (even as a copy)

Functions

func RegisterVMControlHandler

func RegisterVMControlHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error

RegisterVMControlHandler registers the http handlers for service VMControl to "mux". The handlers forward requests to the grpc endpoint over "conn".

func RegisterVMControlHandlerClient

func RegisterVMControlHandlerClient(ctx context.Context, mux *runtime.ServeMux, client VMControlClient) error

RegisterVMControlHandlerClient registers the http handlers for service VMControl to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "VMControlClient". Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "VMControlClient" doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in "VMControlClient" to call the correct interceptors. This client ignores the HTTP middlewares.

func RegisterVMControlHandlerFromEndpoint

func RegisterVMControlHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error)

RegisterVMControlHandlerFromEndpoint is same as RegisterVMControlHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.

func RegisterVMControlHandlerServer

func RegisterVMControlHandlerServer(ctx context.Context, mux *runtime.ServeMux, server VMControlServer) error

RegisterVMControlHandlerServer registers the http handlers for service VMControl to "mux". UnaryRPC :call VMControlServer directly. StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906. Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterVMControlHandlerFromEndpoint instead. GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.

func RegisterVMControlServer

func RegisterVMControlServer(s grpc.ServiceRegistrar, srv VMControlServer)

Types

type API

type API struct {
	// GRPCPort is the port for the gRPC server.
	GRPCPort int `short:"g" long:"grpc-port" description:"The port for the gRPC server" default:"9090"`
	// RESTPort is the port for the REST gateway.
	RESTPort int `short:"r" long:"rest-port" description:"The port for the REST gateway" default:"8080"`
}

API is the command to start the API server.

func (*API) Execute

func (cmd *API) Execute(args []string) error

Execute is the main entry point for the api command.

type OpenStackClient

type OpenStackClient struct {
	// contains filtered or unexported fields
}

func NewOpenStackClient

func NewOpenStackClient() (*OpenStackClient, error)

func (*OpenStackClient) Pause

func (c *OpenStackClient) Pause(ctx context.Context, userID string) error

func (*OpenStackClient) Start

func (c *OpenStackClient) Start(ctx context.Context, userID string) error

func (*OpenStackClient) Status

func (c *OpenStackClient) Status(ctx context.Context, userID string) (string, error)

func (*OpenStackClient) Stop

func (c *OpenStackClient) Stop(ctx context.Context, userID string) error

func (*OpenStackClient) Unpause

func (c *OpenStackClient) Unpause(ctx context.Context, userID string) error

type PauseRequest

type PauseRequest struct {
	UserId string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
	// contains filtered or unexported fields
}

func (*PauseRequest) Descriptor deprecated

func (*PauseRequest) Descriptor() ([]byte, []int)

Deprecated: Use PauseRequest.ProtoReflect.Descriptor instead.

func (*PauseRequest) GetUserId

func (x *PauseRequest) GetUserId() string

func (*PauseRequest) ProtoMessage

func (*PauseRequest) ProtoMessage()

func (*PauseRequest) ProtoReflect

func (x *PauseRequest) ProtoReflect() protoreflect.Message

func (*PauseRequest) Reset

func (x *PauseRequest) Reset()

func (*PauseRequest) String

func (x *PauseRequest) String() string

type PauseResponse

type PauseResponse struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Status  string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*PauseResponse) Descriptor deprecated

func (*PauseResponse) Descriptor() ([]byte, []int)

Deprecated: Use PauseResponse.ProtoReflect.Descriptor instead.

func (*PauseResponse) GetMessage

func (x *PauseResponse) GetMessage() string

func (*PauseResponse) GetStatus

func (x *PauseResponse) GetStatus() string

func (*PauseResponse) ProtoMessage

func (*PauseResponse) ProtoMessage()

func (*PauseResponse) ProtoReflect

func (x *PauseResponse) ProtoReflect() protoreflect.Message

func (*PauseResponse) Reset

func (x *PauseResponse) Reset()

func (*PauseResponse) String

func (x *PauseResponse) String() string

type Server

type Server struct {
	UnimplementedVMControlServer
	// contains filtered or unexported fields
}

func NewServer

func NewServer(osClient *OpenStackClient) *Server

func (*Server) Pause

func (s *Server) Pause(ctx context.Context, req *PauseRequest) (*PauseResponse, error)

func (*Server) Start

func (s *Server) Start(ctx context.Context, req *StartRequest) (*StartResponse, error)

func (*Server) Status

func (s *Server) Status(ctx context.Context, req *StatusRequest) (*StatusResponse, error)

func (*Server) Stop

func (s *Server) Stop(ctx context.Context, req *StopRequest) (*StopResponse, error)

func (*Server) Unpause

func (s *Server) Unpause(ctx context.Context, req *UnpauseRequest) (*UnpauseResponse, error)

type StartRequest

type StartRequest struct {
	UserId string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
	// contains filtered or unexported fields
}

func (*StartRequest) Descriptor deprecated

func (*StartRequest) Descriptor() ([]byte, []int)

Deprecated: Use StartRequest.ProtoReflect.Descriptor instead.

func (*StartRequest) GetUserId

func (x *StartRequest) GetUserId() string

func (*StartRequest) ProtoMessage

func (*StartRequest) ProtoMessage()

func (*StartRequest) ProtoReflect

func (x *StartRequest) ProtoReflect() protoreflect.Message

func (*StartRequest) Reset

func (x *StartRequest) Reset()

func (*StartRequest) String

func (x *StartRequest) String() string

type StartResponse

type StartResponse struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Status  string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*StartResponse) Descriptor deprecated

func (*StartResponse) Descriptor() ([]byte, []int)

Deprecated: Use StartResponse.ProtoReflect.Descriptor instead.

func (*StartResponse) GetMessage

func (x *StartResponse) GetMessage() string

func (*StartResponse) GetStatus

func (x *StartResponse) GetStatus() string

func (*StartResponse) ProtoMessage

func (*StartResponse) ProtoMessage()

func (*StartResponse) ProtoReflect

func (x *StartResponse) ProtoReflect() protoreflect.Message

func (*StartResponse) Reset

func (x *StartResponse) Reset()

func (*StartResponse) String

func (x *StartResponse) String() string

type StatusRequest

type StatusRequest struct {
	UserId string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
	// contains filtered or unexported fields
}

func (*StatusRequest) Descriptor deprecated

func (*StatusRequest) Descriptor() ([]byte, []int)

Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead.

func (*StatusRequest) GetUserId

func (x *StatusRequest) GetUserId() string

func (*StatusRequest) ProtoMessage

func (*StatusRequest) ProtoMessage()

func (*StatusRequest) ProtoReflect

func (x *StatusRequest) ProtoReflect() protoreflect.Message

func (*StatusRequest) Reset

func (x *StatusRequest) Reset()

func (*StatusRequest) String

func (x *StatusRequest) String() string

type StatusResponse

type StatusResponse struct {
	Status  string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"`
	Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
	// contains filtered or unexported fields
}

func (*StatusResponse) Descriptor deprecated

func (*StatusResponse) Descriptor() ([]byte, []int)

Deprecated: Use StatusResponse.ProtoReflect.Descriptor instead.

func (*StatusResponse) GetMessage

func (x *StatusResponse) GetMessage() string

func (*StatusResponse) GetStatus

func (x *StatusResponse) GetStatus() string

func (*StatusResponse) ProtoMessage

func (*StatusResponse) ProtoMessage()

func (*StatusResponse) ProtoReflect

func (x *StatusResponse) ProtoReflect() protoreflect.Message

func (*StatusResponse) Reset

func (x *StatusResponse) Reset()

func (*StatusResponse) String

func (x *StatusResponse) String() string

type StopRequest

type StopRequest struct {
	UserId string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
	// contains filtered or unexported fields
}

func (*StopRequest) Descriptor deprecated

func (*StopRequest) Descriptor() ([]byte, []int)

Deprecated: Use StopRequest.ProtoReflect.Descriptor instead.

func (*StopRequest) GetUserId

func (x *StopRequest) GetUserId() string

func (*StopRequest) ProtoMessage

func (*StopRequest) ProtoMessage()

func (*StopRequest) ProtoReflect

func (x *StopRequest) ProtoReflect() protoreflect.Message

func (*StopRequest) Reset

func (x *StopRequest) Reset()

func (*StopRequest) String

func (x *StopRequest) String() string

type StopResponse

type StopResponse struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Status  string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*StopResponse) Descriptor deprecated

func (*StopResponse) Descriptor() ([]byte, []int)

Deprecated: Use StopResponse.ProtoReflect.Descriptor instead.

func (*StopResponse) GetMessage

func (x *StopResponse) GetMessage() string

func (*StopResponse) GetStatus

func (x *StopResponse) GetStatus() string

func (*StopResponse) ProtoMessage

func (*StopResponse) ProtoMessage()

func (*StopResponse) ProtoReflect

func (x *StopResponse) ProtoReflect() protoreflect.Message

func (*StopResponse) Reset

func (x *StopResponse) Reset()

func (*StopResponse) String

func (x *StopResponse) String() string

type UnimplementedVMControlServer

type UnimplementedVMControlServer struct{}

UnimplementedVMControlServer must be embedded to have forward compatible implementations.

NOTE: this should be embedded by value instead of pointer to avoid a nil pointer dereference when methods are called.

func (UnimplementedVMControlServer) Pause

func (UnimplementedVMControlServer) Start

func (UnimplementedVMControlServer) Status

func (UnimplementedVMControlServer) Stop

func (UnimplementedVMControlServer) Unpause

type UnpauseRequest

type UnpauseRequest struct {
	UserId string `protobuf:"bytes,1,opt,name=userid,proto3" json:"userid,omitempty"`
	// contains filtered or unexported fields
}

func (*UnpauseRequest) Descriptor deprecated

func (*UnpauseRequest) Descriptor() ([]byte, []int)

Deprecated: Use UnpauseRequest.ProtoReflect.Descriptor instead.

func (*UnpauseRequest) GetUserId

func (x *UnpauseRequest) GetUserId() string

func (*UnpauseRequest) ProtoMessage

func (*UnpauseRequest) ProtoMessage()

func (*UnpauseRequest) ProtoReflect

func (x *UnpauseRequest) ProtoReflect() protoreflect.Message

func (*UnpauseRequest) Reset

func (x *UnpauseRequest) Reset()

func (*UnpauseRequest) String

func (x *UnpauseRequest) String() string

type UnpauseResponse

type UnpauseResponse struct {
	Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"`
	Status  string `protobuf:"bytes,2,opt,name=status,proto3" json:"status,omitempty"`
	// contains filtered or unexported fields
}

func (*UnpauseResponse) Descriptor deprecated

func (*UnpauseResponse) Descriptor() ([]byte, []int)

Deprecated: Use UnpauseResponse.ProtoReflect.Descriptor instead.

func (*UnpauseResponse) GetMessage

func (x *UnpauseResponse) GetMessage() string

func (*UnpauseResponse) GetStatus

func (x *UnpauseResponse) GetStatus() string

func (*UnpauseResponse) ProtoMessage

func (*UnpauseResponse) ProtoMessage()

func (*UnpauseResponse) ProtoReflect

func (x *UnpauseResponse) ProtoReflect() protoreflect.Message

func (*UnpauseResponse) Reset

func (x *UnpauseResponse) Reset()

func (*UnpauseResponse) String

func (x *UnpauseResponse) String() string

type UnsafeVMControlServer

type UnsafeVMControlServer interface {
	// contains filtered or unexported methods
}

UnsafeVMControlServer may be embedded to opt out of forward compatibility for this service. Use of this interface is not recommended, as added methods to VMControlServer will result in compilation errors.

type VMControlClient

type VMControlClient interface {
	Start(ctx context.Context, in *StartRequest, opts ...grpc.CallOption) (*StartResponse, error)
	Stop(ctx context.Context, in *StopRequest, opts ...grpc.CallOption) (*StopResponse, error)
	Pause(ctx context.Context, in *PauseRequest, opts ...grpc.CallOption) (*PauseResponse, error)
	Unpause(ctx context.Context, in *UnpauseRequest, opts ...grpc.CallOption) (*UnpauseResponse, error)
	Status(ctx context.Context, in *StatusRequest, opts ...grpc.CallOption) (*StatusResponse, error)
}

VMControlClient is the client API for VMControl service.

For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.

func NewVMControlClient

func NewVMControlClient(cc grpc.ClientConnInterface) VMControlClient

type VMControlServer

type VMControlServer interface {
	Start(context.Context, *StartRequest) (*StartResponse, error)
	Stop(context.Context, *StopRequest) (*StopResponse, error)
	Pause(context.Context, *PauseRequest) (*PauseResponse, error)
	Unpause(context.Context, *UnpauseRequest) (*UnpauseResponse, error)
	Status(context.Context, *StatusRequest) (*StatusResponse, error)
	// contains filtered or unexported methods
}

VMControlServer is the server API for VMControl service. All implementations must embed UnimplementedVMControlServer for forward compatibility.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL