'Return a Subnetwork object based on name and region.
:param  name: The name or URL of the subnetwork
:type   name: ``str``
:keyword region: The region of the subnetwork
:type   region: ``str`` or :class:`GCERegion` or ``None``
:return:  A Subnetwork object
:rtype:   :class:`GCESubnetwork`'

def ex_get_subnetwork(self, name, region=None):

    region_name = None
    if name.startswith('https://'):
        parts = self._get_components_from_path(name)
        name = parts['name']
        region_name = parts['region']
    elif isinstance(region, GCERegion):
        region_name = region.name
    elif isinstance(region, str):
        if region.startswith('https://'):
            region_name = region.split('/')[(-1)]
        else:
            region_name = region
    if (not region_name):
        region = self._set_region(region)
        if (not region):
            raise ValueError('Could    not    determine    region    for    subnetwork.')
        else:
            region_name = region.name
    request = ('/regions/%s/subnetworks/%s' % (region_name, name))
    response = self.connection.request(request, method='GET').object
    return self._to_subnetwork(response)
