Skip to content

Commit

Permalink
feat: added API Token support
Browse files Browse the repository at this point in the history
  • Loading branch information
michtio committed Sep 24, 2024
1 parent aee7050 commit 11ac806
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/F5Purger.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ class F5Purger extends BaseCachePurger
*/
public string $name = '';

/**
* @var string
*/
public string $apiToken = '';

/**
* Whether to remove the content from the distribution, forcing the next request to retrieve the content from the origin server. With this off, the content will be replaced on the next request if the content is stale.
* https://docs.cloud.f5.com/docs-v2/content-delivery-network/how-to/configure-cdn-distribution
Expand Down Expand Up @@ -221,6 +226,7 @@ private function sendRequest(string $pattern): bool
'base_uri' => $this->baseUrl,
'headers' => [
'Content-Type' => 'application/json',
'Authorization' => 'APIToken ' . $this->apiToken,
],
'timeout' => self::API_REQUEST_TIMEOUT,
]);
Expand Down
12 changes: 12 additions & 0 deletions src/templates/settings.twig
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@
required: true,
}) }}

{{ forms.autosuggestField({
label: 'API Token'|t('blitz-f5'),
instructions: 'The API token.'|t('blitz-f5'),
placeholder: 'system',
suggestEnvVars: true,
suggestions: craft.cp.getEnvSuggestions(),
name: 'apiToken',
value: purger.apiToken,
errors: purger.getErrors('namespace'),
required: true,
}) }}

{{ forms.lightswitchField({
label: 'Hard Purge'|t('blitz-f5'),
instructions: 'Whether to remove the content from the distribution, forcing the next request to retrieve the content from the origin server. With this off, the content will be replaced on the next request if the content is stale.'|t('blitz-f5'),
Expand Down

0 comments on commit 11ac806

Please sign in to comment.