'Parse GCP urls and return dict of parts.
Supported URL structures:
/SERVICE/VERSION/\'projects\'/PROJECT_ID/RESOURCE
/SERVICE/VERSION/\'projects\'/PROJECT_ID/RESOURCE/ENTITY_NAME
/SERVICE/VERSION/\'projects\'/PROJECT_ID/RESOURCE/ENTITY_NAME/METHOD_NAME
/SERVICE/VERSION/\'projects\'/PROJECT_ID/\'global\'/RESOURCE
/SERVICE/VERSION/\'projects\'/PROJECT_ID/\'global\'/RESOURCE/ENTITY_NAME
/SERVICE/VERSION/\'projects\'/PROJECT_ID/\'global\'/RESOURCE/ENTITY_NAME/METHOD_NAME
/SERVICE/VERSION/\'projects\'/PROJECT_ID/LOCATION_TYPE/LOCATION/RESOURCE
/SERVICE/VERSION/\'projects\'/PROJECT_ID/LOCATION_TYPE/LOCATION/RESOURCE/ENTITY_NAME
/SERVICE/VERSION/\'projects\'/PROJECT_ID/LOCATION_TYPE/LOCATION/RESOURCE/ENTITY_NAME/METHOD_NAME
:param url: GCP-generated URL, such as a selflink or resource location.
:type url: ``str``
:return: dictionary of parts. Includes stanard components of urlparse, plus
GCP-specific \'service\', \'api_version\', \'project\' and
\'resource_name\' keys. Optionally, \'zone\', \'region\', \'entity_name\'
and \'method_name\', if applicable.
:rtype: ``dict``'

@staticmethod
def parse_gcp_url(url):

    p = urlparse.urlparse(url)
    if (not p):
        return None
    else:
        url_parts = {}
        url_parts['scheme'] = p.scheme
        url_parts['host'] = p.netloc
        url_parts['path'] = p.path
        if (p.path.find('/') == 0):
            url_parts['path'] = p.path[1:]
        url_parts['params'] = p.params
        url_parts['fragment'] = p.fragment
        url_parts['query'] = p.query
        url_parts['project'] = None
        url_parts['service'] = None
        url_parts['api_version'] = None
        path_parts = url_parts['path'].split('/')
        url_parts['service'] = path_parts[0]
        url_parts['api_version'] = path_parts[1]
        if (path_parts[2] == 'projects'):
            url_parts['project'] = path_parts[3]
        else:
            raise GCPInvalidURLError(('unable    to    parse:    %s' % url))
        if ('global' in path_parts):
            url_parts['global'] = True
            idx = path_parts.index('global')
            if ((len(path_parts) - idx) == 4):
                url_parts['resource_name'] = path_parts[(idx + 1)]
                url_parts['entity_name'] = path_parts[(idx + 2)]
                url_parts['method_name'] = path_parts[(idx + 3)]
            if ((len(path_parts) - idx) == 3):
                url_parts['resource_name'] = path_parts[(idx + 1)]
                url_parts['entity_name'] = path_parts[(idx + 2)]
            if ((len(path_parts) - idx) == 2):
                url_parts['resource_name'] = path_parts[(idx + 1)]
            if ((len(path_parts) - idx) < 2):
                raise GCPInvalidURLError(('unable    to    parse:    %s' % url))
        elif (('regions' in path_parts) or ('zones' in path_parts)):
            idx = (-1)
            if ('regions' in path_parts):
                idx = path_parts.index('regions')
                url_parts['region'] = path_parts[(idx + 1)]
            else:
                idx = path_parts.index('zones')
                url_parts['zone'] = path_parts[(idx + 1)]
            if ((len(path_parts) - idx) == 5):
                url_parts['resource_name'] = path_parts[(idx + 2)]
                url_parts['entity_name'] = path_parts[(idx + 3)]
                url_parts['method_name'] = path_parts[(idx + 4)]
            if ((len(path_parts) - idx) == 4):
                url_parts['resource_name'] = path_parts[(idx + 2)]
                url_parts['entity_name'] = path_parts[(idx + 3)]
            if ((len(path_parts) - idx) == 3):
                url_parts['resource_name'] = path_parts[(idx + 2)]
            if ((len(path_parts) - idx) < 3):
                raise GCPInvalidURLError(('unable    to    parse:    %s' % url))
        else:
            idx = path_parts.index('projects')
            if ((len(path_parts) - idx) == 5):
                url_parts['resource_name'] = path_parts[(idx + 2)]
                url_parts['entity_name'] = path_parts[(idx + 3)]
                url_parts['method_name'] = path_parts[(idx + 4)]
            if ((len(path_parts) - idx) == 4):
                url_parts['resource_name'] = path_parts[(idx + 2)]
                url_parts['entity_name'] = path_parts[(idx + 3)]
            if ((len(path_parts) - idx) == 3):
                url_parts['resource_name'] = path_parts[(idx + 2)]
            if ((len(path_parts) - idx) < 3):
                raise GCPInvalidURLError(('unable    to    parse:    %s' % url))
        return url_parts
