Documentation ¶
Overview ¶
Package hierarchy provides the client for making API requests to Enlight Hierarchy Management Service.
Index ¶
- type Client
- func (c *Client) Close()
- func (c *Client) DeepPing() error
- func (c *Client) DeepPingWithContext(ctx context.Context) error
- func (c *Client) DeleteNode(request hierarchy_grpcapi.DeleteNodeInput) error
- func (c *Client) DeleteNodeWithContext(ctx context.Context, request hierarchy_grpcapi.DeleteNodeInput) error
- func (c *Client) Dial(host, port string, opts ...grpc.DialOption) (err error)
- func (c *Client) DialWithContext(ctx context.Context, host, port string, opts ...grpc.DialOption) (err error)
- func (c *Client) GetAncestors(nodeID string) (nodes []hierarchy_grpcapi.AncestorNode, err error)
- func (c *Client) GetAncestorsWithContext(ctx context.Context, nodeID string) (nodes []hierarchy_grpcapi.AncestorNode, err error)
- func (c *Client) GetChildNodes(parentID string) (nodes []hierarchy_grpcapi.Node, err error)
- func (c *Client) GetChildNodesWithContext(ctx context.Context, parentID string) (nodes []hierarchy_grpcapi.Node, err error)
- func (c *Client) GetEvents(since int, limit *int32) (events []eventsource.Record, err error)
- func (c *Client) GetEventsWithContext(ctx context.Context, since int, limit *int32) (events []eventsource.Record, err error)
- func (c *Client) GetNode(uuid string) (node hierarchy_grpcapi.Node, err error)
- func (c *Client) GetNodeIDByOrigin(origin common.Origin) (string, error)
- func (c *Client) GetNodeIDByOriginWithContext(ctx context.Context, origin common.Origin) (string, error)
- func (c *Client) GetNodeWithContext(ctx context.Context, uuid string) (node hierarchy_grpcapi.Node, err error)
- func (c *Client) GetNodes(parentID string) (nodes []hierarchy_grpcapi.Node, err error)
- func (c *Client) GetNodesWithContext(ctx context.Context, parentID string) (nodes []hierarchy_grpcapi.Node, err error)
- func (c *Client) GetParentNode(nodeID string) (node hierarchy_grpcapi.Node, err error)
- func (c *Client) GetParentNodeWithContext(ctx context.Context, nodeID string) (node hierarchy_grpcapi.Node, err error)
- func (c *Client) SaveNode(request hierarchy_grpcapi.SaveNodeInput) (string, error)
- func (c *Client) SaveNodeWithContext(ctx context.Context, request hierarchy_grpcapi.SaveNodeInput) (string, error)
- type HierarchyClient
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client implements the HierarchyClient and holds the connection.
Example ¶
package main import ( "log" "github.com/SKF/go-enlight-sdk/grpc" "github.com/SKF/go-enlight-sdk/services/hierarchy" ) func main() { host, port := "<host>", "<port>" clientCert, clientKey := "<clientCertPath>", "<clientKey>" caCert := "<caCert>" // Create a Hierarchy Service client client := hierarchy.CreateClient() // Dial the Hierarchy Service dialOption, err := grpc.WithTransportCredentials(host, clientCert, clientKey, caCert) if err != nil { log.Fatalf("Couldn't connect due to error: %+v", err) } // Dial the Hierarchy Service err = client.Dial(host, port, dialOption) if err != nil { log.Fatalf("Couldn't dial due to error: %+v", err) } defer client.Close() // Ping the Hierarchy Service err = client.DeepPing() if err != nil { log.Fatalf("Couldn't ping the Hierarchy Service due to error: %+v", err) } }
Output:
func (*Client) Close ¶
func (c *Client) Close()
Close tears down the ClientConn and all underlying connections.
func (*Client) DeepPingWithContext ¶
DeepPingWithContext pings the service to see if it is alive.
func (*Client) DeleteNode ¶
func (c *Client) DeleteNode(request hierarchy_grpcapi.DeleteNodeInput) error
DeleteNode will remove the node of the node id it takes as an argument.
func (*Client) DeleteNodeWithContext ¶
func (c *Client) DeleteNodeWithContext(ctx context.Context, request hierarchy_grpcapi.DeleteNodeInput) error
DeleteNodeWithContext will remove the node of the node id it takes as an argument.
func (*Client) Dial ¶
func (c *Client) Dial(host, port string, opts ...grpc.DialOption) (err error)
Dial creates a client connection to the given host with background context and no timeout
func (*Client) DialWithContext ¶
func (c *Client) DialWithContext(ctx context.Context, host, port string, opts ...grpc.DialOption) (err error)
DialWithContext creates a client connection to the given host with context (for timeout and transaction id)
func (*Client) GetAncestors ¶
func (c *Client) GetAncestors(nodeID string) (nodes []hierarchy_grpcapi.AncestorNode, err error)
GetAncestors will return all ancestors to the top of the node id it takes as an argument.
func (*Client) GetAncestorsWithContext ¶
func (c *Client) GetAncestorsWithContext(ctx context.Context, nodeID string) (nodes []hierarchy_grpcapi.AncestorNode, err error)
GetAncestorsWithContext will return all ancestors to the top of the node id it takes as an argument.
func (*Client) GetChildNodes ¶
func (c *Client) GetChildNodes(parentID string) (nodes []hierarchy_grpcapi.Node, err error)
GetChildNodes will get all child nodes for the node id it takes as an argument.
func (*Client) GetChildNodesWithContext ¶
func (c *Client) GetChildNodesWithContext(ctx context.Context, parentID string) (nodes []hierarchy_grpcapi.Node, err error)
GetChildNodesWithContext will get all child nodes for the node id it takes as an argument.
func (*Client) GetEvents ¶
GetEvents will return all events that has occured in the Hierarchy Management Service.
func (*Client) GetEventsWithContext ¶
func (c *Client) GetEventsWithContext(ctx context.Context, since int, limit *int32) (events []eventsource.Record, err error)
GetEventsWithContext will return all events that has occured in the Hierarchy Management Service.
func (*Client) GetNode ¶
func (c *Client) GetNode(uuid string) (node hierarchy_grpcapi.Node, err error)
GetNode takes an id of a node and returns the node.
func (*Client) GetNodeIDByOrigin ¶
GetNodeIDByOrigin takes an origin and returns the Enlight ID.
func (*Client) GetNodeIDByOriginWithContext ¶
func (c *Client) GetNodeIDByOriginWithContext(ctx context.Context, origin common.Origin) (string, error)
GetNodeIDByOriginWithContext takes an origin and returns the Enlight ID.
func (*Client) GetNodeWithContext ¶
func (c *Client) GetNodeWithContext(ctx context.Context, uuid string) (node hierarchy_grpcapi.Node, err error)
GetNodeWithContext takes an id of a node and returns the node.
func (*Client) GetNodes ¶
func (c *Client) GetNodes(parentID string) (nodes []hierarchy_grpcapi.Node, err error)
GetNodes will get all child nodes for the node id it takes as an argument.
func (*Client) GetNodesWithContext ¶
func (c *Client) GetNodesWithContext(ctx context.Context, parentID string) (nodes []hierarchy_grpcapi.Node, err error)
GetNodesWithContext will get all child nodes for the node id it takes as an argument.
func (*Client) GetParentNode ¶
func (c *Client) GetParentNode(nodeID string) (node hierarchy_grpcapi.Node, err error)
GetParentNode will return the parent of the node id it takes as an argument.
func (*Client) GetParentNodeWithContext ¶
func (c *Client) GetParentNodeWithContext(ctx context.Context, nodeID string) (node hierarchy_grpcapi.Node, err error)
GetParentNodeWithContext will return the parent of the node id it takes as an argument.
func (*Client) SaveNode ¶
func (c *Client) SaveNode(request hierarchy_grpcapi.SaveNodeInput) (string, error)
SaveNode will add the node if it this not exist and otherwise create it.
Example (Create) ¶
package main import ( "log" hierarchy_grpcapi "github.com/SKF/proto/hierarchy" "github.com/SKF/go-enlight-sdk/services/hierarchy" ) func main() { var client hierarchy.HierarchyClient saveNodeInput := hierarchy_grpcapi.SaveNodeInput{ UserId: "<user_id>", Node: &hierarchy_grpcapi.Node{}, ParentId: "<parent_id>", } nodeID, err := client.SaveNode(saveNodeInput) if err != nil { log.Printf("Couldn't save node due to error: %+v", err) return } log.Printf("nodeId: %q", nodeID) }
Output:
Example (Update) ¶
package main import ( "log" hierarchy_grpcapi "github.com/SKF/proto/hierarchy" "github.com/SKF/go-enlight-sdk/services/hierarchy" ) func main() { var client hierarchy.HierarchyClient saveNodeInput := hierarchy_grpcapi.SaveNodeInput{ UserId: "<user_id>", Node: &hierarchy_grpcapi.Node{ Id: "<node_id>", }, ParentId: "<parent_id>", } nodeID, err := client.SaveNode(saveNodeInput) if err != nil { log.Printf("Couldn't save node due to error: %+v", err) return } log.Printf("nodeId: %q", nodeID) }
Output:
func (*Client) SaveNodeWithContext ¶
func (c *Client) SaveNodeWithContext(ctx context.Context, request hierarchy_grpcapi.SaveNodeInput) (string, error)
SaveNode will add the node if it this not exist and otherwise create it.
type HierarchyClient ¶
type HierarchyClient interface { Dial(host, port string, opts ...grpc.DialOption) error DialWithContext(ctx context.Context, host, port string, opts ...grpc.DialOption) error Close() DeepPing() error DeepPingWithContext(ctx context.Context) error SaveNode(request hierarchy_grpcapi.SaveNodeInput) (string, error) SaveNodeWithContext(ctx context.Context, request hierarchy_grpcapi.SaveNodeInput) (string, error) GetNode(nodeID string) (hierarchy_grpcapi.Node, error) GetNodeWithContext(ctx context.Context, nodeID string) (hierarchy_grpcapi.Node, error) GetNodes(parentID string) ([]hierarchy_grpcapi.Node, error) GetNodesWithContext(ctx context.Context, parentID string) ([]hierarchy_grpcapi.Node, error) GetChildNodes(parentID string) ([]hierarchy_grpcapi.Node, error) GetChildNodesWithContext(ctx context.Context, parentID string) ([]hierarchy_grpcapi.Node, error) DeleteNode(request hierarchy_grpcapi.DeleteNodeInput) error DeleteNodeWithContext(ctx context.Context, request hierarchy_grpcapi.DeleteNodeInput) error GetAncestors(nodeID string) ([]hierarchy_grpcapi.AncestorNode, error) GetAncestorsWithContext(ctx context.Context, nodeID string) ([]hierarchy_grpcapi.AncestorNode, error) GetEvents(since int, limit *int32) ([]eventsource.Record, error) GetEventsWithContext(ctx context.Context, since int, limit *int32) ([]eventsource.Record, error) GetParentNode(nodeID string) (hierarchy_grpcapi.Node, error) GetParentNodeWithContext(ctx context.Context, nodeID string) (hierarchy_grpcapi.Node, error) GetNodeIDByOrigin(origin common.Origin) (string, error) GetNodeIDByOriginWithContext(ctx context.Context, origin common.Origin) (string, error) }
HierarchyClient provides the API operation methods for making requests to Enlight Hierarchy Management Service. See this package's package overview docs for details on the service.
func CreateClient ¶
func CreateClient() HierarchyClient
CreateClient creates an instance of the HierarchyClient.