code: function(r) {
      if (r instanceof ResourceGroupVersion) {
        return r;
      }
      var resource, group, version;
      if (angular.isString(r)) {
        resource = normalizeResource(r);
        group = '';
        version = defaultVersion[group];
      } else if (r && r.resource) {
        resource = normalizeResource(r.resource);
        group = r.group || '';
        version = r.version || defaultVersion[group] || _.get(APIS_CFG, ["groups", group, "preferredVersion"]);
      }
      return new ResourceGroupVersion(resource, group, version);
    }
docs: toResourceGroupVersion() returns a ResourceGroupVersion. If resource is already a ResourceGroupVersion, returns itself.  if r is a string, the empty group and default version for the empty group are assumed.  if r is an object, the resource, group, and version attributes are read. a missing group attribute defaults to the legacy group. a missing version attribute defaults to the default version for the group, or undefined if the group is unknown.  if r is already a ResourceGroupVersion, it is returned as-is