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

Commit bd1886d

Browse files
committed
Merge branch 'update/load-balancing' of https://github.com/rita3ko/python-cloudflare into rita3ko-update/load-balancing
2 parents ad841f5 + b1407ac commit bd1886d

File tree

2 files changed

+14
-51
lines changed

2 files changed

+14
-51
lines changed

CloudFlare/api_v4.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -313,19 +313,9 @@ def user_load_balancers(self):
313313
setattr(branch, "load_balancers",
314314
self._add_unused(base, "user/load_balancers"))
315315
branch = getattr(getattr(self, "user"), "load_balancers")
316-
setattr(branch, "global_policies",
317-
self._add_with_auth(base, "user/load_balancers/global_policies"))
318316
setattr(branch, "monitors",
319317
self._add_with_auth(base, "user/load_balancers/monitors"))
320-
setattr(branch, "notifiers",
321-
self._add_with_auth(base, "user/load_balancers/notifiers"))
322-
setattr(branch, "origins",
323-
self._add_with_auth(base, "user/load_balancers/origins"))
324318
setattr(branch, "pools",
325319
self._add_with_auth(base, "user/load_balancers/pools"))
326-
setattr(branch, "maps",
327-
self._add_with_auth(base, "user/load_balancers/maps"))
328-
branch = getattr(getattr(getattr(self, "user"), "load_balancers"), "maps")
329-
setattr(branch, "region",
330-
self._add_with_auth(base, "user/load_balancers/maps", "region"))
320+
branch = getattr(getattr(getattr(self, "user"), "load_balancers"), "pools")
331321

cli4/cli4.py

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -111,42 +111,20 @@ def convert_virtual_dns_to_identifier(cf, virtual_dns_name):
111111

112112
exit('cli4: %s - no virtual_dns found' % (virtual_dns_name))
113113

114-
def convert_load_balancers_map_to_identifier(cf, map_name):
115-
"""load balancer map names to numbers"""
114+
def convert_load_balancers_pool_to_identifier(cf, pool_name):
115+
"""load balancer pool names to numbers"""
116116
try:
117-
maps = cf.user.load_balancers.maps.get()
117+
pools = cf.user.load_balancers.pools.get()
118118
except CloudFlare.exceptions.CloudFlareAPIError as e:
119-
exit('cli4: %s - %d %s' % (map_name, e, e))
119+
exit('cli4: %s - %d %s' % (pool_name, e, e))
120120
except Exception as e:
121-
exit('cli4: %s - %s' % (map_name, e))
122-
123-
for m in maps:
124-
if map_name == m['description']:
125-
return m['id']
126-
127-
exit('cli4: %s - no maps found' % (map_name))
128-
129-
def convert_load_balancers_map_regions(cf, region_name):
130-
"""load balancer map regions"""
131-
# this will/must go away; however it allows :WNAM etc in path.
132-
regions = {
133-
'WNAM', # Western North America
134-
'ENAM', # Eastern North America
135-
'EU', # Europe
136-
'NSAM', # Northern South America
137-
'SSAM', # Southern South America
138-
'OC', # Oceania
139-
'ME', # Middle East
140-
'NAF', # Northern Africa
141-
'SAF', # Southern Africa
142-
'IN', # India
143-
'SEAS', # Southeast Asia
144-
'NEAS', # Northeast Asia
145-
'CHINA' # China
146-
}
147-
if region_name in regions:
148-
return region_name
149-
exit('cli4: %s - no region found' % (region_name))
121+
exit('cli4: %s - %s' % (pool_name, e))
122+
123+
for p in pools:
124+
if pool_name == p['description']:
125+
return p['id']
126+
127+
exit('cli4: %s - no pools found' % (pool_name))
150128

151129
def dump_commands(cf):
152130
"""dump a tree of all the known API commands"""
@@ -314,8 +292,8 @@ def cli4(args):
314292
identifier1 = convert_invites_to_identifier(cf, element)
315293
elif (cmd[0] == 'user') and (cmd[1] == 'virtual_dns'):
316294
identifier1 = convert_virtual_dns_to_identifier(cf, element)
317-
elif (cmd[0] == 'user') and (cmd[1] == 'load_balancers') and (cmd[2] == 'maps'):
318-
identifier1 = convert_load_balancers_map_to_identifier(cf, element)
295+
elif (cmd[0] == 'user') and (cmd[1] == 'load_balancers') and (cmd[2] == 'pools'):
296+
identifier1 = convert_load_balancers_pool_to_identifier(cf, element)
319297
else:
320298
exit("/%s/%s :NOT CODED YET 1" % ('/'.join(cmd), element))
321299
cmd.append(':' + identifier1)
@@ -325,11 +303,6 @@ def cli4(args):
325303
identifier2 = element
326304
elif (cmd[0] and cmd[0] == 'zones') and (cmd[2] and cmd[2] == 'dns_records'):
327305
identifier2 = convert_dns_record_to_identifier(cf, identifier1, element)
328-
elif ((cmd[0] == 'user') and
329-
(cmd[1] == 'load_balancers') and
330-
(cmd[2] == 'maps') and
331-
(cmd[4] == 'region')):
332-
identifier2 = convert_load_balancers_map_regions(cf, element)
333306
else:
334307
exit("/%s/%s :NOT CODED YET 2" % ('/'.join(cmd), element))
335308
# identifier2 may be an array - this needs to be dealt with later

0 commit comments

Comments
 (0)