Skip to content

Commit

Permalink
chore: add storage docs snippets (#205)
Browse files Browse the repository at this point in the history
* chore: add storage client doc snippets

* chore: AUTH_TOKEN -> API_KEY and add missing examples to CI

* fix: fix example script name in CI

* chore: add client cheat sheet

* chore: fix snippet name
  • Loading branch information
pgautier404 authored Jul 17, 2024
1 parent 4af345a commit 1458202
Show file tree
Hide file tree
Showing 20 changed files with 206 additions and 55 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,14 @@ jobs:

- name: Run examples
env:
MOMENTO_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
working-directory: ./examples
run: |
composer install
php ./example.php
php ./dictionary-example.php
php ./list-example.php
php ./set-example.php
php ./doc-examples-php-apis.php
php ./storage-example.php
php ./psr16-example.php
5 changes: 4 additions & 1 deletion .github/workflows/on-push-to-main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,17 @@ jobs:

- name: Run examples
env:
MOMENTO_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
working-directory: ./examples
run: |
composer install
php ./example.php
php ./dictionary-example.php
php ./list-example.php
php ./set-example.php
php ./doc-examples-php-apis.php
php ./storage-example.php
php ./psr16-example.php
- name: Generate README
uses: momentohq/standards-and-practices/github-actions/generate-and-commit-oss-readme@gh-actions-v2
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/on-push-to-release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,17 @@ jobs:

- name: Run examples
env:
MOMENTO_AUTH_TOKEN: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
MOMENTO_API_KEY: ${{ secrets.ALPHA_TEST_AUTH_TOKEN }}
working-directory: ./examples
run: |
composer install
php ./example.php
php ./dictionary-example.php
php ./list-example.php
php ./set-example.php
php ./doc-examples-php-apis.php
php ./storage-example.php
php ./psr16-example.php
release:
runs-on: ubuntu-latest
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ You will likely need to run this only once:
## Run Integration Test

```bash
export TEST_AUTH_TOKEN=<YOUR_AUTH_TOKEN>
export TEST_AUTH_TOKEN=<YOUR_API_KEY>
./dev-run-integration-tests.sh
```
2 changes: 1 addition & 1 deletion README-logging.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ called:
```php
$myLogger = new My\Favorite\Logger("channel_name");
$loggerFactory = new Momento\Logging\PassthroughLoggerFactory($myLogger);
$authProvider = new EnvMomentoTokenProvider("MOMENTO_AUTH_TOKEN");
$authProvider = new EnvMomentoTokenProvider("MOMENTO_API_KEY");
// All logging internal to the Momento client will use this factory to gain
// access to a reference to $myLogger.
$configuration = Laptop::latest()->withLoggerFactory($loggerFactory);
Expand Down
4 changes: 2 additions & 2 deletions README-proxying.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ configured to connect to. If you're using a JWT to authenticate with Momento, yo
control plane (cp) and cache plane (c) with the following shell command:

```shell
echo $MOMENTO_AUTH_TOKEN | awk -F . {'print $2}' | base64 -d
echo $MOMENTO_API_KEY | awk -F . {'print $2}' | base64 -d
```

A sample configuration (using nonexistent server hostnames) is as follows:
Expand Down Expand Up @@ -47,7 +47,7 @@ provider. Using the `EnvMomentoTokenProvider`, which reads the token from an env

```php
$authProvider = new EnvMomentoTokenProvider(
envVariableName: "MOMENTO_AUTH_TOKEN",
envVariableName: "MOMENTO_API_KEY",
controlEndpoint: "localhost:4443",
cacheEndpoint: "localhost:4444",
trustedControlEndpointCertificateName: "control.some-control-cell-name.momentohq.com",
Expand Down
2 changes: 1 addition & 1 deletion README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ $KEY = "MyKey";
$VALUE = "MyValue";

// Setup
$authProvider = CredentialProvider::fromEnvironmentVariable("MOMENTO_AUTH_TOKEN");
$authProvider = CredentialProvider::fromEnvironmentVariable("MOMENTO_API_KEY");
$configuration = Laptop::latest(new StderrLoggerFactory());
$client = new CacheClient($configuration, $authProvider, $ITEM_DEFAULT_TTL_SECONDS);
$logger = $configuration->getLoggerFactory()->getLogger("ex:");
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use Momento\Cache\CacheClient;
use Momento\Config\Configurations\Laptop;

$client = new CacheClient(
Laptop::latest(), CredentialProvider::fromEnvironmentVariable("MOMENTO_AUTH_TOKEN"), 60
Laptop::latest(), CredentialProvider::fromEnvironmentVariable("MOMENTO_API_KEY"), 60
);
$client->createCache("cache");
$client->set("cache", "myKey", "myValue");
Expand Down
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ The Docker way:
Set required environment variables:

```bash
export MOMENTO_AUTH_TOKEN=<YOUR_AUTH_TOKEN>
export MOMENTO_API_KEY=<YOUR_API_KEY>
```

To run the simple set/get example:
Expand Down
2 changes: 1 addition & 1 deletion examples/composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"require": {
"momentohq/client-sdk-php": "1.9.1",
"momentohq/client-sdk-php": "1.11.1",
"monolog/monolog": "^2.5"
}
}
2 changes: 1 addition & 1 deletion examples/dictionary-example.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
$ITEM_DEFAULT_TTL_SECONDS = 60;

// Setup
$authProvider = CredentialProvider::fromEnvironmentVariable("MOMENTO_AUTH_TOKEN");
$authProvider = CredentialProvider::fromEnvironmentVariable("MOMENTO_API_KEY");

$configuration = Laptop::latest(new StderrLoggerFactory());
$client = new CacheClient($configuration, $authProvider, $ITEM_DEFAULT_TTL_SECONDS);
Expand Down
10 changes: 10 additions & 0 deletions examples/doc-example-files/storage-cheat-sheet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
require "vendor/autoload.php";
use Momento\Auth\CredentialProvider;
use Momento\Config\Configurations\Storage\Laptop;
use Momento\Storage\PreviewStorageClient;

$storageClient = new PreviewStorageClient(
Laptop::latest(),
CredentialProvider::fromEnvironmentVariable("MOMENTO_API_KEY")
);
Loading

0 comments on commit 1458202

Please sign in to comment.