From 3358773568ba1454bd0b423960ec2e290e7a270f Mon Sep 17 00:00:00 2001 From: Martin Levy Date: Wed, 27 Sep 2017 15:02:40 -0700 Subject: [PATCH] Cloudflare CA CLI examples added --- README.md | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ README.rst | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 129 insertions(+) diff --git a/README.md b/README.md index 16c1891..fe11c3b 100644 --- a/README.md +++ b/README.md @@ -549,6 +549,67 @@ $ cli4 /zones/:example.com/available_plans | jq -c '.[]|{"id":.id,"name":.name}' $ ``` +### Cloudflare CA CLI examples + +Here's some Cloudflare CA examples. Note the need of the zone_id= paramater with the basic **/certificates** call. + +```bash +$ cli4 /zones/:example.com | jq -c '.|{"id":.id,"name":.name}' +{"id":"12345678901234567890123456789012","name":"example.com"} +$ + +$ cli4 zone_id=12345678901234567890123456789012 /certificates | jq -c '.[]|{"id":.id,"expires_on":.expires_on,"hostnames":.hostnames,"certificate":.certificate}' +{"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-29 22:36:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} +{"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-28 23:23:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} +{"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-28 23:20:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} +$ +``` + +A certificate can be viewed via a simple GET request. +```bash +$ cli4 /certificates/:123456789012345678901234567890123456789012345678 +{ + "certificate": "-----BEGIN CERTIFICATE-----\n ... ", + "expires_on": "2032-01-29 22:36:00 +0000 UTC", + "hostnames": [ + "*.example.com", + "example.com" + ], + "id": "123456789012345678901234567890123456789012345678", + "request_type": "origin-rsa" +} +$ +``` + +Creating a certificate. This is done with a **POST** request. Note the use of **==** in order to pass a decimal number (vs. string) in JSON. The CSR is not shown for simplicity sake. +```bash +$ CSR=`cat example.com.csr` +$ cli4 --post hostnames='["example.com","*.example.com"]' requested_validity==365 request_type="origin-ecc" csr="$CSR" /certificates +{ + "certificate": "-----BEGIN CERTIFICATE-----\n ... ", + "csr": "-----BEGIN CERTIFICATE REQUEST-----\n ... ", + "expires_on": "2018-09-27 21:47:00 +0000 UTC", + "hostnames": [ + "*.example.com", + "example.com" + ], + "id": "123456789012345678901234567890123456789012345678", + "request_type": "origin-ecc", + "requested_validity": 365 +} +$ +``` + +Deleting a certificate can be done with a **DELETE** call. +```bash +$ cli4 --delete /certificates/:123456789012345678901234567890123456789012345678 +{ + "id": "123456789012345678901234567890123456789012345678", + "revoked_at": "0000-00-00T00:00:00Z" +} +$ +``` + ### Paging CLI examples The **--raw** command provides access to the paging returned values. diff --git a/README.rst b/README.rst index 3a0ae7a..5520739 100644 --- a/README.rst +++ b/README.rst @@ -610,6 +610,74 @@ A somewhat useful listing of available plans for a specific zone. {"id":"0feeeeeeeeeeeeeeeeeeeeeeeeeeeeee","name":"Free Website"} $ +Cloudflare CA CLI examples +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here's some Cloudflare CA examples. Note the need of the zone\_id= +paramater with the basic **/certificates** call. + +.. code:: bash + + $ cli4 /zones/:example.com | jq -c '.|{"id":.id,"name":.name}' + {"id":"12345678901234567890123456789012","name":"example.com"} + $ + + $ cli4 zone_id=12345678901234567890123456789012 /certificates | jq -c '.[]|{"id":.id,"expires_on":.expires_on,"hostnames":.hostnames,"certificate":.certificate}' + {"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-29 22:36:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} + {"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-28 23:23:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} + {"id":"123456789012345678901234567890123456789012345678","expires_on":"2032-01-28 23:20:00 +0000 UTC","hostnames":["*.example.com","example.com"],"certificate":"-----BEGIN CERTIFICATE-----\n ... "} + $ + +A certificate can be viewed via a simple GET request. + +.. code:: bash + + $ cli4 /certificates/:123456789012345678901234567890123456789012345678 + { + "certificate": "-----BEGIN CERTIFICATE-----\n ... ", + "expires_on": "2032-01-29 22:36:00 +0000 UTC", + "hostnames": [ + "*.example.com", + "example.com" + ], + "id": "123456789012345678901234567890123456789012345678", + "request_type": "origin-rsa" + } + $ + +Creating a certificate. This is done with a **POST** request. Note the +use of **==** in order to pass a decimal number (vs. string) in JSON. +The CSR is not shown for simplicity sake. + +.. code:: bash + + $ CSR=`cat example.com.csr` + $ cli4 --post hostnames='["example.com","*.example.com"]' requested_validity==365 request_type="origin-ecc" csr="$CSR" /certificates + { + "certificate": "-----BEGIN CERTIFICATE-----\n ... ", + "csr": "-----BEGIN CERTIFICATE REQUEST-----\n ... ", + "expires_on": "2018-09-27 21:47:00 +0000 UTC", + "hostnames": [ + "*.example.com", + "example.com" + ], + "id": "123456789012345678901234567890123456789012345678", + "request_type": "origin-ecc", + "requested_validity": 365 + } + $ + +Deleting a certificate can be done with a **DELETE** call. + +.. code:: bash + + $ cli4 --delete /certificates/:123456789012345678901234567890123456789012345678 + { + "id": "123456789012345678901234567890123456789012345678", + "revoked_at": "0000-00-00T00:00:00Z" + } + $ + Paging CLI examples ~~~~~~~~~~~~~~~~~~~