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

Commit b1407ac

Browse files
committed
Update Load Balancing endpoints to reflect latest API changes
1 parent 9c59aa3 commit b1407ac

2 files changed

Lines changed: 14 additions & 51 deletions

File tree

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"""
@@ -313,8 +291,8 @@ def cli4(args):
313291
identifier1 = convert_invites_to_identifier(cf, element)
314292
elif (cmd[0] == 'user') and (cmd[1] == 'virtual_dns'):
315293
identifier1 = convert_virtual_dns_to_identifier(cf, element)
316-
elif (cmd[0] == 'user') and (cmd[1] == 'load_balancers') and (cmd[2] == 'maps'):
317-
identifier1 = convert_load_balancers_map_to_identifier(cf, element)
294+
elif (cmd[0] == 'user') and (cmd[1] == 'load_balancers') and (cmd[2] == 'pools'):
295+
identifier1 = convert_load_balancers_pool_to_identifier(cf, element)
318296
else:
319297
exit("/%s/%s :NOT CODED YET 1" % ('/'.join(cmd), element))
320298
cmd.append(':' + identifier1)
@@ -324,11 +302,6 @@ def cli4(args):
324302
identifier2 = element
325303
elif (cmd[0] and cmd[0] == 'zones') and (cmd[2] and cmd[2] == 'dns_records'):
326304
identifier2 = convert_dns_record_to_identifier(cf, identifier1, element)
327-
elif ((cmd[0] == 'user') and
328-
(cmd[1] == 'load_balancers') and
329-
(cmd[2] == 'maps') and
330-
(cmd[4] == 'region')):
331-
identifier2 = convert_load_balancers_map_regions(cf, element)
332305
else:
333306
exit("/%s/%s :NOT CODED YET 2" % ('/'.join(cmd), element))
334307
# identifier2 may be an array - this needs to be dealt with later

0 commit comments

Comments
 (0)