Skip to content

Commit

Permalink
chore: README updates/examples
Browse files Browse the repository at this point in the history
  • Loading branch information
markphelps committed Jan 28, 2024
1 parent e0b5360 commit 3c9d357
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 13 deletions.
27 changes: 25 additions & 2 deletions flipt-java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This directory contains the Java source code for the Flipt [server-side](https:/
## Documentation

API documentation is available at <https://www.flipt.io/docs/reference/overview>.
This directory contains the Java source code for the Java server side SDK.

## Installation

Expand Down Expand Up @@ -35,4 +34,28 @@ Add the dependency in your `pom.xml`:

## Usage

In the [examples](./examples) directory, there is an example Java program which imports in the flipt client, and uses it appropriately, please refer to that for how to use the client.
In your Java code you can import this client and use it as so:

```java
import io.flipt.api.FliptClient;
import io.flipt.api.evaluation.models.*;

public class Main {
public static void main(String[] args) {
FliptClient fliptClient = FliptClient.builder().build();
Map<String, String> context = new HashMap<>();

context.put("fizz", "buzz");

EvaluationRequest variantEvaluationRequest =
EvaluationRequest.builder()
.namespaceKey("default")
.flagKey("flag1")
.entityId("entity")
.context(context)
.build();

EvaluationResponse variantEvaluationResponse = fliptClient.evaluate(variantEvaluationRequest);
```

There is a more detailed example in the [examples](./examples) directory.
21 changes: 20 additions & 1 deletion flipt-node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,26 @@ npm i @flipt-io/flipt@{version}

## Usage

In the [example](./example) directory, there is an example TypeScript program which imports in the flipt client, and uses it appropriately, please refer to that for how to use the client.
In your Node code you can import this client and use it as so:

```typescript
import { FliptClient } from "@flipt-io/flipt";

const fliptClient = new FliptClient();

async function evaluate() {
const variantEvaluationResponse = await fliptClient.evaluation.variant({
namespaceKey: "default",
flagKey: "flag1",
entityId: "entity",
context: { fizz: "buzz" }
});

console.log(variantEvaluationResponse);
}
```

There is a more detailed example in the [examples](./examples) directory.

### Metrics

Expand Down
18 changes: 12 additions & 6 deletions flipt-php/README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# Flipt PHP

[![Packagist Version](https://img.shields.io/packagist/v/flipt-io/flipt)](https://packagist.org/packages/flipt-io/flipt)
![beta](https://img.shields.io/badge/status-beta-yellow)

This directory contains the PHP source code for the Flipt [server-side](https://www.flipt.io/docs/integration/server/rest) client.

> [!NOTE]
> If you are on the <https://github.com/flipt-io/flipt-php> repository, this is a mirror of the source code. Please file issues and pull requests against the [flipt-io/flipt-server-sdks](https://github.com/flipt-io/flipt-server-sdks) repository.
## Status

This SDK status is `beta`, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning your installation of this package wherever necessary.

## Requirements

- PHP 8.0 or higher
Expand All @@ -29,7 +24,18 @@ composer install flipt-io/flipt

## Usage

TODO
In your PHP code you can import this client and use it as so:

```php
<?php
use Flipt\Client\FliptClient;

$fliptClient = new FliptClient();

$result = $fliptClient->variant('flag1', ['fizz' => 'buzz'], 'entity');
```

There is a more detailed example in the [tests](./tests) directory.

## Thanks :tada:

Expand Down
23 changes: 21 additions & 2 deletions flipt-python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This directory contains the Python source code for the Flipt [server-side](https
## Documentation

API documentation is available at <https://www.flipt.io/docs/reference/overview>.
This directory contains the Python source code for the Python server side SDK.

## Installation

Expand All @@ -17,4 +16,24 @@ pip install flipt=={version}

## Usage

In the [example](./example) directory, there is an example Python program which imports in the flipt client, and uses it appropriately, please refer to that for how to use the client.
In your Python code you can import this client and use it as so:

```python
from flipt import FliptClient
from flipt.evaluation import BatchEvaluationRequest, EvaluationRequest

fliptClient = FliptClient()

v = fliptClient.evaluation.variant(
EvaluationRequest(
namespace_key="default",
flag_key="flagll",
entity_id="entity",
context={"fizz": "buzz"},
)
)

print(v)
```

There is a more detailed example in the [examples](./examples) directory.
34 changes: 32 additions & 2 deletions flipt-rust/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ This directory contains the Rust source code for the Flipt [server-side](https:/
## Documentation

API documentation is available at <https://www.flipt.io/docs/reference/overview>.
This directory contains the Rust source code for the Rust server side SDK.

## Installation

Expand All @@ -17,4 +16,35 @@ cargo add flipt

## Usage

In the [examples](./examples) directory, there is an example Rust program which imports in the flipt client, and uses it appropriately, please refer to that for how to use the client.
In your Rust code you can import this client and use it as so:

```rust
use std::collections::HashMap;

use flipt::api::FliptClient;
use flipt::evaluation::models::EvaluationRequest;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = FliptClient::default();

let mut context: HashMap<String, String> = HashMap::new();

context.insert("fizz".into(), "buzz".into());

let variant_result = client
.evaluation
.variant(&EvaluationRequest {
namespace_key: "default".into(),
flag_key: "flag1".into(),
entity_id: "entity".into(),
context: context.clone(),
reference: None,
})
.await
.unwrap();

print!("{:?}", variant_result);
```

There is a more detailed example in the [examples](./examples) directory.

0 comments on commit 3c9d357

Please sign in to comment.