Baidu AI Cloud
中国站

百度智能云

CDN

Use CDN Service through CLI

BCE CLI accesses the CDN service and caches purging and preloading through cdn subcommands.

CLI uses multi-layer command structure, and all commands start with bce,[options] represents the options supported by BCE CLI; <service> indicates the services supported by CLI, such as BOS, CDN etc., and each service has multiple specific sub-commands.

$ bce [options] [<service> <command> [parameters [options]]] 

Parameter interpretation

Parameter item Value Description
options The value of BCE common Option is taken as -c, -v, -h, -d and --conf-path. -
service Value is cdn for use of the CDN service -
command Value taken as: lsprefetchpurge Please see the command function description for the role of each command.
parameters Please see the command parameters description for the role of each command. -
+options Option of cdn commands, it can be -a or -h. The option configurable for all command of cdn is not the same. See each command line explanation for detailed method for use.

Common Option of CLI

  • View Help You can add -h or --help to any command to view the help information for the command.

      	    $ bce -h 
              	    $ bce cdn -h 
              	    $ bce cdn ls --help 
  • View and set the configuration information of AK, SK, etc. -c/--configure

        $ bce -c [<conf-path>] 
  • View the version information: -v/--version

        $ bce -v 
  • View the debug information: -d/--debug

        $ bce -d cdn ls 

The command -d/--debug cannot be used alone, and must be used in conjunction with service.

  • Use specified configuration files: --conf-path

        $ bce --conf-path ./conf-sample/ cdn ls 

When the command --conf-path is not used, the configuration under the home directory of user ~/.bce is used by default.

Domain Management

List Domain Names

Note: List all the domain names.

Command format: $ bce cdn ls [-a, --all]

Example for operation: $ bce cdn ls

Example for return

my.domain.com
my1.domain.com
my10.domain.com
...

Cache Management

Purge Cache

Note: It is used to clear cached files. You can submit 20,000 URL purge requests or 200 directory purge requests at most within 24 hours.

Command format: bce cdn purge [--url] [--directory] <url> <path>

Note

  • --url: Submit file purge request.
  • --directory: Submit directory purge requests, and the path shall end with /.

Example for operation

  • Submit file purge request

      	 	 $ bce cdn purge --url http://my.domain.com/1.jpg 
  • Submit directory purge requests

      	 	 $ bce cdn purge --directory http://my.domain.com/to/path/ 

Example for return: purge ok, id: e0e9c9fc-a8c6-4c60-b9c7-6118a8d44698

Query Purge Status

Note: Query the status of purge requests.

Command format: $ bce cdn purge --query <purge-id>

Note

purge-id is the Id returned after the cache purge task is submitted.

Example for operation: $ bce cdn purge --query e0e9c9fc-a8c6-4c60-b9c7-6118a8d44698

Example for return

task 1 
    url: http://my.domain.com/to/path/ , type: directory 
    status:      completed 
    createdAt:   2017-08-10T03:02:28Z 
    startedAt:   None 
    finishedAt:  2017-08-10T03:03:11Z 
    progress:    100 
Parameter Description
url URL and type of purge tasks
status in-progress / completed / failed
createdAt Time to create the purge task
startedAt Time to start the purge task
finishedAt Time to end the purge task. The end may be Completed/Failed. If task is not completed, it does not return this item.
progress Process percentage

Prefetch Management

Cache Preloading

Note: Used to notify CDN to cache specified URL in advance, support batch submission; a maximum of 100 urls can be submitted at one time, and the user can submit 20,000 URLs at most in 24 hours.

Command format: bce cdn prefetch [--url] [--bos --domain] [--file] <url> <bos:/<bucket-name>/[prefix], domain> <file> [--batch] <batch>

Note

  • --url: Submit preload request for a single url
  • --bos: Submit the prefetch request in the bos bucket
  • --file: Submit the preloading request in the file. Each url in the file occupies one line.
  • --batch: When more urls are submitted in one time, the number of urls a batch uploaded at maximum is default as 10, with maximum value 100.

Example for operation

  • Submit preload request for a single url

      	 	 bce cdn prefetch --url http://my.domain.com/1.jpg 
  • Submit the prefetch request in the bos bucket

      	 	 bce cdn prefetch --bos bos:/fcc-test/ --domain my.domain.com 
  • Submit preloading requests in the file

      	 	 bce cdn prefetch --file list.txt 
  • Specify the maximum number of submissions each batch

        bce cdn prefetch --file list.txt --batch 10 

Example for return: prefetch ['http://my.domain.com/1.jpg', 'http://my.domain.com/2.jpg'] ok, id: eJyzMLc0NDUx1bEA02YAGQYDHA==

Query Preloading Status

Note: Query the preload request status.

Command format: bce cdn prefetch --query <prefetch-id>

Note

prefetch-id is the Id returned after the cache purge task is submitted.

Example for operation: bce cdn prefetch --query eJyzMLc0NDUx1bEA02YAGQYDHA==

Example for return

task 1 
    url: http://my.domain.com/2.jpg 
    status:      failed 
    createdAt:   2017-08-10T03:26:31Z 
    startedAt:   2017-08-10T03:26:31Z 
    finishedAt:  None 
    progress:    100 
task 2 
    url: http://my.domain.com/1.jpg 
    status:      failed 
    createdAt:   2017-08-10T03:26:31Z 
    startedAt:   2017-08-10T03:26:31Z 
    finishedAt:  None 
    progress:    100 
Parameter Description
url URL and type of the prefetch task
status waiting / in-progress / completed / failed
createdAt Time to create the prefetch task
startedAt Time to start executing the prefetch task
finishedAt Time to end the prefetch task. The end may be Completed/Failed. If task is not completed, it does not return this item.
progress Process percentage
Previous
Configure BCE-CLI
Next
Version Change Record