Skip to content

Commit ddb1c2e

Browse files
Merge pull request #1896 from edsonarios/issue1895
Added new command - slcli cdn delete
2 parents 3c1080b + 5ea3cba commit ddb1c2e

File tree

7 files changed

+74
-0
lines changed

7 files changed

+74
-0
lines changed

SoftLayer/CLI/cdn/delete.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""Delete a CDN domain mapping."""
2+
# :license: MIT, see LICENSE for more details.
3+
4+
import click
5+
6+
import SoftLayer
7+
from SoftLayer.CLI import environment
8+
9+
10+
@click.command(cls=SoftLayer.CLI.command.SLCommand, )
11+
@click.argument('unique_id')
12+
@environment.pass_env
13+
def cli(env, unique_id):
14+
"""Delete a CDN domain mapping."""
15+
16+
manager = SoftLayer.CDNManager(env.client)
17+
18+
cdn = manager.delete_cdn(unique_id)
19+
20+
if cdn:
21+
env.fout("Cdn with uniqueId: {} was deleted.".format(unique_id))

SoftLayer/CLI/routes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
('cdn:origin-list', 'SoftLayer.CLI.cdn.origin_list:cli'),
8282
('cdn:origin-remove', 'SoftLayer.CLI.cdn.origin_remove:cli'),
8383
('cdn:purge', 'SoftLayer.CLI.cdn.purge:cli'),
84+
('cdn:delete', 'SoftLayer.CLI.cdn.delete:cli'),
8485

8586
('config', 'SoftLayer.CLI.config'),
8687
('config:setup', 'SoftLayer.CLI.config.setup:cli'),

SoftLayer/fixtures/SoftLayer_Network_CdnMarketplace_Configuration_Mapping.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,27 @@
5050
"cacheKeyQueryRule": "include: test"
5151
}
5252
]
53+
54+
deleteDomainMapping = [
55+
{
56+
"akamaiCname": "wildcard.appdomain.mdc.edgekey.net",
57+
"certificateType": "NO_CERT",
58+
"cname": "cdnakayq9fye4t88239.cdn.appdomain.cloud",
59+
"createDate": "2023-03-29T07:33:42-06:00",
60+
"domain": "www.test.com",
61+
"header": "www.header.com",
62+
"httpPort": 80,
63+
"httpsPort": None,
64+
"modifyDate": "2023-03-29T07:33:46-06:00",
65+
"originHost": "67.228.227.82",
66+
"originType": "HOST_SERVER",
67+
"path": "/path/*",
68+
"performanceConfiguration": "General web delivery",
69+
"protocol": "HTTP",
70+
"respectHeaders": False,
71+
"serveStale": True,
72+
"status": "DELETING",
73+
"uniqueId": "303727924488685",
74+
"vendorName": "akamai"
75+
}
76+
]

SoftLayer/managers/cdn.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,3 +269,12 @@ def get_cache_key_query_rule(cache_type, cache):
269269
cache_result = '%s: %s' % (cache_type, cache['description'])
270270

271271
return cache_result
272+
273+
def delete_cdn(self, unique_id):
274+
"""Delete CDN domain mapping for a particular customer.
275+
276+
:param str unique_id: The unique ID associated with the CDN.
277+
:returns: The cdn that is being deleted.
278+
"""
279+
280+
return self.cdn_configuration.deleteDomainMapping(unique_id)

docs/cli/cdn.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ Interacting with CDN
3131
.. click:: SoftLayer.CLI.cdn.edit:cli
3232
:prog: cdn edit
3333
:show-nested:
34+
35+
.. click:: SoftLayer.CLI.cdn.delete:cli
36+
:prog: cdn delete
37+
:show-nested:

tests/CLI/modules/cdn_tests.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,8 @@ def test_edit_cache_by_uniqueId(self):
123123
self.assert_no_fail(result)
124124
header_result = json.loads(result.output)
125125
self.assertEqual('include: test', header_result['Cache key optimization'])
126+
127+
def test_delete_cdn(self):
128+
result = self.run_command(['cdn', 'delete', '123456'])
129+
self.assert_no_fail(result)
130+
self.assertIn("Cdn with uniqueId: 123456 was deleted.", result.output)

tests/managers/cdn_tests.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,13 @@ def test_cdn_instance_by_hostname(self):
150150
self.assert_called_with(
151151
'SoftLayer_Network_CdnMarketplace_Configuration_Mapping',
152152
'listDomainMappings',)
153+
154+
def test_delete_cdn(self):
155+
uniqueId = "123465"
156+
self.cdn_client.delete_cdn(uniqueId)
157+
158+
args = (uniqueId,)
159+
160+
self.assert_called_with('SoftLayer_Network_CdnMarketplace_Configuration_Mapping',
161+
'deleteDomainMapping',
162+
args=args)

0 commit comments

Comments
 (0)