def GetUrlMapGetRequest(self, args, url_map_ref, client): if url_maps_utils.IsGlobalUrlMapRef(url_map_ref): return (client.apitools_client.urlMaps, 'Get', client.messages.ComputeUrlMapsGetRequest( project=properties.VALUES.core.project.GetOrFail(), urlMap=url_map_ref.Name())) else: return (client.apitools_client.regionUrlMaps, 'Get', client.messages.ComputeRegionUrlMapsGetRequest( project=properties.VALUES.core.project.GetOrFail(), urlMap=url_map_ref.Name(), region=url_map_ref.region))
def _GetGetRequest(client, url_map_ref): """Returns the request for the existing URL map resource.""" if url_maps_utils.IsGlobalUrlMapRef(url_map_ref): return (client.apitools_client.urlMaps, 'Get', client.messages.ComputeUrlMapsGetRequest( urlMap=url_map_ref.Name(), project=url_map_ref.project)) else: return (client.apitools_client.regionUrlMaps, 'Get', client.messages.ComputeRegionUrlMapsGetRequest( urlMap=url_map_ref.Name(), project=url_map_ref.project, region=url_map_ref.region))
def _GetSetRequest(self, client, url_map_ref, replacement): if url_maps_utils.IsGlobalUrlMapRef(url_map_ref): return (client.apitools_client.urlMaps, 'Update', client.messages.ComputeUrlMapsUpdateRequest( urlMap=url_map_ref.Name(), urlMapResource=replacement, project=url_map_ref.project)) else: return (client.apitools_client.regionUrlMaps, 'Update', client.messages.ComputeRegionUrlMapsUpdateRequest( urlMap=url_map_ref.Name(), urlMapResource=replacement, project=url_map_ref.project, region=url_map_ref.region))
def _Run(args, holder, backend_bucket_arg, backend_service_arg, url_map_arg): """Issues requests necessary to create a Url Map.""" client = holder.client url_map_ref = url_map_arg.ResolveAsResource( args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL, scope_lister=compute_flags.GetDefaultScopeLister(client)) if args.default_service: default_backend_uri = url_maps_utils.ResolveUrlMapDefaultService( args, backend_service_arg, url_map_ref, holder.resources).SelfLink() else: default_backend_uri = backend_bucket_arg.ResolveAsResource( args, holder.resources).SelfLink() if url_maps_utils.IsGlobalUrlMapRef(url_map_ref): return _MakeGlobalRequest(args, url_map_ref, default_backend_uri, client) elif url_maps_utils.IsRegionalUrlMapRef(url_map_ref): return _MakeRegionalRequest(args, url_map_ref, default_backend_uri, client)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client url_map_ref = self.URL_MAP_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) if args.default_service: default_backend_uri = url_maps_utils.ResolveUrlMapDefaultService( args, self.BACKEND_SERVICE_ARG, url_map_ref, holder.resources).SelfLink() else: default_backend_uri = self.BACKEND_BUCKET_ARG.ResolveAsResource( args, holder.resources).SelfLink() if url_maps_utils.IsGlobalUrlMapRef(url_map_ref): return self._MakeGlobalRequest(args, url_map_ref, default_backend_uri, client) elif url_maps_utils.IsRegionalUrlMapRef(url_map_ref): return self._MakeRegionalRequest(args, url_map_ref, default_backend_uri, client)