Purge a File from Rackspace`s Cloud File CDN Caches

Within this article we will show you how to purge a file from Rackspace`s Cloud File CDN Caches.

Get Auth Token

First all you will need to obtain the Auth Token. This token will be used to perform further actions via the API.
For this you will need to obtain your API Key which can be found from the Rackspace Cloud Portal.

curl -s -X 'POST' \
-d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"<USERNAME>", "apiKey":"<API KEY>"}}}' \
-H "Content-Type: application/json" | python -m json.tool

Below shows an example. I have highlighted the Auth Token and the Cloudfile public URL. Both of which you will need within the next step(s).

[root@server ~]# curl -s  -X 'POST'   \
>        -d '{"auth":{"RAX-KSKEY:apiKeyCredentials":{"username":"<USERNAME>", "apiKey":"<API KEY>"}}}'  \
>        -H "Content-Type: application/json" | python -m json.tool
{
    "access": {
        "serviceCatalog": [
            {
                "endpoints": [
                    {
                        "publicURL": "https://cdn3.clouddrive.com/v1/MossoCloudFS_e69726fd-c72e-4873-b8ae-45dfd17755fa",
                        "region": "LON",
                        "tenantId": "MossoCloudFS_e69726fd-c72e-4873-b8ae-45dfd17755fa"
                    }
                ],
                "name": "cloudFilesCDN",
                "type": "rax:object-cdn"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.servers.api.rackspacecloud.com/v1.0/10008012",
                        "tenantId": "10008012",
                        "versionId": "1.0",
                        "versionInfo": "https://lon.servers.api.rackspacecloud.com/v1.0",
                        "versionList": "https://lon.servers.api.rackspacecloud.com/"
                    }
                ],
                "name": "cloudServers",
                "type": "compute"
            },
            {
                "endpoints": [
                    {
                        "internalURL": "https://snet-storage101.lon3.clouddrive.com/v1/MossoCloudFS_e69726fd-c72e-4873-b8ae-45dfd17755fa",
                        "publicURL": "https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_e69726fd-c72e-4873-b8ae-45dfd17755fa",
                        "region": "LON",
                        "tenantId": "MossoCloudFS_e69726fd-c72e-4873-b8ae-45dfd17755fa"
                    }
                ],
                "name": "cloudFiles",
                "type": "object-store"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.loadbalancers.api.rackspacecloud.com/v1.0/10008012",
                        "region": "LON",
                        "tenantId": "10008012"
                    }
                ],
                "name": "cloudLoadBalancers",
                "type": "rax:load-balancer"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.blockstorage.api.rackspacecloud.com/v1/10008012",
                        "region": "LON",
                        "tenantId": "10008012"
                    }
                ],
                "name": "cloudBlockStorage",
                "type": "volume"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://monitoring.api.rackspacecloud.com/v1.0/10008012",
                        "tenantId": "10008012"
                    }
                ],
                "name": "cloudMonitoring",
                "type": "rax:monitor"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.dns.api.rackspacecloud.com/v1.0/10008012",
                        "tenantId": "10008012"
                    }
                ],
                "name": "cloudDNS",
                "type": "rax:dns"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.databases.api.rackspacecloud.com/v1.0/10008012",
                        "region": "LON",
                        "tenantId": "10008012"
                    }
                ],
                "name": "cloudDatabases",
                "type": "rax:database"
            },
            {
                "endpoints": [
                    {
                        "publicURL": "https://lon.servers.api.rackspacecloud.com/v2/10008012",
                        "region": "LON",
                        "tenantId": "10008012",
                        "versionId": "2",
                        "versionInfo": "https://lon.servers.api.rackspacecloud.com/v2",
                        "versionList": "https://lon.servers.api.rackspacecloud.com/"
                    }
                ],
                "name": "cloudServersOpenStack",
                "type": "compute"
            }
        ],
        "token": {
            "expires": "2012-11-13T06:08:48.000Z",
            "id": "7b93bf4f-24f9-40f8-86b5-8bd5590e06d1",
            "tenant": {
                "id": "10008012",
                "name": "10008012"
            }
        },
        "user": {
            "RAX-AUTH:defaultRegion": "",
            "id": "5246",
            "name": "###",
            "roles": [
                {
                    "description": "User Admin Role.",
                    "id": "3",
                    "name": "identity:user-admin"
                }
            ]
        }
    }
}

List Containers

To list the Cloud File containers we can use the following command.

curl -H "X-Auth-Token: <AUTH TOKEN>" https://storage101.lon3.clouddrive.com/v1/MossoCloudFS_e69
726fd-c72e-4873-b8ae-45dfd1a755fa

Purge File

To purge the file the following command is used. Once this has been actioned an email will be sent to the email address supplied below.

curl -X DELETE -H "X-Purge-Email: <YOUR EMAIL ADDRESS>" -H "X-Auth-Token: <AUTH TOKEN>" 
https://cdn3.clouddrive.com/v1/MossoCloudFS_e69726fd-c72e-4873-b8ae-
45dfda7755fa/images/legacy/oldimage.png

Download File

As a side note to download the file the following command would be used.

curl -XGET -H "X-Auth-Token: <AUTH TOKEN>" 
https://cdn3.clouddrive.com/v1/MossoCloudFS_e69726fd-c72e-4873-b8ae-
45dfda7755fa/images/legacy/oldimage.png > oldimage.png
Rick Donato

Want to become an OpenStack expert?

Here is our hand-picked selection of the best courses you can find online:
OpenStack Essentials course
Certified OpenStack Administrator course
Docker Mastery course
and our recommended certification practice exams:
AlphaPrep Practice Tests - Free Trial