github.com/safing/portbase@v0.19.5/api/client/api.go (about) 1 package client 2 3 // Get sends a get command to the API. 4 func (c *Client) Get(key string, handleFunc func(*Message)) *Operation { 5 op := c.NewOperation(handleFunc) 6 op.Send(msgRequestGet, key, nil) 7 return op 8 } 9 10 // Query sends a query command to the API. 11 func (c *Client) Query(query string, handleFunc func(*Message)) *Operation { 12 op := c.NewOperation(handleFunc) 13 op.Send(msgRequestQuery, query, nil) 14 return op 15 } 16 17 // Sub sends a sub command to the API. 18 func (c *Client) Sub(query string, handleFunc func(*Message)) *Operation { 19 op := c.NewOperation(handleFunc) 20 op.Send(msgRequestSub, query, nil) 21 return op 22 } 23 24 // Qsub sends a qsub command to the API. 25 func (c *Client) Qsub(query string, handleFunc func(*Message)) *Operation { 26 op := c.NewOperation(handleFunc) 27 op.Send(msgRequestQsub, query, nil) 28 return op 29 } 30 31 // Create sends a create command to the API. 32 func (c *Client) Create(key string, value interface{}, handleFunc func(*Message)) *Operation { 33 op := c.NewOperation(handleFunc) 34 op.Send(msgRequestCreate, key, value) 35 return op 36 } 37 38 // Update sends an update command to the API. 39 func (c *Client) Update(key string, value interface{}, handleFunc func(*Message)) *Operation { 40 op := c.NewOperation(handleFunc) 41 op.Send(msgRequestUpdate, key, value) 42 return op 43 } 44 45 // Insert sends an insert command to the API. 46 func (c *Client) Insert(key string, value interface{}, handleFunc func(*Message)) *Operation { 47 op := c.NewOperation(handleFunc) 48 op.Send(msgRequestInsert, key, value) 49 return op 50 } 51 52 // Delete sends a delete command to the API. 53 func (c *Client) Delete(key string, handleFunc func(*Message)) *Operation { 54 op := c.NewOperation(handleFunc) 55 op.Send(msgRequestDelete, key, nil) 56 return op 57 }