예제 #1
0
 def parse(to_parse: str) -> "TopicPath":
     splits = to_parse.split("/")
     if (len(splits) != 6 or splits[0] != "projects"
             or splits[2] != "locations" or splits[4] != "topics"):
         raise InvalidArgument(
             "Topic path must be formatted like projects/{project_number}/locations/{location}/topics/{name} but was instead "
             + to_parse)
     return TopicPath(splits[1], CloudZone.parse(splits[3]), splits[5])
예제 #2
0
def _parse_location(to_parse: str) -> Union[CloudRegion, CloudZone]:
    try:
        return CloudZone.parse(to_parse)
    except InvalidArgument:
        pass
    try:
        return CloudRegion.parse(to_parse)
    except InvalidArgument:
        pass
    raise InvalidArgument("Invalid location name: " + to_parse)