1 // TYPEs returns a slice of TYPE matching the filter expression filter.
2 // If no PLURAL match, error wraps ErrNoMatch.
3 // To fetch all LOWER, set filter to the empty string ("").
4 func (c *Client) TYPEs(filter string) ([]TYPE, error) {
5 objects, err := c.filterObjects("/objects/PLURAL", filter)
7 return nil, fmt.Errorf("get PLURAL filter %s: %w", filter, err)
10 for _, o := range objects {
13 return nil, fmt.Errorf("get PLURAL filter %s: %T in response", filter, v)
15 PLURAL = append(PLURAL, v)
20 // LookupTYPE returns the TYPE identified by name. If no TYPE is found, error
22 func (c *Client) LookupTYPE(name string) (TYPE, error) {
23 obj, err := c.lookupObject("/objects/PLURAL/" + url.PathEscape(name))
25 return TYPE{}, fmt.Errorf("lookup LOWER %s: %w", name, err)
29 return TYPE{}, fmt.Errorf("lookup LOWER %s: result type %T is not TYPE", name, v)
34 // CreateTYPE creates LOWER. Some fields of LOWER must be set for successful
35 // creation; see the type definition of TYPE for details.
36 func (c *Client) CreateTYPE(LOWER TYPE) error {
37 if err := c.createObject(LOWER); err != nil {
38 return fmt.Errorf("create LOWER %s: %w", LOWER.Name, err)
43 // DeleteTYPE deletes the TYPE identified by name. If cascade is true, objects
44 // depending on the TYPE are also deleted. If no TYPE is found, error wraps
46 func (c *Client) DeleteTYPE(name string, cascade bool) error {
47 if err := c.deleteObject("/objects/PLURAL/"+url.PathEscape(name), cascade); err != nil {
48 return fmt.Errorf("delete LOWER %s: %w", name, err)