README.md in akamai_ccu-1.3.4 vs README.md in akamai_ccu-1.3.5

- old
+ new

@@ -2,19 +2,18 @@ * [Scope](#scope) * [Motivation](#motivation) * [akamai-edgerid](#akamai-edgerid) * [Installation](#installation) -* [Usage](#usage) * [Configuration](#configuration) * [edgerc](#edgerc) * [txt](#txt) - * [Inside your script](#inside-your-script) +* [Usage](#usage) + * [As library](#as-library) * [Secret](#secret) * [Invalidating](#invalidating) * [Deleting](#deleting) - * [Reuse client](#reuse-client) * [CLI](#cli) * [Help](#help) * [ccu_invalidate](#ccu_invalidate) * [ccu_delete](#ccu_delete) * [Bulk operation](#bulk-operation) @@ -53,12 +52,10 @@ Or install it yourself as: ```shell gem install akamai_ccu ``` -## Usage - ### Configuration This gem requires you have a valid Akamai Luna Control Center account, enabled to use the CCU APIs. Akamai relies on a credentials file with three secret keys and a dedicated host for API authorization. Detailing how to get this file is out of the scope of this readme, check Akamai's [official documentation](https://developer.akamai.com/introduction/Conf_Client.html) for that. Suffice to say you have two main options: @@ -84,13 +81,15 @@ access_token = akab-access-token-xxx-xxx client_token = akab-client-token-xxx-xxx ``` -### Inside your script -You can obviously use the gem directly inside your Ruby's script: +## Usage +### As library +You can require the gem to use it as a library inside your scripts: + #### Secret Once you've got APIs credentials, you can instantiate the secret object aimed to generate the authorization header: ```ruby require "akamai_ccu" @@ -102,42 +101,35 @@ # by specifying arguments secret = AkamaiCCU::Secret.new(client_secret: "xxx=", host: "akaa-baseurl-xxx-xxx.luna.akamaiapis.net/", access_token: "akab-access-token-xxx-xxx", client_token: "akab-client-token-xxx-xxx", max_body: 131072) ``` +The next step is setting the `Wrapper` class with the secret object (Net client and secret will be shared by successive calls): +```ruby +AkamaiCCU::Wrapper.setup(secret) +``` + #### Invalidating -The CCU V3 APIs allow for invalidating the contents by URL or content provider (CP) code: +The CCU V3 APIs allow for invalidating contents by URL or content provider (CP) code: ```ruby # invalidating resources on staging by url AkamaiCCU::Wrapper.invalidate_by_url(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/index.html], secret) # invalidating resources on production (mind the "!") by CP code AkamaiCCU::Wrapper.invalidate_by_cpcode!([12345, 98765], secret) ``` #### Deleting -You can also delete the contents by URL or CP code, just be aware of the consequences: +You can also delete contents by URL or CP code (just be aware of what you're doing): ```ruby # deleting resources on staging by CP code AkamaiCCU::Wrapper.delete_by_cpcode([12345, 98765], secret) # deleting resources on production (mind the "!") by url -AkamaiCCU::Wrapper.delete_by_url!(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.js], secret) +AkamaiCCU::Wrapper.delete_by_url!(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js], secret) ``` -#### Reuse client -By default `Wrapper` class methods create a brand new Net::HTTP client on each call. -If this is an issue for you, you can use the `Wrapper#call` instance method and update the `endpoint` collaborator to switch API: -```ruby -wrapper = AkamaiCCU::Wrapper.new(secret: secret, endpoint: AkamaiCCU::Endpoint.by_name("invalidate_by_url")) -wrapper.call(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.css]) - -# switch to deleting on production -wrapper.endpoint = AkamaiCCU::Endpoint.by_name("delete_by_cpcode!") -wrapper.call([12345, 98765]) -``` - #### Response The Net::HTTP response is wrapped by an utility struct: ```ruby res = AkamaiCCU::Wrapper.invalidate_by_cpcode([12345, 98765], secret) puts res @@ -164,11 +156,11 @@ #### ccu_invalidate You can request for contents invalidation by calling: ```shell ccu_invalidate --edgerc=~/.edgerc \ - --url=https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.css,https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.js \ + --url=https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.css,https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js \ --production ``` #### ccu_delete You can request for contents deletion by calling: @@ -182,13 +174,13 @@ In case you have multiple contents to work with, it could be impractical to write several entries on the CLI. Just specify them on a separate file and use the bulk option: `urls.txt` file with each url/CP code specified on one line: ```txt -https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.css -https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.js -https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/static/*.html +https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.css +https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js +https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/static/index.html ``` Specify the bulk option by using the file path: ```shell ccu_invalidate --edgerc=~/.edgerc --bulk=urls.txt @@ -228,10 +220,10 @@ This command will delete by CP codes: ```shell ccu_delete --txt=~/tokens.txt \ --cp=12345,98765 - --url=https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.css,https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/*.js + --url=https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.css,https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js ``` ### Possible Issues It happens you can get a `bad request` response by Akamai like this: ```shell