def _Run(args, holder, url_map_ref, target_http_proxy_ref, traffic_director_security): """Issue a Target HTTP Proxy Insert request.""" client = holder.client if traffic_director_security and args.proxy_bind: target_http_proxy = client.messages.TargetHttpProxy( description=args.description, name=target_http_proxy_ref.Name(), urlMap=url_map_ref.SelfLink(), proxyBind=args.proxy_bind) else: target_http_proxy = client.messages.TargetHttpProxy( description=args.description, name=target_http_proxy_ref.Name(), urlMap=url_map_ref.SelfLink()) if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, region=target_http_proxy_ref.region, targetHttpProxy=target_http_proxy) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, targetHttpProxy=target_http_proxy) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'Insert', request)])
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client target_http_proxy_refs = self.TARGET_HTTP_PROXY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) utils.PromptForDeletion(target_http_proxy_refs) requests = [] for target_http_proxy_ref in target_http_proxy_refs: if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): requests.append( (client.apitools_client.regionTargetHttpProxies, 'Delete', client.messages. ComputeRegionTargetHttpProxiesDeleteRequest( **target_http_proxy_ref.AsDict()))) else: requests.append( (client.apitools_client.targetHttpProxies, 'Delete', client.messages.ComputeTargetHttpProxiesDeleteRequest( **target_http_proxy_ref.AsDict()))) return client.MakeRequests(requests)
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client target_http_proxy_ref = self.TARGET_HTTP_PROXY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) url_map_ref = target_http_proxies_utils.ResolveTargetHttpProxyUrlMap( args, self.URL_MAP_ARG, target_http_proxy_ref, holder.resources) if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesSetUrlMapRequest( project=target_http_proxy_ref.project, region=target_http_proxy_ref.region, targetHttpProxy=target_http_proxy_ref.Name(), urlMapReference=client.messages.UrlMapReference( urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesSetUrlMapRequest( project=target_http_proxy_ref.project, targetHttpProxy=target_http_proxy_ref.Name(), urlMapReference=client.messages.UrlMapReference( urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'SetUrlMap', request)])
def Run(self, args): """Issue a Target HTTP Proxy Insert request.""" holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client target_http_proxy_ref = self.TARGET_HTTP_PROXY_ARG.ResolveAsResource( args, holder.resources) url_map_ref = target_http_proxies_utils.ResolveTargetHttpProxyUrlMap( args, self.URL_MAP_ARG, target_http_proxy_ref, holder.resources) if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, region=target_http_proxy_ref.region, targetHttpProxy=client.messages.TargetHttpProxy( description=args.description, name=target_http_proxy_ref.Name(), urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, targetHttpProxy=client.messages.TargetHttpProxy( description=args.description, name=target_http_proxy_ref.Name(), urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'Insert', request)])
def _WaitForOperation(resources, service, operation, target_http_proxy_ref, message): """Waits for the TargetHttpProxy operation to finish.""" if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): collection = operation_utils.GetRegionalOperationsCollection() else: collection = operation_utils.GetGlobalOperationsCollection() return operation_utils.WaitForOperation(resources, service, operation, collection, target_http_proxy_ref, message)
def _Run(holder, target_http_proxy_ref): """Issues requests necessary to describe Target HTTP Proxies.""" client = holder.client if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesGetRequest( **target_http_proxy_ref.AsDict()) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesGetRequest( **target_http_proxy_ref.AsDict()) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'Get', request)])[0]
def _SendPatchRequest(client, resources, target_http_proxy_ref, target_http_proxy): """Make target HTTP proxy patch request.""" if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): console_message = ('Target HTTP Proxy [{0}] cannot be updated'.format( target_http_proxy_ref.Name())) raise NotImplementedError(console_message) service = client.apitools_client.targetHttpProxies operation = service.Patch( client.messages.ComputeTargetHttpProxiesPatchRequest( project=target_http_proxy_ref.project, targetHttpProxy=target_http_proxy_ref.Name(), targetHttpProxyResource=target_http_proxy)) return _WaitForOperation(resources, service, operation, target_http_proxy_ref, 'Updating TargetHttpProxy')
def Run(self, args): holder = base_classes.ComputeApiHolder(self.ReleaseTrack()) client = holder.client target_http_proxy_ref = self.TARGET_HTTP_PROXY_ARG.ResolveAsResource( args, holder.resources, scope_lister=compute_flags.GetDefaultScopeLister(client)) if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesGetRequest( **target_http_proxy_ref.AsDict()) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesGetRequest( **target_http_proxy_ref.AsDict()) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'Get', request)])[0]
def _Run(holder, target_http_proxy_refs): """Issues requests necessary to delete Target HTTP Proxies.""" client = holder.client utils.PromptForDeletion(target_http_proxy_refs) requests = [] for target_http_proxy_ref in target_http_proxy_refs: if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): requests.append( (client.apitools_client.regionTargetHttpProxies, 'Delete', client.messages.ComputeRegionTargetHttpProxiesDeleteRequest( **target_http_proxy_ref.AsDict()))) else: requests.append( (client.apitools_client.targetHttpProxies, 'Delete', client.messages.ComputeTargetHttpProxiesDeleteRequest( **target_http_proxy_ref.AsDict()))) return client.MakeRequests(requests)
def _SendInsertRequest(client, resources, target_http_proxy_ref, target_http_proxy): """Sends Target HTTP Proxy insert request.""" if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): service = client.apitools_client.regionTargetHttpProxies operation = service.Insert( client.messages.ComputeRegionTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, region=target_http_proxy_ref.region, targetHttpProxy=target_http_proxy)) else: service = client.apitools_client.targetHttpProxies operation = service.Insert( client.messages.ComputeTargetHttpProxiesInsertRequest( project=target_http_proxy_ref.project, targetHttpProxy=target_http_proxy)) return _WaitForOperation(resources, service, operation, target_http_proxy_ref, 'Inserting TargetHttpProxy')
def _Run(holder, target_http_proxy_ref, url_map_ref): """Issues requests necessary to update Target HTTP Proxies.""" client = holder.client if target_http_proxies_utils.IsRegionalTargetHttpProxiesRef( target_http_proxy_ref): request = client.messages.ComputeRegionTargetHttpProxiesSetUrlMapRequest( project=target_http_proxy_ref.project, region=target_http_proxy_ref.region, targetHttpProxy=target_http_proxy_ref.Name(), urlMapReference=client.messages.UrlMapReference( urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.regionTargetHttpProxies else: request = client.messages.ComputeTargetHttpProxiesSetUrlMapRequest( project=target_http_proxy_ref.project, targetHttpProxy=target_http_proxy_ref.Name(), urlMapReference=client.messages.UrlMapReference( urlMap=url_map_ref.SelfLink())) collection = client.apitools_client.targetHttpProxies return client.MakeRequests([(collection, 'SetUrlMap', request)])