akamai_ccu 1.3.7 → 1.3.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 34081b860a9117fcb8b29d71142e7fc3b9a35f21
4
- data.tar.gz: c050cdf93d6438e15e7117e6408f70b7b6f7ae76
3
+ metadata.gz: b391acf5cc630f905fe9ec0b2b9b8a41bfa050ca
4
+ data.tar.gz: a68c5fb3a6643330809dc6aaf427633779dd7567
5
5
  SHA512:
6
- metadata.gz: 7529688f00dda88a6f27d515b8e87efb59a5a59448fb8a0b5f1e942c6bbf4cb9b5d32444e627c8e6b89e957f390cdf27ae73f7629f1d071d1774ab646603df40
7
- data.tar.gz: 384ab0c12360473d0b4751a13d8888c4eebd66c83934e595ea4a896dec633a89d232b107d06ba889f64f1a22c328e5c72382d134f73139f5e3a7ea126aca0fe5
6
+ metadata.gz: af084a3c29b82a20a92bf651b89e84edeef63e55b4478b766c03d484abcfcbc8e04ea3efe91f832719b755d3a4198515b76b1394d2d3336ca34fe1ef9c14e5f4
7
+ data.tar.gz: 271ce8ede89bb27f105a46aceb0808959b0e9b7ffcfd7e62d9a39f946afa8ff28a5d3b1882d431e3575080d659e30a48568220830188ace72e5df81a11ab724d
data/README.md CHANGED
@@ -10,6 +10,7 @@
10
10
  * [Usage](#usage)
11
11
  * [As library](#as-library)
12
12
  * [Secret](#secret)
13
+ * [Edge network](#edge-network)
13
14
  * [Invalidating](#invalidating)
14
15
  * [Deleting](#deleting)
15
16
  * [CLI](#cli)
@@ -20,10 +21,13 @@
20
21
  * [Redirecting output](#redirecting-output)
21
22
  * [Overwriting options](#overwriting-options)
22
23
  * [Possible issues](#possible-issues)
24
+ * [Invalid timestamp](#invalid-timestamp)
25
+ * [No wildcard](#no-wildcard)
26
+ * [Mixed bulk](#mixed-bulk)
23
27
 
24
28
  ## Scope
25
29
  This gem is a minimal wrapper of the [Akamai Content Control Utility](https://developer.akamai.com/api/purge/ccu/overview.html) APIs used to purge Edge content by request.
26
- The library is compliant with [CCU API V3](https://developer.akamai.com/api/purge/ccu/resources.html), based on the *Fast Purge* utility.
30
+ The library is compliant with [CCU API V3](https://developer.akamai.com/api/purge/ccu/resources.html), based on the *Fast Purge Utility*.
27
31
 
28
32
  ## Motivation
29
33
  The gem has two main responsibilities:
@@ -55,13 +59,13 @@ gem install akamai_ccu
55
59
  ```
56
60
 
57
61
  ### Configuration
58
- This gem requires you have a valid Akamai Luna Control Center account, enabled to use the CCU APIs.
59
- Akamai relies on a credentials file with three secret keys and a dedicated host for API authorization.
60
- 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.
61
- Suffice to say you have two main options:
62
+ This gem requires you have a valid Akamai Luna Control Center account, enabled to add APIs clients.
63
+ Upon APIs client creation, you'll get the `client token` to be used to generate new APIs credentials data: these consist of a secret key, two token (client and access) and a dedicated host for API authorization.
64
+ Check Akamai's [official documentation](https://developer.akamai.com/introduction/Conf_Client.html) for more details.
65
+ Suffice to say you have two main options to import credentials data:
62
66
 
63
67
  #### edgerc
64
- You can generate (by facility script or by hand) a specific file named `.edgerc`:
68
+ You can generate (using a script or by hand) an INI file named `.edgerc`:
65
69
  ```
66
70
  [default]
67
71
  client_secret = xxx=
@@ -72,7 +76,7 @@ max-body = 131072
72
76
  ```
73
77
 
74
78
  #### txt
75
- You can download a plain text file directly from Luna Control Center `Manage APIs` page:
79
+ You can download a plain text file upon credentials data creation:
76
80
  ```
77
81
  client_secret = xxx=
78
82
 
@@ -99,19 +103,23 @@ secret = AkamaiCCU::Secret.by_edgerc(".edgerc")
99
103
  # by txt file
100
104
  secret = AkamaiCCU::Secret.by_txt("tokens.txt")
101
105
 
102
- # by specifying arguments
106
+ # by using initializer
103
107
  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)
104
108
  ```
105
109
 
106
- The next step is setting the `Wrapper` class with the secret object (Net client and secret will be shared by successive calls):
110
+ The next step is setting the `Wrapper` class with the secret object, the secret and Net::HTTP client instances are shared between calls:
107
111
  ```ruby
108
112
  AkamaiCCU::Wrapper.setup(secret)
109
113
  ```
110
114
 
115
+ #### Edge network
116
+ Purging actions runs on the `staging` network by default.
117
+ Switch to production by just appending a shebang `!` on the method name.
118
+
111
119
  #### Invalidating
112
- The CCU V3 APIs allow for invalidating contents by URL or content provider (CP) code:
120
+ The CCU V3 APIs allow for invalidating contents by URLs or content provider (CP) codes: currently only the former relies on the Fast Purge Utility.
113
121
  ```ruby
114
- # invalidating resources on staging by url
122
+ # invalidating resources on staging by URLs
115
123
  AkamaiCCU::Wrapper.invalidate_by_url(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/index.html])
116
124
 
117
125
  # invalidating resources on production (mind the "!") by CP code
@@ -119,12 +127,12 @@ AkamaiCCU::Wrapper.invalidate_by_cpcode!([12345, 98765])
119
127
  ```
120
128
 
121
129
  #### Deleting
122
- You can also delete contents by URL or CP code (just be aware of what you're doing):
130
+ You can delete contents by URLs or CP codes as well, just be aware of what you're doing:
123
131
  ```ruby
124
- # deleting resources on staging by CP code
132
+ # deleting resources on staging by CP codes
125
133
  AkamaiCCU::Wrapper.delete_by_cpcode([12345, 98765])
126
134
 
127
- # deleting resources on production (mind the "!") by url
135
+ # deleting resources on production (mind the "!") by URLs
128
136
  AkamaiCCU::Wrapper.delete_by_url!(%w[https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js])
129
137
  ```
130
138
 
@@ -155,7 +163,7 @@ Usage: invalidate --edgerc=./.edgerc --production --cp="12345, 98765"
155
163
  ```
156
164
 
157
165
  #### ccu_invalidate
158
- You can request for contents invalidation by calling:
166
+ Do request for contents invalidation by:
159
167
  ```shell
160
168
  ccu_invalidate --edgerc=~/.edgerc \
161
169
  --url=https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.css,https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js \
@@ -163,7 +171,7 @@ ccu_invalidate --edgerc=~/.edgerc \
163
171
  ```
164
172
 
165
173
  #### ccu_delete
166
- You can request for contents deletion by calling:
174
+ Do request for contents deletion by:
167
175
  ```shell
168
176
  ccu_delete --txt=~/tokens.txt \
169
177
  --cp=12345,98765 \
@@ -174,7 +182,7 @@ ccu_delete --txt=~/tokens.txt \
174
182
  In case you have multiple contents to work with, it could be impractical to write several entries on the CLI.
175
183
  Just specify them on a separate file and use the bulk option:
176
184
 
177
- `urls.txt` file with each url/CP code specified on one line:
185
+ `urls.txt` file with URL entries specified on a new line:
178
186
  ```txt
179
187
  https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.css
180
188
  https://akaa-baseurl-xxx-xxx.luna.akamaiapis.net/main.js
@@ -186,9 +194,6 @@ Specify the bulk option by using the file path:
186
194
  ccu_invalidate --edgerc=~/.edgerc --bulk=urls.txt
187
195
  ```
188
196
 
189
- ##### Do not mix content types
190
- You cannot specify both CP codes and URLs on the same bulk file, mind being consistent!
191
-
192
197
  #### Redirecting output
193
198
  In case you're calling the CLI from another program (like your Jenkins script), just redirect the output to your log file:
194
199
  ```shell
@@ -196,22 +201,22 @@ ccu_invalidate --edgerc=~/.edgerc --cp=12345,98765 > mylog.log
196
201
  ```
197
202
 
198
203
  #### Overwriting options
199
- The CLI does allow only one option to specify the secret file and the content objects.
200
- If multiple options for the same scope are provided, the program runs by giving precedence to:
204
+ The CLI allows different options for the same scope on secret and contents specification. If multiple options for the same scope are provided, the program runs by assigning specific precedence rules:
201
205
 
202
- ##### Secret file
206
+ ##### Secret
203
207
  The `edgerc` option has always precedence over the `txt` one:
208
+
209
+ This command will load secret from ~/.edgerc:
204
210
  ```shell
205
- # will load secret from ~/.edgerc
206
211
  ccu_invalidate --txt=~/tokens.txt \
207
212
  --edgerc=~/.edgerc \
208
213
  --cp=12345,98765
209
214
  ```
210
215
 
211
- ##### Content objects
212
- The `bulk` option has always precedence over the `cp` one, that has precedence over the `url`:
216
+ ##### Contents
217
+ The `bulk` option has always precedence over the `cp` one, that has precedence over `url`:
213
218
 
214
- This command will invalidate by urls:
219
+ This command will invalidate by URLs:
215
220
  ```shell
216
221
  ccu_invalidate --txt=~/tokens.txt \
217
222
  --cp=12345,98765
@@ -226,7 +231,9 @@ ccu_delete --txt=~/tokens.txt \
226
231
  ```
227
232
 
228
233
  ### Possible Issues
229
- It happens you can get a `bad request` response by Akamai like this:
234
+
235
+ #### Invalid timestamp
236
+ You could get a `bad request` response like this:
230
237
  ```shell
231
238
  status=400; title=Bad request; detail=Invalid timestamp; request_id=2ce206fd; method=POST; requested_at=2017-06-21T12:33:10Z
232
239
  ```
@@ -235,3 +242,10 @@ This happens since Akamai APIs only tolerate a clock skew of at most 30 seconds
235
242
  In order to fix this annoying issue please do synchronize you server clock by:
236
243
  * `NTP` if you are on a UX server
237
244
  * `manually` versus an atomic clock site (check Internet) by using your workstation GUI
245
+
246
+ #### No wildcard
247
+ Do keep in mind CCU V3 APIs doesn't support contents specification by wildcard.
248
+
249
+ #### Mixed bulk
250
+ When specifying contents by bulk on the CLI, you cannot include both CP codes and URLs resources on the same file.
251
+ The library tries to detect which mode to use basing on entries kind: mixing them will generate unexpected behaviour.
@@ -4,6 +4,8 @@ require "akamai_ccu/wrapper"
4
4
 
5
5
  module AkamaiCCU
6
6
  class CLI
7
+ SCHEME = "http"
8
+
7
9
  attr_reader :network, :action
8
10
 
9
11
  def initialize(args:, action:, io: STDOUT, wrapper_klass: Wrapper, secret_klass: Secret, endpoint_klass: Endpoint)
@@ -43,10 +45,9 @@ module AkamaiCCU
43
45
 
44
46
  private def bulk_objects(file)
45
47
  return unless File.exist?(file)
46
- File.readlines(file).map(&:strip).reject(&:empty?).map do |entry|
47
- entry = entry.to_i unless entry.start_with?("http")
48
- entry
49
- end
48
+ data = File.readlines(file).map(&:strip).reject(&:empty?)
49
+ return data if data.all? { |entry| entry.downcase.start_with?(SCHEME) }
50
+ data.map(&:to_i).reject(&:zero?)
50
51
  end
51
52
 
52
53
  private def parser
@@ -1,3 +1,3 @@
1
1
  module AkamaiCCU
2
- VERSION = "1.3.7"
2
+ VERSION = "1.3.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: akamai_ccu
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.7
4
+ version: 1.3.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler