示例#1
0
def _Run(args, holder, ssl_certificates_arg, target_https_proxy_arg,
         url_map_arg, ssl_policy_arg, certificate_map_ref):
    """Issues requests necessary to update Target HTTPS Proxies."""
    client = holder.client

    target_https_proxy_ref = target_https_proxy_arg.ResolveAsResource(
        args,
        holder.resources,
        default_scope=compute_scope.ScopeEnum.GLOBAL,
        scope_lister=compute_flags.GetDefaultScopeLister(client))

    old_resource = _GetTargetHttpsProxy(client, target_https_proxy_ref)
    new_resource = encoding.CopyProtoMessage(old_resource)
    cleared_fields = []

    if args.ssl_certificates:
        ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
            args, ssl_certificates_arg, target_https_proxy_ref,
            holder.resources)
        new_resource.sslCertificates = [
            ref.SelfLink() for ref in ssl_cert_refs
        ]

    if args.url_map:
        new_resource.urlMap = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
            args, url_map_arg, target_https_proxy_ref,
            holder.resources).SelfLink()

    if args.quic_override:
        new_resource.quicOverride = client.messages.TargetHttpsProxy.QuicOverrideValueValuesEnum(
            args.quic_override)

    if args.ssl_policy:
        ssl_policy_ref = target_https_proxies_utils.ResolveSslPolicy(
            args, ssl_policy_arg, target_https_proxy_ref, holder.resources)
        new_resource.sslPolicy = ssl_policy_ref.SelfLink()

    if args.IsSpecified('clear_ssl_policy'):
        new_resource.sslPolicy = None
        cleared_fields.append('sslPolicy')

    if certificate_map_ref:
        new_resource.certificateMap = certificate_map_ref.SelfLink()

    if args.IsKnownAndSpecified('clear_certificate_map'):
        new_resource.certificateMap = None
        cleared_fields.append('certificateMap')

    if old_resource != new_resource:
        return _PatchTargetHttpsProxy(client, target_https_proxy_ref,
                                      new_resource, cleared_fields)
    return []
示例#2
0
 def Run(self, args):
   holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
   target_https_proxy_ref = self.TARGET_HTTPS_PROXY_ARG.ResolveAsResource(
       args, holder.resources)
   url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
       args, self.URL_MAP_ARG, target_https_proxy_ref, holder.resources)
   ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
       args, self.SSL_CERTIFICATES_ARG, target_https_proxy_ref,
       holder.resources)
   ssl_policy_ref = self.SSL_POLICY_ARG.ResolveAsResource(
       args, holder.resources) if args.ssl_policy else None
   return _Run(args, holder, target_https_proxy_ref, url_map_ref,
               ssl_cert_refs, ssl_policy_ref, self._traffic_director_security)
示例#3
0
 def Run(self, args):
   if self.ReleaseTrack() == base.ReleaseTrack.GA:
     log.warning('The target-https-proxies create command will soon require '
                 'either a --global or --region flag.')
   holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
   target_https_proxy_ref = self.TARGET_HTTPS_PROXY_ARG.ResolveAsResource(
       args, holder.resources)
   url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
       args, self.URL_MAP_ARG, target_https_proxy_ref, holder.resources)
   ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
       args, self.SSL_CERTIFICATES_ARG, target_https_proxy_ref,
       holder.resources)
   ssl_policy_ref = self.SSL_POLICY_ARG.ResolveAsResource(
       args, holder.resources) if args.ssl_policy else None
   return _Run(args, holder, target_https_proxy_ref, url_map_ref,
               ssl_cert_refs, ssl_policy_ref, self._traffic_director_security)
示例#4
0
    def Run(self, args):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client

        target_https_proxy_ref = self.TARGET_HTTPS_PROXY_ARG.ResolveAsResource(
            args, holder.resources)

        url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
            args, self.URL_MAP_ARG, target_https_proxy_ref, holder.resources)

        ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
            args, self.SSL_CERTIFICATES_ARG, target_https_proxy_ref,
            holder.resources)

        target_https_proxy = client.messages.TargetHttpsProxy(
            description=args.description,
            name=target_https_proxy_ref.Name(),
            urlMap=url_map_ref.SelfLink(),
            sslCertificates=[ref.SelfLink() for ref in ssl_cert_refs])

        ssl_policy_ref = self.SSL_POLICY_ARG.ResolveAsResource(
            args, holder.resources) if args.ssl_policy else None

        if args.IsSpecified('quic_override'):
            quic_enum = client.messages.TargetHttpsProxy.QuicOverrideValueValuesEnum
            target_https_proxy.quicOverride = quic_enum(args.quic_override)

        if ssl_policy_ref:
            target_https_proxy.sslPolicy = ssl_policy_ref.SelfLink()

        if target_https_proxies_utils.IsRegionalTargetHttpsProxiesRef(
                target_https_proxy_ref):
            request = client.messages.ComputeRegionTargetHttpsProxiesInsertRequest(
                project=target_https_proxy_ref.project,
                region=target_https_proxy_ref.region,
                targetHttpsProxy=target_https_proxy)
            collection = client.apitools_client.regionTargetHttpsProxies
        else:
            request = client.messages.ComputeTargetHttpsProxiesInsertRequest(
                project=target_https_proxy_ref.project,
                targetHttpsProxy=target_https_proxy)
            collection = client.apitools_client.targetHttpsProxies

        return client.MakeRequests([(collection, 'Insert', request)])
示例#5
0
 def Run(self, args):
   holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
   target_https_proxy_ref = self.TARGET_HTTPS_PROXY_ARG.ResolveAsResource(
       args, holder.resources, default_scope=compute_scope.ScopeEnum.GLOBAL)
   url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
       args, self.URL_MAP_ARG, target_https_proxy_ref, holder.resources)
   ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
       args, self.SSL_CERTIFICATES_ARG, target_https_proxy_ref,
       holder.resources)
   if args.ssl_policy:
     ssl_policy_ref = target_https_proxies_utils.ResolveSslPolicy(
         args, self.SSL_POLICY_ARG, target_https_proxy_ref, holder.resources)
   else:
     ssl_policy_ref = None
   certificate_map_ref = args.CONCEPTS.certificate_map.Parse(
   ) if self._certificate_map else None
   return _Run(args, holder, target_https_proxy_ref, url_map_ref,
               ssl_cert_refs, ssl_policy_ref, self._traffic_director_security,
               certificate_map_ref)
示例#6
0
def _Run(args, holder, ssl_certificates_arg, target_https_proxy_arg,
         url_map_arg, ssl_policy_arg):
    """Issues requests necessary to update Target HTTPS Proxies."""
    client = holder.client

    requests = []
    target_https_proxy_ref = target_https_proxy_arg.ResolveAsResource(
        args,
        holder.resources,
        scope_lister=compute_flags.GetDefaultScopeLister(client))

    if args.ssl_certificates:
        ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
            args, ssl_certificates_arg, target_https_proxy_ref,
            holder.resources)
        if target_https_proxies_utils.IsRegionalTargetHttpsProxiesRef(
                target_https_proxy_ref):
            requests.append(
                (client.apitools_client.regionTargetHttpsProxies,
                 'SetSslCertificates',
                 client.messages.
                 ComputeRegionTargetHttpsProxiesSetSslCertificatesRequest(
                     project=target_https_proxy_ref.project,
                     region=target_https_proxy_ref.region,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     regionTargetHttpsProxiesSetSslCertificatesRequest=(
                         client.messages.
                         RegionTargetHttpsProxiesSetSslCertificatesRequest(
                             sslCertificates=[
                                 ref.SelfLink() for ref in ssl_cert_refs
                             ])))))
        else:
            requests.append(
                (client.apitools_client.targetHttpsProxies,
                 'SetSslCertificates',
                 client.messages.
                 ComputeTargetHttpsProxiesSetSslCertificatesRequest(
                     project=target_https_proxy_ref.project,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     targetHttpsProxiesSetSslCertificatesRequest=(
                         client.messages.
                         TargetHttpsProxiesSetSslCertificatesRequest(
                             sslCertificates=[
                                 ref.SelfLink() for ref in ssl_cert_refs
                             ])))))

    if args.url_map:
        url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
            args, url_map_arg, target_https_proxy_ref, holder.resources)
        if target_https_proxies_utils.IsRegionalTargetHttpsProxiesRef(
                target_https_proxy_ref):
            requests.append(
                (client.apitools_client.regionTargetHttpsProxies, 'SetUrlMap',
                 client.messages.
                 ComputeRegionTargetHttpsProxiesSetUrlMapRequest(
                     project=target_https_proxy_ref.project,
                     region=target_https_proxy_ref.region,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     urlMapReference=client.messages.UrlMapReference(
                         urlMap=url_map_ref.SelfLink()))))
        else:
            requests.append(
                (client.apitools_client.targetHttpsProxies, 'SetUrlMap',
                 client.messages.ComputeTargetHttpsProxiesSetUrlMapRequest(
                     project=target_https_proxy_ref.project,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     urlMapReference=client.messages.UrlMapReference(
                         urlMap=url_map_ref.SelfLink()))))

    if args.IsSpecified('quic_override'):
        quic_override = (
            client.messages.TargetHttpsProxiesSetQuicOverrideRequest.
            QuicOverrideValueValuesEnum(args.quic_override))
        requests.append(
            (client.apitools_client.targetHttpsProxies, 'SetQuicOverride',
             client.messages.ComputeTargetHttpsProxiesSetQuicOverrideRequest(
                 project=target_https_proxy_ref.project,
                 targetHttpsProxy=target_https_proxy_ref.Name(),
                 targetHttpsProxiesSetQuicOverrideRequest=(
                     client.messages.TargetHttpsProxiesSetQuicOverrideRequest(
                         quicOverride=quic_override)))))

    ssl_policy = client.messages.SslPolicyReference(
        sslPolicy=ssl_policy_arg.ResolveAsResource(args, holder.resources).
        SelfLink()) if args.IsSpecified('ssl_policy') else None
    clear_ssl_policy = args.IsSpecified('clear_ssl_policy')

    if ssl_policy or clear_ssl_policy:
        requests.append(
            (client.apitools_client.targetHttpsProxies, 'SetSslPolicy',
             client.messages.ComputeTargetHttpsProxiesSetSslPolicyRequest(
                 project=target_https_proxy_ref.project,
                 targetHttpsProxy=target_https_proxy_ref.Name(),
                 sslPolicyReference=ssl_policy)))

    return client.MakeRequests(requests)
示例#7
0
    def _SendRequests(self, args, quic_override=None):
        holder = base_classes.ComputeApiHolder(self.ReleaseTrack())
        client = holder.client

        requests = []
        target_https_proxy_ref = self.TARGET_HTTPS_PROXY_ARG.ResolveAsResource(
            args,
            holder.resources,
            scope_lister=compute_flags.GetDefaultScopeLister(client))

        if args.ssl_certificates:
            ssl_cert_refs = target_https_proxies_utils.ResolveSslCertificates(
                args, self.SSL_CERTIFICATES_ARG, target_https_proxy_ref,
                holder.resources)
            if target_https_proxies_utils.IsRegionalTargetHttpsProxiesRef(
                    target_https_proxy_ref):
                requests.append(
                    (client.apitools_client.regionTargetHttpsProxies,
                     'SetSslCertificates',
                     client.messages.
                     ComputeRegionTargetHttpsProxiesSetSslCertificatesRequest(
                         project=target_https_proxy_ref.project,
                         region=target_https_proxy_ref.region,
                         targetHttpsProxy=target_https_proxy_ref.Name(),
                         regionTargetHttpsProxiesSetSslCertificatesRequest=(
                             client.messages.
                             RegionTargetHttpsProxiesSetSslCertificatesRequest(
                                 sslCertificates=[
                                     ref.SelfLink() for ref in ssl_cert_refs
                                 ])))))
            else:
                requests.append(
                    (client.apitools_client.targetHttpsProxies,
                     'SetSslCertificates',
                     client.messages.
                     ComputeTargetHttpsProxiesSetSslCertificatesRequest(
                         project=target_https_proxy_ref.project,
                         targetHttpsProxy=target_https_proxy_ref.Name(),
                         targetHttpsProxiesSetSslCertificatesRequest=(
                             client.messages.
                             TargetHttpsProxiesSetSslCertificatesRequest(
                                 sslCertificates=[
                                     ref.SelfLink() for ref in ssl_cert_refs
                                 ])))))

        if args.url_map:
            url_map_ref = target_https_proxies_utils.ResolveTargetHttpsProxyUrlMap(
                args, self.URL_MAP_ARG, target_https_proxy_ref,
                holder.resources)
            if target_https_proxies_utils.IsRegionalTargetHttpsProxiesRef(
                    target_https_proxy_ref):
                requests.append(
                    (client.apitools_client.regionTargetHttpsProxies,
                     'SetUrlMap',
                     client.messages.
                     ComputeRegionTargetHttpsProxiesSetUrlMapRequest(
                         project=target_https_proxy_ref.project,
                         region=target_https_proxy_ref.region,
                         targetHttpsProxy=target_https_proxy_ref.Name(),
                         urlMapReference=client.messages.UrlMapReference(
                             urlMap=url_map_ref.SelfLink()))))
            else:
                requests.append(
                    (client.apitools_client.targetHttpsProxies, 'SetUrlMap',
                     client.messages.ComputeTargetHttpsProxiesSetUrlMapRequest(
                         project=target_https_proxy_ref.project,
                         targetHttpsProxy=target_https_proxy_ref.Name(),
                         urlMapReference=client.messages.UrlMapReference(
                             urlMap=url_map_ref.SelfLink()))))

        if args.IsSpecified('quic_override'):
            quic_override = (
                client.messages.TargetHttpsProxiesSetQuicOverrideRequest.
                QuicOverrideValueValuesEnum(args.quic_override))
            requests.append(
                (client.apitools_client.targetHttpsProxies, 'SetQuicOverride',
                 client.messages.
                 ComputeTargetHttpsProxiesSetQuicOverrideRequest(
                     project=target_https_proxy_ref.project,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     targetHttpsProxiesSetQuicOverrideRequest=(
                         client.messages.
                         TargetHttpsProxiesSetQuicOverrideRequest(
                             quicOverride=quic_override)))))

        ssl_policy = client.messages.SslPolicyReference(
            sslPolicy=self.SSL_POLICY_ARG.ResolveAsResource(
                args, holder.resources).SelfLink()) if args.IsSpecified(
                    'ssl_policy') else None
        clear_ssl_policy = args.IsSpecified('clear_ssl_policy')

        if ssl_policy or clear_ssl_policy:
            requests.append(
                (client.apitools_client.targetHttpsProxies, 'SetSslPolicy',
                 client.messages.ComputeTargetHttpsProxiesSetSslPolicyRequest(
                     project=target_https_proxy_ref.project,
                     targetHttpsProxy=target_https_proxy_ref.Name(),
                     sslPolicyReference=ssl_policy)))

        return client.MakeRequests(requests)