http

package
v0.0.0-...-0be5f3d Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultLimit defines default results limit
	DefaultLimit = 20
)

Variables

This section is empty.

Functions

func StringPtr

func StringPtr(s string) *string

Types

type Config

type Config struct {
	IdleTimeout  time.Duration
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
}

type EdgesResponse

type EdgesResponse struct {
	Edges []*api.Edge `json:"edges"`
	N     int         `json:"n"`
}

EdgesReponse is returned when querying edges.

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

ErrorResponse represents a JSON structure for error output.

type GraphsResponse

type GraphsResponse struct {
	Graphs []*api.Graph `json:"graphs"`
	N      int          `json:"n"`
}

GraphsResponse is returned when querying graphs.

type NodesResponse

type NodesResponse struct {
	Nodes []*api.Node `json:"nodes"`
	N     int         `json:"n"`
}

NodesResponse is returned when querying nodes.

type Server

type Server struct {

	// Addr is bind address
	Addr string
	// GraphService provides access to Graph endpoints.
	GraphService api.GraphService
	// NodeService provides access to Node endpoints.
	NodeService api.NodeService
	// EdgeService provides access to Edge endpoints.
	EdgeService api.EdgeService
	// contains filtered or unexported fields
}

Server is an HTTP server used to provide REST API access for various Graph API endpoints.

func NewServer

func NewServer(config ...Config) (*Server, error)

NewServer creates a new Server and returns it.

func (*Server) Close

func (s *Server) Close(ctx context.Context) error

Close gracefully shuts down the server.

func (*Server) CreateEdge

func (s *Server) CreateEdge(c *fiber.Ctx) error

CreateEdge creates a new graph edge between two nodes. @Summary Create new graph edge. @Description Create a new graph edge and return it. @Tags edges @Accept json @Produce json @Param graph body api.Edge true "Create a edge" @Success 200 {object} api.Edge @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges [post]

func (*Server) CreateGraph

func (s *Server) CreateGraph(c *fiber.Ctx) error

CreateGraph creates a new graph. @Summary Create new graph. @Description Create new graph. @Tags graphs @Accept json @Produce json @Param graph body api.Graph true "Create a graph" @Success 200 {object} api.Graph @Failure 400 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs [post]

func (*Server) CreateNode

func (s *Server) CreateNode(c *fiber.Ctx) error

CreateNode creates a new graph node. @Summary Create new graph node. @Description Create a new graph node and returns it. @Tags nodes @Accept json @Produce json @Param graph body api.Node true "Create a node" @Success 200 {object} api.Node @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes [post]

func (*Server) DeleteEdge

func (s *Server) DeleteEdge(c *fiber.Ctx) error

DeleteEdge deletes graph edge with the given UID. @Summary Delete graph edge by UID. @Description Delete graph edge with the given UID. @Tags edges @Produce json @Param guid path string true "Graph UID" @Param uid path string true "Edge UID" @Success 204 {string} status "Edge was deleted successfully" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges/{uid} [delete]

func (*Server) DeleteEdgeBetween

func (s *Server) DeleteEdgeBetween(c *fiber.Ctx) error

DeleteEdgeBetween deletes a graph edge between two nodes. @Summary Delete graph edge between two nodes. @Description Delete graph edge between nodes with given IDs. @Tags edges @Produce json @Param uid path string true "Graph UID" @Param source query int false "Source node ID" @Param target query int false "Target node ID" @Success 204 {string} status "Edge was deleted successfully" @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges [delete]

func (*Server) DeleteGraph

func (s *Server) DeleteGraph(c *fiber.Ctx) error

DeleteGraph deletes graph by uid. @Summary Delete graph by UID. @Description Delete graph with the given UID. @Tags graphs @Produce json @Param uid path string true "Graph UID" @Success 204 {string} status "Graph was deleted successfully" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{uid} [delete]

func (*Server) DeleteNodeByID

func (s *Server) DeleteNodeByID(c *fiber.Ctx) error

DeleteNodeByID deletes a graph node by id. @Summary Delete graph node by ID. @Description Delete graph node with the given ID. @Tags nodes @Produce json @Param uid path string true "Graph UID" @Param id path string true "Node ID" @Success 204 {string} status "Node was deleted successfully" @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes/{id} [delete]

func (*Server) DeleteNodeByUID

func (s *Server) DeleteNodeByUID(c *fiber.Ctx) error

DeleteNodeByUID deletes a graph node by UID. @Summary Delete graph node by UID. @Description Delete graph node with the given UID. @Tags nodes @Produce json @Param uid path string true "Graph UID" @Param id path string true "Node ID" @Success 204 {string} status "Node was deleted successfully" @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes/uid/{uid} [delete]

func (*Server) GetAllEdges

func (s *Server) GetAllEdges(c *fiber.Ctx) error

GetAllEdges returns all edges in the graph matching a query. @Summary Get graph edges matching a filter. @Description Get all edges matching a query. @Tags edges @Produce json @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Param label query string false "Node label" @Param guid path string true "Graph UID" @Success 200 {object} EdgesResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges [get]

func (*Server) GetAllGraphs

func (s *Server) GetAllGraphs(c *fiber.Ctx) error

GetAllGraphs returns all available graphs. @Summary Get all graphs @Description Get all available graphs. @Tags graphs @Produce json @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Success 200 {object} GraphsResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs [get]

func (*Server) GetEdgeByUID

func (s *Server) GetEdgeByUID(c *fiber.Ctx) error

GetEdgeByUID returns graph edge with the given UID. @Summary Get graph edge by UID. @Description Get graph a single graph edge with the given UID. @Tags edges @Produce json @Param guid path string true "Graph UID" @Param uid path string true "Edge UID" @Success 200 {object} api.Edge @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges/{uid} [get]

func (*Server) GetGraphByUID

func (s *Server) GetGraphByUID(c *fiber.Ctx) error

GetGraphByUID returns graph with the given UID. @Summary Get graph by UID. @Description Get graph returns graph with the given UID. @Tags graphs @Produce json @Param uid path string true "Graph UID" @Success 200 {object} api.Graph @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{uid} [get]

func (*Server) GetNodeByID

func (s *Server) GetNodeByID(c *fiber.Ctx) error

GetNodeByID returns a single graph node with the given ID. @Summary Get graph node by ID. @Description Get a single graph node with the given ID. @Tags nodes @Produce json @Param guid path string true "Graph UID" @Param id path string true "Node ID" @Success 200 {object} api.Node @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes/{id} [get]

func (*Server) GetNodeByUID

func (s *Server) GetNodeByUID(c *fiber.Ctx) error

GetNodeByUID returns a single graph node with the given UID. @Summary Get graph node by UID. @Description Get graph returns a single graph node with the given UID. @Tags nodes @Produce json @Param guid path string true "Graph UID" @Param uid path string true "Node UID" @Success 200 {object} api.Node @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes/uid/{uid} [get]

func (*Server) GetNodes

func (s *Server) GetNodes(c *fiber.Ctx) error

GetNodes returns all nodes in the graph matching a query. @Summary Graph nodes matching a filter. @Description Get all nodes matching a query. @Tags nodes @Produce json @Param offset query int false "Result offset" @Param limit query int false "Result limit" @Param label query string false "Node label" @Param guid path string true "Graph UID" @Success 200 {object} NodesResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes [get]

func (*Server) Listen

func (s *Server) Listen() error

Listen validates the server options and starts listening on the bind address.

func (*Server) UpdateEdgeBetween

func (s *Server) UpdateEdgeBetween(c *fiber.Ctx) error

UpdateEdgeBetween updates an existing edge between two nodes. @Summary Update graph edge between two existing nodes. @Description Update existing graph edge between the nodes with the given IDs. @Tags edges @Accept json @Produce json @Param uid path string true "Graph UID" @Param graph body api.EdgeUpdate true "Update an edge" @Param source query int false "Source node ID" @Param target query int false "Target node ID" @Success 200 {object} api.Edge @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/edges [patch]

func (*Server) UpdateGraph

func (s *Server) UpdateGraph(c *fiber.Ctx) error

UpdateGraph updates existing graph. @Summary Update graph @Description Update existing graph. @Tags graphs @Accept json @Produce json @Param uid path string true "Graph UID" @Param graph body api.GraphUpdate true "Update a graph" @Success 200 {object} api.Graph @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{uid} [patch]

func (*Server) UpdateNode

func (s *Server) UpdateNode(c *fiber.Ctx) error

UpdateNode updates existing graph node. @Summary Update graph node. @Description Update existing graph node. @Tags nodes @Accept json @Produce json @Param uid path string true "Graph UID" @Param id path string true "Node ID" @Param graph body api.NodeUpdate true "Update a node" @Success 200 {object} api.Node @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Failure 500 {object} ErrorResponse @Router /v1/graphs/{guid}/nodes/{id} [patch]

Directories

Path Synopsis
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.

Jump to

Keyboard shortcuts

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