def METHOD_NAME(cls, object_kind, path_component_map, url, defaults=None):
    """Constructs a key given a GCP object reference URL.
    Inter-object references in GCP APIs use URLs. These URLs are a sequence
    of key-value pairs describing the path to the resource, e.g.:
      https://www.googleapis.com/compute/v1
      /projects/foo
      /global
      /backendServices/bar
    describes a backend service named 'bar' with global scope in
    project 'foo', whereas:
      https://www.googleapis.com/compute/v1
      /projects/foo
      /zones/us-east1-a
      /instances/bar
    describes a compute instance named 'bar' in zone 'us-east1-a'
    of project 'foo'.
    Args:
        object_kind (str): The kind of resource the key represents
        path_component_map (dict): Maps components in the URL
                                   path to object_path keys. In the backend
                                   service example, this would be:
                                     {'projects': 'project_id',
                                      'backendServices': 'name'}
                                   The special component 'global'
                                   is ignored.  If a component not
                                   seen in this map is seen, this
                                   function raises an
                                   exception. The caller is
                                   responsible for checking that
                                   all required components were
                                   present.
        url (str): Resource URL
        defaults (dict): If non-None, a dictionary specifying default values
                         for object_path keys.
    Returns:
        Key: A Key instance
    Raises:
        ValueError: If the URL is invalid.
    """
    # The first two components identify the API name and version,
    # e.g. ('compute', 'v1'). Ignore those.
    path_components = urllib.parse.urlparse(url)[2].split('/')[3:]
    key_name = None
    object_path = dict((key, None) for key in
                       list(path_component_map.values()))
    if defaults:
        object_path.update(defaults)
    for path_component in path_components:
        if key_name:
            object_path[key_name] = path_component
            key_name = None
        elif path_component == 'global':
            # GCE APIs use special path 'global' to indicate that there's
            # no scope (zone, region, etc.)
            pass
        else:
            key_name = path_component_map.get(path_component)
            if not key_name:
                raise ValueError('Unexpected key %s in %s URL %r' % (
                    path_component, object_kind, url))
    if key_name:
        raise ValueError('No value found for key %s in %s URL %r' % (
            key_name, object_kind, url))
    else:
        return cls(object_kind, object_path)