8460: Add event_at and props.{new,old}.{pdh,owner} to websocket v0. Fix fuse crash...
[arvados.git] / sdk / go / arvados / client.go
index 0c18d38974f8be6ce99460ef2713e220a2cff403..a7d8c4acea1ecf208b45253f210a9b12f234c846 100644 (file)
@@ -241,14 +241,10 @@ func (c *Client) DiscoveryDocument() (*DiscoveryDocument, error) {
        return c.dd, nil
 }
 
-func (c *Client) PathForUUID(method, uuid string) (string, error) {
+func (c *Client) modelForUUID(dd *DiscoveryDocument, uuid string) (string, error) {
        if len(uuid) != 27 {
                return "", fmt.Errorf("invalid UUID: %q", uuid)
        }
-       dd, err := c.DiscoveryDocument()
-       if err != nil {
-               return "", err
-       }
        infix := uuid[6:11]
        var model string
        for m, s := range dd.Schemas {
@@ -260,6 +256,30 @@ func (c *Client) PathForUUID(method, uuid string) (string, error) {
        if model == "" {
                return "", fmt.Errorf("unrecognized UUID infix: %q", infix)
        }
+       return model, nil
+}
+
+func (c *Client) KindForUUID(uuid string) (string, error) {
+       dd, err := c.DiscoveryDocument()
+       if err != nil {
+               return "", err
+       }
+       model, err := c.modelForUUID(dd, uuid)
+       if err != nil {
+               return "", err
+       }
+       return "arvados#" + strings.ToLower(model[:1]) + model[1:], nil
+}
+
+func (c *Client) PathForUUID(method, uuid string) (string, error) {
+       dd, err := c.DiscoveryDocument()
+       if err != nil {
+               return "", err
+       }
+       model, err := c.modelForUUID(dd, uuid)
+       if err != nil {
+               return "", err
+       }
        var resource string
        for r, rsc := range dd.Resources {
                if rsc.Methods["get"].Response.Ref == model {