Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Commit

Permalink
BackendService LoadBalancingScheme + IAP support
Browse files Browse the repository at this point in the history
  • Loading branch information
modular-magician authored and rambleraptor committed Aug 28, 2018
1 parent c5cbf37 commit 2125463
Show file tree
Hide file tree
Showing 2 changed files with 133 additions and 0 deletions.
100 changes: 100 additions & 0 deletions lib/ansible/modules/cloud/google/gcp_compute_backend_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,37 @@
and a health check is required.
- For internal load balancing, a URL to a HealthCheck resource must be specified instead.
required: false
iap:
description:
- Settings for enabling Cloud Identity Aware Proxy.
required: false
version_added: 2.7
suboptions:
enabled:
description:
- Enables IAP.
required: false
type: bool
oauth2_client_id:
description:
- OAuth2 Client ID for IAP.
required: false
oauth2_client_secret:
description:
- OAuth2 Client Secret for IAP.
required: false
oauth2_client_secret_sha256:
description:
- OAuth2 Client Secret SHA-256 for IAP.
required: false
load_balancing_scheme:
description:
- Indicates whether the backend service will be used with internal or external load
balancing. A backend service created for one type of load balancing cannot be used
with the other.
required: false
version_added: 2.7
choices: ['INTERNAL', 'EXTERNAL']
name:
description:
- Name of the resource. Provided by the client when the resource is created. The name
Expand Down Expand Up @@ -456,6 +487,39 @@
- The unique identifier for the resource.
returned: success
type: int
iap:
description:
- Settings for enabling Cloud Identity Aware Proxy.
returned: success
type: complex
contains:
enabled:
description:
- Enables IAP.
returned: success
type: bool
oauth2_client_id:
description:
- OAuth2 Client ID for IAP.
returned: success
type: str
oauth2_client_secret:
description:
- OAuth2 Client Secret for IAP.
returned: success
type: str
oauth2_client_secret_sha256:
description:
- OAuth2 Client Secret SHA-256 for IAP.
returned: success
type: str
load_balancing_scheme:
description:
- Indicates whether the backend service will be used with internal or external load
balancing. A backend service created for one type of load balancing cannot be used
with the other.
returned: success
type: str
name:
description:
- Name of the resource. Provided by the client when the resource is created. The name
Expand Down Expand Up @@ -551,6 +615,13 @@ def main():
description=dict(type='str'),
enable_cdn=dict(type='bool'),
health_checks=dict(type='list', elements='str'),
iap=dict(type='dict', options=dict(
enabled=dict(type='bool'),
oauth2_client_id=dict(type='str'),
oauth2_client_secret=dict(type='str'),
oauth2_client_secret_sha256=dict(type='str')
)),
load_balancing_scheme=dict(type='str', choices=['INTERNAL', 'EXTERNAL']),
name=dict(type='str'),
port_name=dict(type='str'),
protocol=dict(type='str', choices=['HTTP', 'HTTPS', 'TCP', 'SSL']),
Expand Down Expand Up @@ -615,6 +686,8 @@ def resource_to_request(module):
u'description': module.params.get('description'),
u'enableCDN': module.params.get('enable_cdn'),
u'healthChecks': module.params.get('health_checks'),
u'iap': BackendServiceIap(module.params.get('iap', {}), module).to_request(),
u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
u'name': module.params.get('name'),
u'portName': module.params.get('port_name'),
u'protocol': module.params.get('protocol'),
Expand Down Expand Up @@ -695,6 +768,8 @@ def response_to_hash(module, response):
u'enableCDN': response.get(u'enableCDN'),
u'healthChecks': response.get(u'healthChecks'),
u'id': response.get(u'id'),
u'iap': BackendServiceIap(response.get(u'iap', {}), module).from_response(),
u'loadBalancingScheme': response.get(u'loadBalancingScheme'),
u'name': response.get(u'name'),
u'portName': response.get(u'portName'),
u'protocol': response.get(u'protocol'),
Expand Down Expand Up @@ -862,5 +937,30 @@ def from_response(self):
})


class BackendServiceIap(object):
def __init__(self, request, module):
self.module = module
if request:
self.request = request
else:
self.request = {}

def to_request(self):
return remove_nones_from_dict({
u'enabled': self.request.get('enabled'),
u'oauth2ClientId': self.request.get('oauth2_client_id'),
u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
u'oauth2ClientSecretSha256': self.request.get('oauth2_client_secret_sha256')
})

def from_response(self):
return remove_nones_from_dict({
u'enabled': self.request.get(u'enabled'),
u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
u'oauth2ClientSecretSha256': self.request.get(u'oauth2ClientSecretSha256')
})


if __name__ == '__main__':
main()
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,39 @@
- The unique identifier for the resource.
returned: success
type: int
iap:
description:
- Settings for enabling Cloud Identity Aware Proxy.
returned: success
type: complex
contains:
enabled:
description:
- Enables IAP.
returned: success
type: bool
oauth2_client_id:
description:
- OAuth2 Client ID for IAP.
returned: success
type: str
oauth2_client_secret:
description:
- OAuth2 Client Secret for IAP.
returned: success
type: str
oauth2_client_secret_sha256:
description:
- OAuth2 Client Secret SHA-256 for IAP.
returned: success
type: str
load_balancing_scheme:
description:
- Indicates whether the backend service will be used with internal or external load
balancing. A backend service created for one type of load balancing cannot be used
with the other.
returned: success
type: str
name:
description:
- Name of the resource. Provided by the client when the resource is created. The name
Expand Down

0 comments on commit 2125463

Please sign in to comment.