Source code for c7n_gcp.resources.loadbalancer

# Copyright 2019 Capital One Services, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


from c7n_gcp.provider import resources
from c7n_gcp.query import QueryResourceManager, TypeInfo


[docs]@resources.register('loadbalancer-address') class LoadBalancingAddress(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'addresses' enum_spec = ('aggregatedList', 'items.*.addresses[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'region': resource_info['region'], 'address': resource_info['name']})
[docs]@resources.register('loadbalancer-url-map') class LoadBalancingUrlMap(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'urlMaps' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'urlMap': resource_info['name']})
[docs]@resources.register('loadbalancer-target-tcp-proxy') class LoadBalancingTargetTcpProxy(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetTcpProxies' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'targetTcpProxy': resource_info['name']})
[docs]@resources.register('loadbalancer-target-ssl-proxy') class LoadBalancingTargetSslProxy(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetSslProxies' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'targetSslProxy': resource_info['name']})
[docs]@resources.register('loadbalancer-ssl-policy') class LoadBalancingSslPolicy(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'sslPolicies' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'sslPolicy': resource_info['name']})
[docs]@resources.register('loadbalancer-ssl-certificate') class LoadBalancingSslCertificate(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'sslCertificates' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'sslCertificate': resource_info['name']})
[docs]@resources.register('loadbalancer-target-https-proxy') class LoadBalancingTargetHttpsProxy(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetHttpsProxies' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'targetHttpsProxy': resource_info['name']})
[docs]@resources.register('loadbalancer-backend-bucket') class LoadBalancingBackendBucket(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'backendBuckets' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'backendBucket': resource_info['name']})
[docs]@resources.register('loadbalancer-https-health-check') class LoadBalancingHttpsHealthCheck(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'httpsHealthChecks' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'httpsHealthCheck': resource_info['name']})
[docs]@resources.register('loadbalancer-http-health-check') class LoadBalancingHttpHealthCheck(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'httpHealthChecks' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'httpHealthCheck': resource_info['name']})
[docs]@resources.register('loadbalancer-health-check') class LoadBalancingHealthCheck(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'healthChecks' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'healthCheck': resource_info['name']})
[docs]@resources.register('loadbalancer-target-http-proxy') class LoadBalancingTargetHttpProxy(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetHttpProxies' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'targetHttpProxy': resource_info['name']})
[docs]@resources.register('loadbalancer-backend-service') class LoadBalancingBackendService(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'backendServices' enum_spec = ('aggregatedList', 'items.*.backendServices[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'backendService': resource_info['name']})
[docs]@resources.register('loadbalancer-target-instance') class LoadBalancingTargetInstance(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetInstances' enum_spec = ('aggregatedList', 'items.*.targetInstances[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'zone': resource_info['zone'].rsplit('/', 1)[-1], 'targetInstance': resource_info['name']})
[docs]@resources.register('loadbalancer-target-pool') class LoadBalancingTargetPool(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'targetPools' enum_spec = ('aggregatedList', 'items.*.targetPools[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'region': resource_info['region'].rsplit('/', 1)[-1], 'targetPool': resource_info['name']})
[docs]@resources.register('loadbalancer-forwarding-rule') class LoadBalancingForwardingRule(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'forwardingRules' enum_spec = ('aggregatedList', 'items.*.forwardingRules[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'region': resource_info['region'].rsplit('/', 1)[-1], 'forwardingRule': resource_info['name']})
[docs]@resources.register('loadbalancer-global-forwarding-rule') class LoadBalancingGlobalForwardingRule(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'globalForwardingRules' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'forwardingRule': resource_info['name']})
[docs]@resources.register('loadbalancer-global-address') class LoadBalancingGlobalAddress(QueryResourceManager):
[docs] class resource_type(TypeInfo): service = 'compute' version = 'v1' component = 'globalAddresses' enum_spec = ('list', 'items[]', None) scope = 'project' id = 'name'
[docs] @staticmethod def get(client, resource_info): return client.execute_command('get', { 'project': resource_info['project_id'], 'address': resource_info['name']})