getAdditionalHeaders() {
16 | return this.additionalHeaders;
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/api/configuration/CredentialsMethod.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{configPackage}};
3 |
4 | /**
5 | * Mutually exclusive methods for delivering credentials.
6 | */
7 | public enum CredentialsMethod {
8 | /**
9 | * No credentials.
10 | */
11 | NONE,
12 |
13 | /**
14 | * A static API token. In OAuth2 terms, this indicates an "access token"
15 | * that will be used to make a request. When used as part of {@link Configuration}
16 | * then an {@link ApiToken} should also be defined.
17 | */
18 | API_TOKEN,
19 |
20 | /**
21 | * OAuth2 client credentials that can be used to acquire an OAuth2 access
22 | * token. When used as part of {@link Configuration} then a
23 | * {@link ClientCredentials} should also be defined.
24 | */
25 | CLIENT_CREDENTIALS;
26 | }
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaApiAuthenticationError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | public class FgaApiAuthenticationError extends FgaError {
6 | public FgaApiAuthenticationError(
7 | String message, Throwable cause, int code, HttpHeaders responseHeaders, String responseBody) {
8 | super(message, cause, code, responseHeaders, responseBody);
9 | }
10 |
11 | public FgaApiAuthenticationError(String message, int code, HttpHeaders responseHeaders, String responseBody) {
12 | super(message, code, responseHeaders, responseBody);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaApiInternalError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | public class FgaApiInternalError extends FgaError {
6 | public FgaApiInternalError(
7 | String message, Throwable cause, int code, HttpHeaders responseHeaders, String responseBody) {
8 | super(message, cause, code, responseHeaders, responseBody);
9 | }
10 |
11 | public FgaApiInternalError(String message, int code, HttpHeaders responseHeaders, String responseBody) {
12 | super(message, code, responseHeaders, responseBody);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaApiNotFoundError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | public class FgaApiNotFoundError extends FgaError {
6 | public FgaApiNotFoundError(
7 | String message, Throwable cause, int code, HttpHeaders responseHeaders, String responseBody) {
8 | super(message, cause, code, responseHeaders, responseBody);
9 | }
10 |
11 | public FgaApiNotFoundError(String message, int code, HttpHeaders responseHeaders, String responseBody) {
12 | super(message, code, responseHeaders, responseBody);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaApiRateLimitExceededError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | public class FgaApiRateLimitExceededError extends FgaError {
6 | public FgaApiRateLimitExceededError(
7 | String message, Throwable cause, int code, HttpHeaders responseHeaders, String responseBody) {
8 | super(message, cause, code, responseHeaders, responseBody);
9 | }
10 |
11 | public FgaApiRateLimitExceededError(String message, int code, HttpHeaders responseHeaders, String responseBody) {
12 | super(message, code, responseHeaders, responseBody);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaApiValidationError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | import java.net.http.HttpHeaders;
4 |
5 | public class FgaApiValidationError extends FgaError {
6 | public FgaApiValidationError(
7 | String message, Throwable cause, int code, HttpHeaders responseHeaders, String responseBody) {
8 | super(message, cause, code, responseHeaders, responseBody);
9 | }
10 |
11 | public FgaApiValidationError(String message, int code, HttpHeaders responseHeaders, String responseBody) {
12 | super(message, code, responseHeaders, responseBody);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaInvalidParameterException.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | public class FgaInvalidParameterException extends Exception {
4 | public FgaInvalidParameterException(String message) {
5 | super(message);
6 | }
7 |
8 | public FgaInvalidParameterException(String paramName, String functionName) {
9 | super(message(paramName, functionName));
10 | }
11 |
12 | public FgaInvalidParameterException(String paramName, String functionName, Throwable cause) {
13 | super(message(paramName, functionName), cause);
14 | }
15 |
16 | private static String message(String paramName, String functionName) {
17 | return String.format("Required parameter %s was invalid when calling %s.", paramName, functionName);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/errors/FgaValidationError.java.mustache:
--------------------------------------------------------------------------------
1 | package {{errorsPackage}};
2 |
3 | public class FgaValidationError extends Exception {
4 | private final String field;
5 |
6 | public FgaValidationError(String field, String message) {
7 | super(message);
8 | this.field = field;
9 | }
10 |
11 | public String getField() {
12 | return field;
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Attribute.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | /**
5 | * Represents an attribute in telemetry data.
6 | */
7 | public class Attribute {
8 | private final String name;
9 |
10 | /**
11 | * Constructs a new Attribute object with the specified name.
12 | *
13 | * @param name the name of the attribute
14 | */
15 | public Attribute(String name) {
16 | this.name = name;
17 | }
18 |
19 | /**
20 | * Returns the name of the attribute.
21 | *
22 | * @return the name of the attribute
23 | */
24 | public String getName() {
25 | return name;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Counter.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | /**
5 | * Represents a counter used for telemetry purposes.
6 | */
7 | public class Counter extends Metric {
8 | /**
9 | * Constructs a new Counter with the specified name, unit, and description.
10 | *
11 | * @param name the name of the counter
12 | * @param description the description of the counter
13 | */
14 | public Counter(String name, String description) {
15 | super(name, description);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Counters.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | /**
5 | * The Counters class represents telemetry counters used in the OpenFGA SDK.
6 | */
7 | public class Counters {
8 | /**
9 | * The CREDENTIALS_REQUEST counter represents the number of times an access token is requested.
10 | */
11 | public static final Counter CREDENTIALS_REQUEST = new Counter(
12 | "fga-client.credentials.request",
13 | "The total number of times new access tokens have been requested using ClientCredentials.");
14 |
15 | private Counters() {} // Instantiation prevented.
16 | }
17 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Histogram.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | /**
5 | * Represents a histogram for telemetry data.
6 | */
7 | public class Histogram extends Metric {
8 | private final String unit;
9 |
10 | /**
11 | * Constructs a Histogram object with the specified name, unit, and description.
12 | *
13 | * @param name the name of the histogram
14 | * @param unit the unit of measurement for the histogram
15 | * @param description the description of the histogram
16 | */
17 | public Histogram(String name, String unit, String description) {
18 | super(name, description);
19 | this.unit = unit;
20 | }
21 |
22 | /**
23 | * Constructs a Histogram object with the specified name and description. The unit of measurement is set to "milliseconds" by default.
24 | *
25 | * @param name the name of the histogram
26 | * @param description the description of the histogram
27 | */
28 | public Histogram(String name, String description) {
29 | super(name, description);
30 | this.unit = "milliseconds";
31 | }
32 |
33 | /**
34 | * Returns the unit of measurement for the histogram.
35 | */
36 | public String getUnit() {
37 | return unit;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Histograms.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | /**
5 | * The Histograms class represents a collection of predefined histograms for telemetry purposes.
6 | */
7 | public class Histograms {
8 | /**
9 | * A histogram for measuring the total time (in milliseconds) it took for the request to complete, including the time it took to send the request and receive the response.
10 | */
11 | public static final Histogram REQUEST_DURATION = new Histogram(
12 | "fga-client.request.duration",
13 | "The total time (in milliseconds) it took for the request to complete, including the time it took to send the request and receive the response.");
14 |
15 | /**
16 | * A histogram for measuring the total time it took (in milliseconds) for the FGA server to process and evaluate the request.
17 | */
18 | public static final Histogram QUERY_DURATION = new Histogram(
19 | "fga-client.query.duration",
20 | "The total time it took (in milliseconds) for the FGA server to process and evaluate the request.");
21 |
22 | private Histograms() {} // Instantiation prevented.
23 | }
24 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Metric.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | public class Metric {
5 | private final String name;
6 | private final String description;
7 |
8 | /**
9 | * Constructs a new metric with the specified name and description.
10 | *
11 | * @param name the name of the counter
12 | * @param description the description of the counter
13 | */
14 | public Metric(String name, String description) {
15 | this.name = name;
16 | this.description = description;
17 | }
18 |
19 | /**
20 | * Returns the name of the metric.
21 | */
22 | public String getName() {
23 | return name;
24 | }
25 |
26 | /**
27 | * Returns the description of the metric.
28 | */
29 | public String getDescription() {
30 | return description;
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/telemetry/Telemetry.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import {{configPackage}}.Configuration;
5 |
6 | /**
7 | * The Telemetry class provides access to telemetry-related functionality.
8 | */
9 | public class Telemetry {
10 | private Configuration configuration = null;
11 | private Metrics metrics = null;
12 |
13 | public Telemetry(Configuration configuration) {
14 | this.configuration = configuration;
15 | }
16 |
17 | /**
18 | * Returns a Metrics singleton for collecting telemetry data.
19 | * If the Metrics singleton has not previously been initialized, it will be created.
20 | */
21 | public Metrics metrics() {
22 | if (metrics == null) {
23 | metrics = new Metrics(configuration);
24 | }
25 |
26 | return metrics;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/main/util/Validation.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{utilPackage}};
3 |
4 | import static {{utilPackage}}.StringUtil.isNullOrWhitespace;
5 | import {{errorsPackage}}.FgaInvalidParameterException;
6 |
7 | public class Validation {
8 | private Validation() {} // Instantiation prevented for utility class.
9 |
10 | public static void assertParamExists(Object obj, String name, String context) throws FgaInvalidParameterException {
11 | if (obj == null || obj instanceof String && isNullOrWhitespace((String) obj)) {
12 | throw new FgaInvalidParameterException(name, context);
13 | }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test-integration/package-info.java.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * This is an autogenerated Java SDK for OpenFGA.
3 | * It provides a wrapper around the OpenFGA API definition.
4 | *
5 | * Most interaction should be centered around the high-level {@link {{clientPackage}}.OpenFgaClient}.
6 | *
7 | * @see OpenFGA Docs
8 | * @see Source
9 | */
10 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/AttributeTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | class AttributeTest {
9 | @Test
10 | void shouldGetName() {
11 | // given
12 | String attributeName = "testAttribute";
13 | Attribute attribute = new Attribute(attributeName);
14 |
15 | // when
16 | String result = attribute.getName();
17 |
18 | // then
19 | assertThat(result).isEqualTo(attributeName);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/CounterTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | class CounterTest {
9 | @Test
10 | void shouldCreateCounter() {
11 | // given
12 | String name = "testCounter";
13 | String description = "A counter for testing";
14 |
15 | // when
16 | Counter counter = new Counter(name, description);
17 |
18 | // then
19 | assertThat(counter.getName()).isEqualTo(name);
20 | assertThat(counter.getDescription()).isEqualTo(description);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/CountersTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | class CountersTest {
9 | @Test
10 | void shouldCreateCredentialsRequestCounter() {
11 | // given
12 | String expectedName = "fga-client.credentials.request";
13 | String expectedDescription =
14 | "The total number of times new access tokens have been requested using ClientCredentials.";
15 |
16 | // when
17 | Counter counter = Counters.CREDENTIALS_REQUEST;
18 |
19 | // then
20 | assertThat(counter.getName()).isEqualTo(expectedName);
21 | assertThat(counter.getDescription()).isEqualTo(expectedDescription);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/HistogramTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | class HistogramTest {
9 | @Test
10 | void shouldCreateHistogramWithUnit() {
11 | // given
12 | String name = "testHistogram";
13 | String unit = "seconds";
14 | String description = "A histogram for testing";
15 |
16 | // when
17 | Histogram histogram = new Histogram(name, unit, description);
18 |
19 | // then
20 | assertThat(histogram.getName()).isEqualTo(name);
21 | assertThat(histogram.getDescription()).isEqualTo(description);
22 | assertThat(histogram.getUnit()).isEqualTo(unit);
23 | }
24 |
25 | @Test
26 | void shouldCreateHistogramWithDefaultMillisecondsUnit() {
27 | // given
28 | String name = "testHistogram";
29 | String description = "A histogram for testing";
30 |
31 | // when
32 | Histogram histogram = new Histogram(name, description);
33 |
34 | // then
35 | assertThat(histogram.getName()).isEqualTo(name);
36 | assertThat(histogram.getDescription()).isEqualTo(description);
37 | assertThat(histogram.getUnit()).isEqualTo("milliseconds");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/MetricTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import org.junit.jupiter.api.Test;
7 |
8 | class MetricTest {
9 | @Test
10 | void shouldCreateMetric() {
11 | // given
12 | String name = "testMetric";
13 | String description = "A metric for testing";
14 |
15 | // when
16 | Metric metric = new Metric(name, description);
17 |
18 | // then
19 | assertThat(metric.getName()).isEqualTo(name);
20 | assertThat(metric.getDescription()).isEqualTo(description);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/config/clients/java/template/src/test/telemetry/TelemetryTest.java.mustache:
--------------------------------------------------------------------------------
1 | {{>licenseInfo}}
2 | package {{telemetryPackage}};
3 |
4 | import static org.assertj.core.api.Assertions.assertThat;
5 |
6 | import {{configPackage}}.Configuration;
7 | import org.junit.jupiter.api.Test;
8 |
9 | class TelemetryTest {
10 | @Test
11 | void shouldBeASingletonMetricsInitialization() {
12 | // given
13 | Telemetry telemetry = new Telemetry(new Configuration());
14 |
15 | // when
16 | Metrics firstCall = telemetry.metrics();
17 | Metrics secondCall = telemetry.metrics();
18 |
19 | // then
20 | assertThat(firstCall).isNotNull().isSameAs(secondCall);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/config/clients/java/template/typeInfoAnnotation.mustache:
--------------------------------------------------------------------------------
1 | {{#jackson}}
2 |
3 | @JsonIgnoreProperties(
4 | value = "{{{discriminator.propertyBaseName}}}", // ignore manually set {{{discriminator.propertyBaseName}}}, it will be automatically generated by Jackson during serialization
5 | allowSetters = true // allows the {{{discriminator.propertyBaseName}}} to be set during deserialization
6 | )
7 | @JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "{{{discriminator.propertyBaseName}}}", visible = true)
8 | {{#discriminator.mappedModels}}
9 | {{#-first}}
10 | @JsonSubTypes({
11 | {{/-first}}
12 | @JsonSubTypes.Type(value = {{modelName}}.class, name = "{{^vendorExtensions.x-discriminator-value}}{{mappingName}}{{/vendorExtensions.x-discriminator-value}}{{#vendorExtensions.x-discriminator-value}}{{{vendorExtensions.x-discriminator-value}}}{{/vendorExtensions.x-discriminator-value}}"),
13 | {{#-last}}
14 | })
15 | {{/-last}}
16 | {{/discriminator.mappedModels}}
17 | {{/jackson}}
18 |
--------------------------------------------------------------------------------
/config/clients/js/.openapi-generator-ignore:
--------------------------------------------------------------------------------
1 | .npmignore
2 |
--------------------------------------------------------------------------------
/config/clients/js/generator.txt:
--------------------------------------------------------------------------------
1 | typescript-axios
2 |
--------------------------------------------------------------------------------
/config/clients/js/template/.eslintignore:
--------------------------------------------------------------------------------
1 | dist/
2 |
--------------------------------------------------------------------------------
/config/clients/js/template/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "env": {
3 | "browser": true,
4 | "es2021": true,
5 | "node": true
6 | },
7 | "extends": [
8 | "eslint:recommended",
9 | "plugin:@typescript-eslint/recommended"
10 | ],
11 | "parser": "@typescript-eslint/parser",
12 | "parserOptions": {
13 | "ecmaVersion": 13,
14 | "sourceType": "module"
15 | },
16 | "plugins": [
17 | "@typescript-eslint"
18 | ],
19 | "rules": {
20 | "@typescript-eslint/no-unused-vars": ["warn"],
21 | "@typescript-eslint/no-explicit-any": ["warn"],
22 | "@typescript-eslint/no-require-imports":["error", { allowAsImport: true }],
23 | "indent": [
24 | "error",
25 | 2
26 | ],
27 | "linebreak-style": [
28 | "error",
29 | "unix"
30 | ],
31 | "quotes": [
32 | "error",
33 | "double"
34 | ],
35 | "semi": [
36 | "error",
37 | "always"
38 | ]
39 | }
40 | };
41 |
--------------------------------------------------------------------------------
/config/clients/js/template/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "npm"
4 | directory: "/"
5 | schedule:
6 | interval: "weekly"
7 | groups:
8 | dependencies:
9 | patterns:
10 | - "*"
11 | exclude-patterns:
12 | - "eslint"
13 | - package-ecosystem: "github-actions"
14 | directory: "/"
15 | schedule:
16 | interval: "weekly"
17 | groups:
18 | dependencies:
19 | patterns:
20 | - "*"
21 |
--------------------------------------------------------------------------------
/config/clients/js/template/.madgerc:
--------------------------------------------------------------------------------
1 | {
2 | "detectiveOptions": {
3 | "ts": {
4 | "skipTypeImports": true
5 | }
6 | }
7 | }
--------------------------------------------------------------------------------
/config/clients/js/template/README_custom_badges.mustache:
--------------------------------------------------------------------------------
1 | [](https://www.npmjs.com/package/{{packageName}})
2 |
--------------------------------------------------------------------------------
/config/clients/js/template/README_installation.mustache:
--------------------------------------------------------------------------------
1 | Using [npm](https://npmjs.org):
2 |
3 | ```shell
4 | npm install {{packageName}}
5 | ```
6 |
7 | Using [yarn](https://yarnpkg.com):
8 |
9 | ```shell
10 | yarn add {{packageName}}
11 | ```
--------------------------------------------------------------------------------
/config/clients/js/template/README_license_disclaimer.mustache:
--------------------------------------------------------------------------------
1 | The code in this repo was auto generated by [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from a template based on the [typescript-axios template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/typescript-axios) and [go template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/go), licensed under the [Apache License 2.0](https://github.com/OpenAPITools/openapi-generator/blob/master/LICENSE).
--------------------------------------------------------------------------------
/config/clients/js/template/README_models.mustache:
--------------------------------------------------------------------------------
1 | [Models](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/blob/main/apiModel.ts)
2 |
--------------------------------------------------------------------------------
/config/clients/js/template/README_retries.mustache:
--------------------------------------------------------------------------------
1 | If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to {{defaultMaxRetry}} times with a minimum wait time of {{defaultMinWaitInMs}} milliseconds between each attempt.
2 |
3 | To customize this behavior, create an object with `maxRetry` and `minWaitInMs` properties. `maxRetry` determines the maximum number of retries (up to {{retryMaxAllowedNumber}}), while `minWaitInMs` sets the minimum wait time between retries in milliseconds.
4 |
5 | Apply your custom retry values by setting to `retryParams` on the configuration object passed to the `OpenFgaClient` call.
6 |
7 | ```javascript
8 | const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';
9 |
10 | const fgaClient = new OpenFgaClient({
11 | apiUrl: process.env.FGA_API_URL, // required
12 | storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
13 | authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
14 | retryParams: {
15 | maxRetry: 3, // retry up to 3 times on API requests
16 | minWaitInMs: 250 // wait a minimum of 250 milliseconds between requests
17 | }
18 | });
19 | ```
--------------------------------------------------------------------------------
/config/clients/js/template/api.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | {{^withSeparateModelsAndApi}}
4 | import globalAxios, { AxiosInstance } from 'axios';
5 |
6 | import { BaseAPI } from './base';
7 | import {
8 | DUMMY_BASE_URL,
9 | setSearchParams,
10 | serializeDataIfNeeded,
11 | toPathString,
12 | createRequestFunction,
13 | RequestArgs,
14 | CallResult,
15 | PromiseResult
16 | } from './common';
17 | import { Configuration } from './configuration';
18 | import { Credentials } from "./credentials";
19 | import { assertParamExists } from './validation';
20 |
21 | import {
22 | {{#models}}
23 | {{#model}}{{classname}},{{/model}}
24 | {{/models}}
25 | } from './apiModel';
26 | import { TelemetryAttribute, TelemetryAttributes } from "./telemetry/attributes";
27 |
28 | {{#apiInfo}}{{#apis}}
29 | {{>apiInner}}
30 | {{/apis}}{{/apiInfo}}
31 | {{/withSeparateModelsAndApi}}{{#withSeparateModelsAndApi}}
32 | {{#apiInfo}}{{#apis}}{{#operations}}export * from './{{tsApiPackage}}/{{classFilename}}';
33 | {{/operations}}{{/apis}}{{/apiInfo}}
34 | {{/withSeparateModelsAndApi}}
35 |
--------------------------------------------------------------------------------
/config/clients/js/template/apiModel.mustache:
--------------------------------------------------------------------------------
1 | {{^withSeparateModelsAndApi}}
2 | /* tslint:disable */
3 | /* eslint-disable */
4 | {{>partial_header}}
5 |
6 | {{#models}}
7 | {{#model}}{{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{^isEnum}}{{^oneOf}}{{>modelGeneric}}{{/oneOf}}{{/isEnum}}{{/model}}
8 | {{/models}}
9 |
10 | {{/withSeparateModelsAndApi}}
--------------------------------------------------------------------------------
/config/clients/js/template/credentials/index.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export * from "./credentials";
4 | export * from "./types";
5 |
--------------------------------------------------------------------------------
/config/clients/js/template/example/Makefile:
--------------------------------------------------------------------------------
1 | all: run
2 |
3 | project_name=example1
4 | openfga_version=latest
5 |
6 | setup:
7 | npm --prefix "${project_name}" install
8 |
9 | run:
10 | npm --prefix "${project_name}" run start
11 |
12 | run-openfga:
13 | docker pull docker.io/openfga/openfga:${openfga_version} && \
14 | docker run -p 8080:8080 docker.io/openfga/openfga:${openfga_version} run
--------------------------------------------------------------------------------
/config/clients/js/template/example/example1/package.json.mustache:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example1",
3 | "private": "true",
4 | "version": "1.0.0",
5 | "description": "A bare bones example of using the OpenFGA SDK",
6 | "author": "OpenFGA",
7 | "license": "Apache-2.0",
8 | "scripts": {
9 | "start": "node example1.mjs"
10 | },
11 | "dependencies": {
12 | "@openfga/sdk": "^{{packageVersion}}"
13 | },
14 | "engines": {
15 | "node": ">=16.13.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/config/clients/js/template/example/opentelemetry/.env.example:
--------------------------------------------------------------------------------
1 | # Configuration for OpenFGA
2 | FGA_CLIENT_ID=
3 | FGA_API_TOKEN_ISSUER=
4 | FGA_API_AUDIENCE=
5 | FGA_CLIENT_SECRET=
6 | FGA_STORE_ID=
7 | FGA_AUTHORIZATION_MODEL_ID=
8 | FGA_API_URL="http://localhost:8080"
9 |
10 | # Configuration for OpenTelemetry
11 | OTEL_SERVICE_NAME="openfga-opentelemetry-example"
--------------------------------------------------------------------------------
/config/clients/js/template/example/opentelemetry/.npmrc:
--------------------------------------------------------------------------------
1 | package-lock=false
--------------------------------------------------------------------------------
/config/clients/js/template/example/opentelemetry/README.md:
--------------------------------------------------------------------------------
1 | # OpenTelemetry usage with OpenFGA's JS SDK
2 |
3 | This example demonstrates how you can use OpenTelemetry with OpenFGA's JS SDK.
4 |
5 | ## Prerequisites
6 |
7 | If you do not already have an OpenFGA instance running, you can start one using the following command:
8 |
9 | ```bash
10 | docker run -d -p 8080:8080 openfga/openfga
11 | ```
12 |
13 | You need to have an OpenTelemetry collector running to receive data. A pre-configured collector is available using Docker:
14 |
15 | ```bash
16 | git clone https://github.com/ewanharris/opentelemetry-collector-dev-setup.git
17 | cd opentelemetry-collector-dev-setup
18 | docker-compose up -d
19 | ```
20 |
21 | ## Configure the example
22 |
23 | You need to configure the example for your environment:
24 |
25 | ```bash
26 | cp .env.example .env
27 | ```
28 |
29 | Now edit the `.env` file and set the values as appropriate.
30 |
31 | ## Running the example
32 |
33 | Begin by installing the required dependencies:
34 |
35 | ```bash
36 | npm i
37 | ```
38 |
39 | Next, run the example:
40 |
41 | ```bash
42 | npm start
43 | ```
--------------------------------------------------------------------------------
/config/clients/js/template/example/opentelemetry/instrumentation.mjs:
--------------------------------------------------------------------------------
1 | import "dotenv/config";
2 | import { NodeSDK } from "@opentelemetry/sdk-node";
3 | import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
4 | import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-proto";
5 | import process from "process";
6 |
7 | const sdk = new NodeSDK({
8 | metricReader: new PeriodicExportingMetricReader({
9 | exportIntervalMillis: 5000,
10 | exporter: new OTLPMetricExporter({
11 | concurrencyLimit: 1,
12 | }),
13 | }),
14 | });
15 | sdk.start();
16 |
17 | process.on("exit", () => {
18 | sdk
19 | .shutdown()
20 | .then(
21 | () => console.log("SDK shut down successfully"),
22 | (err) => console.log("Error shutting down SDK", err)
23 | )
24 | .finally(() => process.exit(0));
25 | });
--------------------------------------------------------------------------------
/config/clients/js/template/example/opentelemetry/package.json.mustache:
--------------------------------------------------------------------------------
1 | {
2 | "name": "openfga-opentelemetry-example",
3 | "private": "true",
4 | "version": "1.0.0",
5 | "description": "A bare bones example of using the OpenFGA SDK with OpenTelemetry metrics reporting",
6 | "author": "OpenFGA",
7 | "license": "Apache-2.0",
8 | "scripts": {
9 | "start": "node --import ./instrumentation.mjs opentelemetry.mjs"
10 | },
11 | "dependencies": {
12 | "@openfga/sdk": "file:../../",
13 | "@opentelemetry/exporter-metrics-otlp-proto": "^0.52.1",
14 | "@opentelemetry/exporter-prometheus": "^0.52.1",
15 | "@opentelemetry/sdk-metrics": "^1.25.1",
16 | "@opentelemetry/sdk-node": "^0.52.1",
17 | "dotenv": "^16.4.5"
18 | },
19 | "engines": {
20 | "node": ">=16.13.0"
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/config/clients/js/template/gitignore_custom.mustache:
--------------------------------------------------------------------------------
1 | wwwroot/*.js
2 | node_modules
3 | typings
4 | dist
5 | coverage
6 |
--------------------------------------------------------------------------------
/config/clients/js/template/index.mustache:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | {{>partial_header}}
4 |
5 | export * from "./api";
6 | export * from "./client";
7 | export * from "./apiModel";
8 | export { Configuration, UserConfigurationParams, GetDefaultRetryParams } from "./configuration";
9 | export { Credentials, CredentialsMethod } from "./credentials";
10 | export * from "./telemetry/attributes";
11 | export * from "./telemetry/configuration";
12 | export * from "./telemetry/counters";
13 | export * from "./telemetry/histograms";
14 | export * from "./telemetry/metrics";
15 | export * from "./errors";
16 |
17 | {{#withSeparateModelsAndApi}}export * from "./{{tsModelPackage}}";{{/withSeparateModelsAndApi}}
18 |
--------------------------------------------------------------------------------
/config/clients/js/template/model.mustache:
--------------------------------------------------------------------------------
1 | /* tslint:disable */
2 | /* eslint-disable */
3 | {{>partial_header}}
4 | {{#withSeparateModelsAndApi}}{{#hasAllOf}}{{#allOf}}
5 | import { {{class}} } from './{{filename}}';{{/allOf}}{{/hasAllOf}}{{#hasOneOf}}{{#oneOf}}
6 | import { {{class}} } from './{{filename}}';{{/oneOf}}{{/hasOneOf}}{{^hasAllOf}}{{^hasOneOf}}{{#imports}}
7 | import { {{class}} } from './{{filename}}';{{/imports}}{{/hasOneOf}}{{/hasAllOf}}{{/withSeparateModelsAndApi}}
8 | {{#models}}{{#model}}
9 | {{#isEnum}}{{>modelEnum}}{{/isEnum}}{{#oneOf}}{{#-first}}{{>modelOneOf}}{{/-first}}{{/oneOf}}{{#allOf}}{{#-first}}{{>modelAllOf}}{{/-first}}{{/allOf}}{{^isEnum}}{{^oneOf}}{{^allOf}}{{>modelGeneric}}{{/allOf}}{{/oneOf}}{{/isEnum}}
10 | {{/model}}{{/models}}
11 |
--------------------------------------------------------------------------------
/config/clients/js/template/modelAllOf.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {{classname}}{{#description}}
3 | * {{{description}}}{{/description}}
4 | * @export
5 | */
6 | export type {{classname}} = {{#allOf}}{{{.}}}{{^-last}} & {{/-last}}{{/allOf}};
7 |
--------------------------------------------------------------------------------
/config/clients/js/template/modelEnum.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * {{{description}}}
3 | * @export
4 | * @enum {string}
5 | */
6 | {{#isBoolean}}
7 | export type {{classname}} = {{#allowableValues}}{{#enumVars}}{{{value}}}{{^-last}} | {{/-last}}{{/enumVars}}{{/allowableValues}}
8 | {{/isBoolean}}
9 |
10 | {{^isBoolean}}
11 | export enum {{classname}} {
12 | {{#allowableValues}}
13 | {{#enumVars}}
14 | {{#enumDescription}}
15 | /**
16 | * {{enumDescription}}
17 | */
18 | {{/enumDescription}}
19 | {{{name}}} = {{{value}}}{{^-last}},{{/-last}}
20 | {{/enumVars}}
21 | {{/allowableValues}}
22 | }
23 | {{/isBoolean}}
24 |
--------------------------------------------------------------------------------
/config/clients/js/template/modelGeneric.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * {{{description}}}
3 | * @export
4 | * @interface {{classname}}
5 | */
6 | export interface {{classname}} {{#parent}}extends {{{parent}}} {{/parent}}{
7 | {{#additionalPropertiesType}}
8 | [key: string]: {{{additionalPropertiesType}}}{{#hasVars}} | any{{/hasVars}};
9 |
10 | {{/additionalPropertiesType}}
11 | {{#vars}}
12 | /**
13 | * {{{description}}}
14 | * @type {{=<% %>=}}{<%&datatype%>}<%={{ }}=%>
15 | * @memberof {{classname}}
16 | {{#deprecated}}
17 | * @deprecated
18 | {{/deprecated}}
19 | */
20 | {{name}}{{^required}}?{{/required}}: {{#isEnum}}{{{datatypeWithEnum}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{#isNullable}} | null{{/isNullable}}{{/isEnum}};
21 | {{/vars}}
22 | }{{#hasEnums}}
23 |
24 | {{#vars}}
25 | {{#isEnum}}
26 | /**
27 | * @export
28 | * @enum {string}
29 | */
30 | export enum {{enumName}} {
31 | {{#allowableValues}}
32 | {{#enumVars}}
33 | {{#enumDescription}}
34 | /**
35 | * {{enumDescription}}
36 | */
37 | {{/enumDescription}}
38 | {{{name}}} = {{{value}}}{{^-last}},{{/-last}}
39 | {{/enumVars}}
40 | {{/allowableValues}}
41 | }
42 | {{/isEnum}}
43 | {{/vars}}
44 | {{/hasEnums}}
45 |
--------------------------------------------------------------------------------
/config/clients/js/template/modelIndex.mustache:
--------------------------------------------------------------------------------
1 | {{#models}}{{#model}}export * from './{{classFilename}}';{{/model}}
2 | {{/models}}
--------------------------------------------------------------------------------
/config/clients/js/template/modelOneOf.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | * @type {{classname}}{{#description}}
3 | * {{{description}}}{{/description}}
4 | * @export
5 | */
6 | export type {{classname}} = {{#oneOf}}{{{.}}}{{^-last}} | {{/-last}}{{/oneOf}};
7 |
--------------------------------------------------------------------------------
/config/clients/js/template/npmignore:
--------------------------------------------------------------------------------
1 | # empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
--------------------------------------------------------------------------------
/config/clients/js/template/npmrc.mustache:
--------------------------------------------------------------------------------
1 | registry={{npmRegistry}}
2 | sign-git-tag=true
3 |
--------------------------------------------------------------------------------
/config/clients/js/template/telemetry/counters.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export interface TelemetryCounter {
4 | name: string;
5 | unit: string;
6 | description: string;
7 | }
8 |
9 | export class TelemetryCounters {
10 | static credentialsRequest: TelemetryCounter = {
11 | name: "fga-client.credentials.request",
12 | unit: "milliseconds",
13 | description: "The number of times an access token is requested.",
14 | };
15 | }
16 |
--------------------------------------------------------------------------------
/config/clients/js/template/telemetry/histograms.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export interface TelemetryHistogram {
4 | name: string;
5 | unit: string;
6 | description: string;
7 | }
8 |
9 | export class TelemetryHistograms {
10 | static requestDuration: TelemetryHistogram = {
11 | name: "fga-client.request.duration",
12 | unit: "milliseconds",
13 | description: "How long it took for a request to be fulfilled.",
14 | };
15 |
16 | static queryDuration: TelemetryHistogram = {
17 | name: "fga-client.query.duration",
18 | unit: "milliseconds",
19 | description: "How long it took to perform a query request.",
20 | };
21 | }
22 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/helpers/index.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export { getNocks } from "./nocks";
4 | export { baseConfig, defaultConfiguration } from "./default-config";
5 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | preset: "ts-jest",
3 | rootDir: "../",
4 | testEnvironment: "node",
5 | moduleFileExtensions: ["js", "d.ts", "ts", "json"],
6 | collectCoverage: true,
7 | coverageReporters: ["text", "cobertura", "lcov"],
8 | collectCoverageFrom: [
9 | "**/**.{ts,tsx,js,jsx}",
10 | "!**/**.d.ts",
11 | "!**/**.eslintrc.js",
12 | "!**/coverage/**",
13 | "!**/dist/**",
14 | "!**/example/**",
15 | "!**/node_modules/**",
16 | "!**/tests/**",
17 | ],
18 | };
19 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/telemetry/counters.test.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import { TelemetryCounters } from "../../telemetry/counters";
4 |
5 | describe("TelemetryCounters", () => {
6 | test("should have correct counter details", () => {
7 | expect(TelemetryCounters.credentialsRequest.name).toBe("fga-client.credentials.request");
8 | expect(TelemetryCounters.credentialsRequest.unit).toBe("milliseconds");
9 | expect(TelemetryCounters.credentialsRequest.description).toBe("The number of times an access token is requested.");
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/telemetry/histograms.test.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import { TelemetryHistograms } from "../../telemetry/histograms";
4 |
5 | describe("TelemetryHistograms", () => {
6 | test("should have correct histogram details for request duration", () => {
7 | expect(TelemetryHistograms.requestDuration.name).toBe("fga-client.request.duration");
8 | expect(TelemetryHistograms.requestDuration.unit).toBe("milliseconds");
9 | expect(TelemetryHistograms.requestDuration.description).toBe("How long it took for a request to be fulfilled.");
10 | });
11 |
12 | test("should have correct histogram details for query duration", () => {
13 | expect(TelemetryHistograms.queryDuration.name).toBe("fga-client.query.duration");
14 | expect(TelemetryHistograms.queryDuration.unit).toBe("milliseconds");
15 | expect(TelemetryHistograms.queryDuration.description).toBe("How long it took to perform a query request.");
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.json",
3 | "compilerOptions": {
4 | "types": ["jest", "node"],
5 | "noEmit": true,
6 | "rootDir": "../"
7 | },
8 | "include": [
9 | "../**/*.ts",
10 | "./*.ts"
11 | ]
12 | }
13 |
--------------------------------------------------------------------------------
/config/clients/js/template/tests/validation.test.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import { isWellFormedUlidString } from "../validation";
4 |
5 | describe("validation.ts", () => {
6 | describe("isWellFormedUlidString", () => {
7 | it("should return true on valid ulids", async () => {
8 | const ulids: string[] = [
9 | "01H0GVCS1HCQM6SJRJ4A026FZ9",
10 | "01H0GVD9ACPFKGMWJV0Y93ZM7H",
11 | "01H0GVDH0FRZ4WAFED6T9KZYZR",
12 | "01H0GVDSW72AZ8QV3R0HJ91QBX",
13 | ];
14 | ulids.forEach(ulid => {
15 | const result = isWellFormedUlidString(ulid);
16 | expect(result).toBe(true);
17 | });
18 | });
19 |
20 | it("should return false on invalid ulids", async () => {
21 | const ulids: string[] = [
22 | "abc",
23 | 123 as any,
24 | null,
25 | "01H0GVDSW72AZ8QV3R0HJ91QBXa",
26 | "b523ad13-8adb-4803-a6db-013ac50197ca",
27 | "9240BFC0-DA00-457B-A328-FC370A598D60",
28 | ];
29 | ulids.forEach(ulid => {
30 | const result = isWellFormedUlidString(ulid);
31 | expect(result).toBe(false);
32 | });
33 | });
34 | });
35 | });
36 |
--------------------------------------------------------------------------------
/config/clients/js/template/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "declaration": true,
4 | "target": "es2020",
5 | "module": "commonjs",
6 | "noImplicitAny": true,
7 | "strict": true,
8 | "outDir": "dist",
9 | "rootDir": ".",
10 | "typeRoots": [
11 | "node_modules/@types"
12 | ]
13 | },
14 | "exclude": [
15 | "dist",
16 | "node_modules",
17 | "**/*.test.ts",
18 | "tests"
19 | ]
20 | }
21 |
--------------------------------------------------------------------------------
/config/clients/js/template/tsconfig.mustache:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "declaration": true,
4 | "target": "{{#supportsES6}}es6{{/supportsES6}}{{^supportsES6}}es5{{/supportsES6}}",
5 | "module": "commonjs",
6 | "noImplicitAny": true,
7 | "strict": true,
8 | "outDir": "dist",
9 | "rootDir": ".",
10 | {{^supportsES6}}
11 | "lib": [
12 | "es6",
13 | "dom"
14 | ],
15 | {{/supportsES6}}
16 | "typeRoots": [
17 | "node_modules/@types"
18 | ]
19 | },
20 | "exclude": [
21 | "dist",
22 | "node_modules",
23 | "**/*.test.ts",
24 | "tests"
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/assert-never.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export function assertNever(value: never): never {
4 | throw new Error(`Assertion failed. Unacceptable value: '${value}'`);
5 | }
6 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/chunk-array.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export function chunkArray(inputArray: T[], maxChunkSize: number): T[][] {
4 | const arrayOfArrays = [];
5 |
6 | const inputArrayClone = [...inputArray];
7 | while (inputArrayClone.length > 0) {
8 | arrayOfArrays.push(inputArrayClone.splice(0, maxChunkSize));
9 | }
10 |
11 | return arrayOfArrays;
12 | }
13 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/generate-random-id.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import { randomUUID, randomBytes } from "crypto";
4 |
5 | /**
6 | * Generates a random ID
7 | *
8 | * Note: May not return a valid value on older browsers - we're fine with this for now
9 | */
10 | export function generateRandomId(): string | undefined {
11 | if (typeof randomUUID === "function") {
12 | return randomUUID();
13 | }
14 |
15 | if (typeof randomBytes === "function") {
16 | // Fallback for older node versions
17 | return randomBytes(20).toString("hex");
18 | }
19 |
20 | // For older browsers
21 | return;
22 | }
23 |
24 | export function generateRandomIdWithNonUniqueFallback(): string {
25 | return generateRandomId() || "00000000-0000-0000-0000-000000000000";
26 | }
27 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/index.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export * from "./assert-never";
4 | export * from "./chunk-array";
5 | export * from "./generate-random-id";
6 | export * from "./set-header-if-not-set";
7 | export * from "./set-not-enumerable-property";
8 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/set-header-if-not-set.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export function setHeaderIfNotSet(headers: Record, key: string, value: string): void {
4 | if (!headers[key] && value) {
5 | headers[key] = value;
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/config/clients/js/template/utils/set-not-enumerable-property.ts.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | export function setNotEnumerableProperty(entity: object, property: string, value: T) {
4 | Object.defineProperty(entity, property, {
5 | enumerable: false,
6 | writable: false,
7 | value: value
8 | });
9 | }
10 |
--------------------------------------------------------------------------------
/config/clients/js/template/validation.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import { FgaRequiredParamError } from "./errors";
4 |
5 | /**
6 | *
7 | * @throws { FgaRequiredParamError }
8 | * @export
9 | */
10 | export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
11 | if (paramValue === null || paramValue === undefined) {
12 | throw new FgaRequiredParamError(functionName, paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
13 | }
14 | };
15 |
16 | /**
17 | *
18 | * @export
19 | */
20 | export const isWellFormedUriString = (uri: string): boolean => {
21 | try {
22 | const uriResult = new URL(uri);
23 | return ((uriResult.toString() === uri || uriResult.toString() === `${uri}/`) &&
24 | (uriResult.protocol === "https:" || uriResult.protocol === "http:"));
25 | } catch (err) {
26 | return false;
27 | }
28 | };
29 |
30 | export const isWellFormedUlidString = (ulid: string): boolean => {
31 | const regex = /^[0-7][0-9A-HJKMNP-TV-Z]{25}$/;
32 | return !!(typeof ulid === "string" && ulid.match(regex)?.length);
33 | };
34 |
--------------------------------------------------------------------------------
/config/clients/python/.openapi-generator-ignore:
--------------------------------------------------------------------------------
1 | git_push.sh
2 | test/*
3 | !test/__init__.py
4 | !test/test_open_fga_api.py
5 | !test/test_configuration.py
6 | !test/test_credentials.py
7 | !test/test_client.py
8 | !test/test_client_sync.py
9 | !test/test_open_fga_api_sync.py
10 | !test/test_validation.py
11 | !test/test_oauth2.py
12 | !test/test_oauth2_sync.py
13 | .github/workflows/python.yml
14 | .gitlab-ci.yml
15 | .travis.yml
16 | tox.ini
17 | setup.cfg
18 |
--------------------------------------------------------------------------------
/config/clients/python/generator.txt:
--------------------------------------------------------------------------------
1 | python-legacy
2 |
--------------------------------------------------------------------------------
/config/clients/python/template-source.json:
--------------------------------------------------------------------------------
1 | {
2 | "repo": "https://github.com/OpenAPITools/openapi-generator",
3 | "branch": "master",
4 | "commit": "fea42b547ed61dcfdfc479cab6f68a601ec5adde",
5 | "url": "https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python-legacy",
6 | "docs": "https://github.com/OpenAPITools/openapi-generator/blob/master/docs/generators/python-legacy.md"
7 | }
8 |
--------------------------------------------------------------------------------
/config/clients/python/template/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "pip"
4 | directory: "/"
5 | schedule:
6 | interval: "monthly"
7 | groups:
8 | dependencies:
9 | patterns:
10 | - "*"
11 | ignore:
12 | - dependency-name: "urllib3"
13 | - package-ecosystem: "pip"
14 | directory: "/example/example1"
15 | schedule:
16 | interval: "monthly"
17 | groups:
18 | dependencies:
19 | patterns:
20 | - "*"
21 | - package-ecosystem: "github-actions"
22 | directory: "/"
23 | schedule:
24 | interval: "monthly"
25 | groups:
26 | dependencies:
27 | patterns:
28 | - "*"
29 |
--------------------------------------------------------------------------------
/config/clients/python/template/.snyk:
--------------------------------------------------------------------------------
1 | language-settings:
2 | python: '3.10.6'
--------------------------------------------------------------------------------
/config/clients/python/template/README_api_endpoints.mustache:
--------------------------------------------------------------------------------
1 | Class | Method | HTTP request | Description
2 | ------------ | ------------- | ------------- | -------------
3 | {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}*{{classname}}* | [**{{operationId}}**]({{docPrefix}}{{apiDocPath}}{{classname}}.md#{{operationIdLowerCase}}) | **{{httpMethod}}** {{path}} | {{#summary}}{{summary}}{{/summary}}
4 | {{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
5 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_common.mustache:
--------------------------------------------------------------------------------
1 | {{>README_calling_api}}
2 |
3 | {{>README_api_endpoints}}
4 |
5 | {{>README_models}}
6 | ## Author
7 |
8 | {{#apiInfo}}{{#apis}}{{#-last}}{{infoEmail}}
9 | {{/-last}}{{/apis}}{{/apiInfo}}
10 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_custom_badges.mustache:
--------------------------------------------------------------------------------
1 | [](https://pypi.org/project/{{packageName}})
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_installation.mustache:
--------------------------------------------------------------------------------
1 | ### pip install
2 |
3 | #### PyPI
4 |
5 | The {{packageName}} is available to be downloaded via PyPI, you can install directly using:
6 |
7 | ```sh
8 | pip3 install {{packageName}}
9 | ```
10 | (you may need to run `pip` with root permission: `sudo pip3 install {{packageName}}`)
11 |
12 | Then import the package:
13 | ```python
14 | import {{{packageName}}}
15 | ```
16 |
17 | #### GitHub
18 |
19 | The {{packageName}} is also hosted in GitHub, you can install directly using:
20 |
21 | ```sh
22 | pip3 install https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git
23 | ```
24 | (you may need to run `pip` with root permission: `sudo pip3 install https://{{gitHost}}/{{{gitUserId}}}/{{{gitRepoId}}}.git`)
25 |
26 | Then import the package:
27 | ```python
28 | import {{{packageName}}}
29 | ```
30 |
31 | ### Setuptools
32 |
33 | Install via [Setuptools](https://pypi.python.org/pypi/setuptools).
34 |
35 | ```sh
36 | python setup.py install --user
37 | ```
38 | (or `sudo python setup.py install` to install the package for all users)
39 |
40 | Then import the package:
41 | ```python
42 | import {{{packageName}}}
43 | ```
44 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_license_disclaimer.mustache:
--------------------------------------------------------------------------------
1 | The code in this repo was auto generated by [OpenAPI Generator](https://github.com/OpenAPITools/openapi-generator) from a template based on the [python legacy template](https://github.com/OpenAPITools/openapi-generator/tree/master/modules/openapi-generator/src/main/resources/python-legacy), licensed under the [Apache License 2.0](https://github.com/OpenAPITools/openapi-generator/blob/master/LICENSE).
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_models.mustache:
--------------------------------------------------------------------------------
1 | ## Documentation For Models
2 |
3 | {{#models}}{{#model}} - [{{{classname}}}]({{docPrefix}}{{modelDocPath}}{{{classname}}}.md)
4 | {{/model}}{{/models}}
5 |
--------------------------------------------------------------------------------
/config/clients/python/template/README_retries.mustache:
--------------------------------------------------------------------------------
1 | If a network request fails with a 429 or 5xx error from the server, the SDK will automatically retry the request up to {{defaultMaxRetry}} times with a minimum wait time of {{defaultMinWaitInMs}} milliseconds between each attempt.
2 |
3 | To customize this behavior, create a `RetryParams` object and assign values to the `max_retry` and `min_wait_in_ms` constructor parameters. `max_retry` determines the maximum number of retries (up to {{retryMaxAllowedNumber}}), while `min_wait_in_ms` sets the minimum wait time between retries in milliseconds.
4 |
5 | Apply your custom retry values by passing the object to the `ClientConfiguration` constructor's `retry_params` parameter.
6 |
7 | ```python
8 | from {{packageName}} import ClientConfiguration, {{appShortName}}Client
9 | from {{packageName}}.configuration import RetryParams
10 | from os import environ
11 |
12 | async def main():
13 | # Configure the client with custom retry settings
14 | config = ClientConfiguration(
15 | api_url=environ.get("FGA_API_URL"),
16 | retry_params=RetryParams(max_retry=3, min_wait_in_ms=250)
17 | )
18 |
19 | # Create a client instance and read authorization models
20 | async with {{appShortName}}Client(config) as client:
21 | return await client.read_authorization_models()
22 | ```
23 |
--------------------------------------------------------------------------------
/config/clients/python/template/api.mustache:
--------------------------------------------------------------------------------
1 | {{>src/api.py}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/api_sync.mustache:
--------------------------------------------------------------------------------
1 | {{>src/sync/api.py}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/api_test.mustache:
--------------------------------------------------------------------------------
1 | {{>test/api_test.py}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/Makefile:
--------------------------------------------------------------------------------
1 | all: run
2 |
3 | project_name=example1
4 | openfga_version=latest
5 |
6 | setup:
7 | cd "${project_name}/" && pip3 install -r requirements.txt && cd -
8 |
9 | run: setup
10 | python3 "${project_name}/${project_name}.py"
11 |
12 | run-openfga:
13 | docker pull docker.io/openfga/openfga:${openfga_version} && \
14 | docker run -p 8080:8080 docker.io/openfga/openfga:${openfga_version} run
15 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/example1/requirements.txt.mustache:
--------------------------------------------------------------------------------
1 | aiohttp >= 3.9.2
2 | aiosignal >= 1.3.1
3 | attrs >= 23.1.0
4 | frozenlist >= 1.4.1
5 | idna >= 3.6
6 | multidict >= 6.0.4
7 | openfga-sdk >= {{packageVersion}}
8 | python-dateutil >= 2.8.2
9 | urllib3 >= 2.1.0
10 | yarl >= 1.9.4
11 | python-dotenv >= 1, <2
12 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/example1/setup.cfg:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length=99
3 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/example1/setup.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from setuptools import find_packages, setup
4 |
5 | NAME = "example1"
6 | VERSION = "0.0.1"
7 | REQUIRES = ["openfga-sdk >= {{packageVersion}}"]
8 |
9 | setup(
10 | name=NAME,
11 | version=VERSION,
12 | description="An example of using the OpenFGA Python SDK",
13 | author="OpenFGA (https://openfga.dev)",
14 | author_email="community@openfga.dev",
15 | url="https://github.com/openfga/python-sdk",
16 | install_requires=REQUIRES,
17 | python_requires=">={{pythonMinimumRuntime}}",
18 | packages=find_packages(exclude=["test", "tests"]),
19 | include_package_data=True,
20 | license="Apache-2.0",
21 | )
22 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/.env.example:
--------------------------------------------------------------------------------
1 | FGA_CLIENT_ID=
2 | FGA_API_TOKEN_ISSUER=
3 | FGA_API_AUDIENCE=
4 | FGA_CLIENT_SECRET=
5 | FGA_STORE_ID=
6 | FGA_AUTHORIZATION_MODEL_ID=
7 | FGA_API_URL="http://localhost:8080"
8 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/.gitignore:
--------------------------------------------------------------------------------
1 | .env
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/README.md:
--------------------------------------------------------------------------------
1 | # OpenTelemetry usage with OpenFGA's Python SDK
2 |
3 | This example demonstrates how you can use OpenTelemetry with OpenFGA's Python SDK.
4 |
5 | ## Prerequisites
6 |
7 | If you do not already have an OpenFGA instance running, you can start one using the following command:
8 |
9 | ```bash
10 | docker run -d -p 8080:8080 openfga/openfga
11 | ```
12 |
13 | You need to have an OpenTelemetry collector running to receive data. A pre-configured collector is available using Docker:
14 |
15 | ```bash
16 | git clone https://github.com/ewanharris/opentelemetry-collector-dev-setup.git
17 | cd opentelemetry-collector-dev-setup
18 | docker-compose up -d
19 | ```
20 |
21 | ## Configure the example
22 |
23 | You need to configure the example for your environment:
24 |
25 | ```bash
26 | cp .env.example .env
27 | ```
28 |
29 | Now edit the `.env` file and set the values as appropriate.
30 |
31 | ## Running the example
32 |
33 | Begin by installing the required dependencies:
34 |
35 | ```bash
36 | pip install -r requirements.txt
37 | ```
38 |
39 | Next, run the example:
40 |
41 | ```bash
42 | python main.py
43 | ```
44 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/requirements.txt:
--------------------------------------------------------------------------------
1 | python-dotenv >= 1, <2
2 | opentelemetry-sdk >= 1, <2
3 | opentelemetry-exporter-otlp-proto-grpc >= 1.25, <2
4 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/setup.cfg:
--------------------------------------------------------------------------------
1 | [flake8]
2 | max-line-length=99
3 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/opentelemetry/setup.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from setuptools import find_packages, setup
4 |
5 | NAME = "openfga-opentelemetry-example"
6 | VERSION = "0.0.1"
7 | REQUIRES = [""]
8 |
9 | setup(
10 | name=NAME,
11 | version=VERSION,
12 | description="An example of using the OpenFGA Python SDK with OpenTelemetry",
13 | author="OpenFGA (https://openfga.dev)",
14 | author_email="community@openfga.dev",
15 | url="https://github.com/openfga/python-sdk",
16 | python_requires=">={{pythonMinimumRuntime}}",
17 | packages=find_packages(exclude=["test", "tests"]),
18 | include_package_data=True,
19 | license="Apache-2.0",
20 | )
21 |
--------------------------------------------------------------------------------
/config/clients/python/template/example/streamed-list-objects/README.md:
--------------------------------------------------------------------------------
1 | # Streamed List Objects Example
2 |
3 | This example demonstrates working with [OpenFGA's `/streamed-list-objects` endpoint](https://openfga.dev/api/service#/Relationship%20Queries/StreamedListObjects) using the Python SDK's `streamed_list_objects()` method.
4 |
5 | ## Prerequisites
6 |
7 | - Python 3.10+
8 | - OpenFGA running on `localhost:8080`
9 |
10 | You can start OpenFGA with Docker by running the following command:
11 |
12 | ```bash
13 | docker pull openfga/openfga && docker run -it --rm -p 8080:8080 openfga/openfga run
14 | ```
15 |
16 | ## Running the example
17 |
18 | No additional setup is required to run this example. Simply run the following command:
19 |
20 | ```bash
21 | python example.py
22 | ```
23 |
--------------------------------------------------------------------------------
/config/clients/python/template/gitignore_custom.mustache:
--------------------------------------------------------------------------------
1 | # Byte-compiled / optimized / DLL files
2 | __pycache__/
3 | *.py[cod]
4 | *$py.class
5 | *.pyc
6 | openfga_sdk/__pycache__/
7 |
8 | # C extensions
9 | *.so
10 |
11 | # Distribution / packaging
12 | .Python
13 | env/
14 | build/
15 | develop-eggs/
16 | dist/
17 | downloads/
18 | eggs/
19 | .eggs/
20 | lib/
21 | lib64/
22 | parts/
23 | sdist/
24 | var/
25 | *.egg-info/
26 | .installed.cfg
27 | *.egg
28 |
29 | # PyInstaller
30 | # Usually these files are written by a python script from a template
31 | # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 | *.manifest
33 | *.spec
34 |
35 | # Installer logs
36 | pip-log.txt
37 | pip-delete-this-directory.txt
38 |
39 | # Unit test / coverage reports
40 | htmlcov/
41 | .tox/
42 | .coverage
43 | .coverage.*
44 | .cache
45 | nosetests.xml
46 | coverage.xml
47 | *,cover
48 | .hypothesis/
49 | venv/
50 | .venv/
51 | .python-version
52 | .pytest_cache
53 | .ruff_cache
54 | test/__pycache__/
55 |
56 | # Translations
57 | *.mo
58 | *.pot
59 |
60 | # Django stuff:
61 | *.log
62 |
63 | # Sphinx documentation
64 | docs/_build/
65 |
66 | # PyBuilder
67 | target/
68 |
69 | #Ipython Notebook
70 | .ipynb_checkpoints
71 |
72 | # Python tooling
73 | setup.local.cfg
74 |
--------------------------------------------------------------------------------
/config/clients/python/template/model_doc.mustache:
--------------------------------------------------------------------------------
1 | {{#models}}{{#model}}# {{classname}}
2 |
3 | {{#description}}{{&description}}
4 | {{/description}}
5 |
6 | ## Properties
7 | Name | Type | Description | Notes
8 | ------------ | ------------- | ------------- | -------------
9 | {{#vars}}**{{name}}** | {{#isPrimitiveType}}**{{dataType}}**{{/isPrimitiveType}}{{^isPrimitiveType}}[**{{dataType}}**]({{complexType}}.md){{/isPrimitiveType}} | {{description}} | {{^required}}[optional] {{/required}}{{#isReadOnly}}[readonly] {{/isReadOnly}}{{#defaultValue}}[default to {{{.}}}]{{/defaultValue}}
10 | {{/vars}}
11 |
12 | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)
13 |
14 | {{/model}}{{/models}}
15 |
--------------------------------------------------------------------------------
/config/clients/python/template/partial_header.mustache:
--------------------------------------------------------------------------------
1 | """
2 | {{#packageDescription}}
3 | {{{packageDescription}}}
4 |
5 | {{/packageDescription}}
6 | {{#version}}
7 | API version: {{{version}}}
8 | {{/version}}
9 | {{#websiteUrl}}
10 | Website: {{{websiteUrl}}}
11 | {{/websiteUrl}}
12 | {{#docsUrl}}
13 | Documentation: {{{docsUrl}}}
14 | {{/docsUrl}}
15 | {{#supportInfo}}
16 | Support: {{{supportInfo}}}
17 | {{/supportInfo}}
18 | {{#licenseId}}
19 | License: [{{{licenseId}}}](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/blob/main/LICENSE)
20 | {{/licenseId}}
21 |
22 | NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
23 | """
24 |
--------------------------------------------------------------------------------
/config/clients/python/template/python_doc_auth_partial.mustache:
--------------------------------------------------------------------------------
1 | # To configure the configuration
2 | # host is mandatory
3 | # api_scheme is optional and default to https
4 | {{#requiredParams}}
5 | {{#-first}}
6 | # store_id is mandatory
7 | {{/-first}}
8 | {{/requiredParams}}
9 | # See configuration.py for a list of all supported configuration parameters.
10 | configuration = {{{packageName}}}.Configuration(
11 | scheme = "https",
12 | api_host = "api.{{{sampleApiDomain}}}",
13 | {{#requiredParams}}
14 | {{#-first}}
15 | store_id = 'YOUR_STORE_ID',
16 | {{/-first}}
17 | {{/requiredParams}}
18 | )
19 |
20 |
21 | # When authenticating via the API TOKEN method
22 | credentials = Credentials(method='api_token', configuration=CredentialConfiguration(api_token='TOKEN1'))
23 | configuration = {{{packageName}}}.Configuration(
24 | scheme = "https",
25 | api_host = "api.{{{sampleApiDomain}}}",
26 | {{#requiredParams}}
27 | {{#-first}}
28 | store_id = 'YOUR_STORE_ID',
29 | {{/-first}}
30 | {{/requiredParams}}
31 | credentials = credentials
32 | )
33 |
--------------------------------------------------------------------------------
/config/clients/python/template/requirements.mustache:
--------------------------------------------------------------------------------
1 | aiohttp >= 3.9.3, < 4
2 | python-dateutil >= 2.9.0, < 3
3 | setuptools >= 69.1.1
4 | build >= 1.2.1, < 2
5 | urllib3 >= 1.26.19, < 3
6 | opentelemetry-api >= 1.25.0, < 2
7 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/api/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | {{#apiInfo}}{{#apis}}from {{apiPackage}}.{{classFilename}} import {{classname}}
4 | {{/apis}}{{/apiInfo}}
5 |
6 | __all__ = [
7 | {{#apiInfo}}{{#apis}}"{{classname}}",
8 | {{/apis}}{{/apiInfo}}
9 | ]
10 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/client/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.client.client import OpenFgaClient
4 | from {{packageName}}.client.configuration import ClientConfiguration
5 | from {{packageName}}.client.models.check_request import ClientCheckRequest
6 |
7 | __all__ = [
8 | "OpenFgaClient",
9 | "ClientConfiguration",
10 | "ClientCheckRequest",
11 | ]
12 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/client/models/batch_check_request.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.client.models.batch_check_item import ClientBatchCheckItem
4 |
5 |
6 | class ClientBatchCheckRequest:
7 | """
8 | ClientBatchCheckRequest encapsulates the parameters for a BatchCheck request
9 | """
10 |
11 | def __init__(
12 | self,
13 | checks: list[ClientBatchCheckItem],
14 | ) -> None:
15 | self._checks = checks
16 |
17 | @property
18 | def checks(self) -> list[ClientBatchCheckItem]:
19 | """
20 | Return checks
21 | """
22 | return self._checks
23 |
24 | @checks.setter
25 | def checks(self, checks: list[ClientBatchCheckItem]) -> None:
26 | """
27 | Set checks
28 | """
29 | self._checks = checks
30 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/client/models/batch_check_response.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.client.models.batch_check_single_response import ClientBatchCheckSingleResponse
4 |
5 |
6 | class ClientBatchCheckResponse:
7 | def __init__(
8 | self,
9 | result: list[ClientBatchCheckSingleResponse],
10 | ) -> None:
11 | self._result = result
12 |
13 | @property
14 | def result(self) -> list[ClientBatchCheckSingleResponse]:
15 | """
16 | Return result
17 | """
18 | return self._result
19 |
20 | @result.setter
21 | def result(self, result: list[ClientBatchCheckSingleResponse]) -> None:
22 | """
23 | Set result
24 | """
25 | self._result = result
26 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/client/models/read_changes_request.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | class ClientReadChangesRequest:
4 | """
5 | ClientReadChangesRequest encapsulates the parameters required to read changes
6 | """
7 |
8 | def __init__(
9 | self,
10 | type: str,
11 | start_time: str | None = None,
12 | ):
13 | self._type = type
14 | self._startTime = start_time
15 |
16 | @property
17 | def type(self) -> str:
18 | """
19 | Return type
20 | """
21 | return self._type
22 |
23 | @type.setter
24 | def type(
25 | self,
26 | value: str,
27 | ) -> None:
28 | """
29 | Set type
30 | """
31 | self._type = value
32 |
33 | @property
34 | def start_time(self) -> str | None:
35 | """
36 | Return startTime
37 | """
38 | return self._startTime
39 |
40 | @start_time.setter
41 | def start_time(
42 | self,
43 | value: str | None,
44 | ) -> None:
45 | """
46 | Set startTime
47 | """
48 | self._startTime = value
49 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/models/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 | {{#models}}{{#model}}from {{modelPackage}}.{{classFilename}} import {{classname}}{{/model}}
3 | {{/models}}
4 |
5 | __all__ = [
6 | {{#models}}{{#model}}"{{classname}}",
7 | {{/model}}{{/models}}
8 | ]
9 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/sync/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.sync.client.client import OpenFgaClient
4 | from {{packageName}}.sync.api_client import ApiClient
5 |
6 |
7 | __all__ = [
8 | "ApiClient",
9 | "OpenFgaClient",
10 | ]
11 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/sync/client/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/telemetry/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.telemetry.attributes import TelemetryAttribute, TelemetryAttributes
4 | from {{packageName}}.telemetry.configuration import (
5 | TelemetryConfiguration,
6 | TelemetryConfigurations,
7 | TelemetryConfigurationType,
8 | TelemetryMetricConfiguration,
9 | TelemetryMetricsConfiguration,
10 | )
11 | from {{packageName}}.telemetry.histograms import TelemetryHistogram, TelemetryHistograms
12 | from {{packageName}}.telemetry.metrics import TelemetryMetrics
13 | from {{packageName}}.telemetry.telemetry import Telemetry
14 |
15 |
16 | __all__ = [
17 | "Telemetry",
18 | "TelemetryAttribute",
19 | "TelemetryAttributes",
20 | "TelemetryConfiguration",
21 | "TelemetryConfigurations",
22 | "TelemetryConfigurationType",
23 | "TelemetryMetricConfiguration",
24 | "TelemetryMetricsConfiguration",
25 | "TelemetryHistogram",
26 | "TelemetryHistograms",
27 | "TelemetryMetrics",
28 | ]
29 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/telemetry/counters.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from typing import NamedTuple
4 |
5 |
6 | class TelemetryCounter(NamedTuple):
7 | name: str
8 | description: str
9 | unit: str = ""
10 |
11 |
12 | class TelemetryCounters:
13 | fga_client_credentials_request: TelemetryCounter = TelemetryCounter(
14 | name="fga-client.credentials.request",
15 | description="Total number of new token requests initiated using the Client Credentials flow.",
16 | )
17 |
18 | fga_client_request: TelemetryCounter = TelemetryCounter(
19 | name="fga-client.request",
20 | description="Total number of requests made to the FGA server.",
21 | )
22 |
23 | _counters: list[TelemetryCounter] = [
24 | fga_client_credentials_request,
25 | fga_client_request,
26 | ]
27 |
28 | @staticmethod
29 | def getAll() -> list[TelemetryCounter]:
30 | return TelemetryCounters._counters
31 |
32 | @staticmethod
33 | def get(
34 | name: str | None = None,
35 | ) -> TelemetryCounter | None:
36 | for counter in TelemetryCounters._counters:
37 | if counter.name == name:
38 | return counter
39 |
40 | return None
41 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/telemetry/histograms.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from typing import NamedTuple
4 |
5 |
6 | class TelemetryHistogram(NamedTuple):
7 | name: str
8 | description: str
9 | unit: str = "milliseconds"
10 |
11 |
12 | class TelemetryHistograms:
13 | fga_client_request_duration: TelemetryHistogram = TelemetryHistogram(
14 | name="fga-client.request.duration",
15 | description="Total request time for FGA requests, in milliseconds.",
16 | )
17 | fga_client_query_duration: TelemetryHistogram = TelemetryHistogram(
18 | name="fga-client.query.duration",
19 | description="Time taken by the FGA server to process and evaluate the request, in milliseconds.",
20 | )
21 |
22 | _histograms: list[TelemetryHistogram] = [
23 | fga_client_request_duration,
24 | fga_client_query_duration,
25 | ]
26 |
27 | @staticmethod
28 | def getAll() -> list[TelemetryHistogram]:
29 | return TelemetryHistograms._histograms
30 |
31 | @staticmethod
32 | def get(
33 | name: str | None = None,
34 | ) -> TelemetryHistogram | None:
35 | for histogram in TelemetryHistograms._histograms:
36 | if histogram.name == name:
37 | return histogram
38 |
39 | return None
40 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/telemetry/telemetry.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | from {{packageName}}.telemetry.metrics import TelemetryMetrics
4 |
5 |
6 | class Telemetry:
7 | _metrics: TelemetryMetrics | None = None
8 |
9 | @property
10 | def metrics(self) -> TelemetryMetrics:
11 | if self._metrics is None:
12 | self._metrics = TelemetryMetrics()
13 |
14 | return self._metrics
15 |
--------------------------------------------------------------------------------
/config/clients/python/template/src/validation.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
3 | import re
4 |
5 | def is_well_formed_ulid_string(ulid):
6 | regex = re.compile("^[0-7][0-9A-HJKMNP-TV-Z]{25}$")
7 | if not isinstance(ulid, str):
8 | return False
9 | match = regex.match(ulid)
10 | if match is None:
11 | return False
12 | return True
13 |
--------------------------------------------------------------------------------
/config/clients/python/template/test-requirements.mustache:
--------------------------------------------------------------------------------
1 | -r requirements.txt
2 |
3 | griffe >= 0.41.2, < 2
4 | mock >= 5.1.0, < 6
5 | pytest-asyncio >= 0.25, < 1
6 | pytest-cov >= 5, < 7
7 | ruff >= 0.9, < 1
8 | mypy >= 1.14.1, < 2
9 |
--------------------------------------------------------------------------------
/config/clients/python/template/test/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/test/api/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/test/client/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/test/sync/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/clients/python/template/test/sync/client/__init__.py.mustache:
--------------------------------------------------------------------------------
1 | {{>partial_header}}
2 |
--------------------------------------------------------------------------------
/config/common/files/.codecov.yml.mustache:
--------------------------------------------------------------------------------
1 | coverage:
2 | precision: 2
3 | range: "60...80"
4 | round: down
5 |
--------------------------------------------------------------------------------
/config/common/files/.fossa.yml.mustache:
--------------------------------------------------------------------------------
1 | version: 3
2 |
3 | server: https://app.fossa.com
4 |
5 | project:
6 | id: {{gitHost}}/{{gitUserId}}/{{gitRepoId}}
7 | name: {{gitHost}}/{{gitUserId}}/{{gitRepoId}}
8 | link: openfga.dev
9 | url: {{gitHost}}/{{gitUserId}}/{{gitRepoId}}
10 |
--------------------------------------------------------------------------------
/config/common/files/.github/CODEOWNERS.mustache:
--------------------------------------------------------------------------------
1 | * @{{gitUserId}}/dx
2 | README.md @{{gitUserId}}/product @{{gitUserId}}/community @{{gitUserId}}/dx
3 |
--------------------------------------------------------------------------------
/config/common/files/.github/ISSUE_TEMPLATE/config.yaml:
--------------------------------------------------------------------------------
1 | blank_issues_enabled: false
2 | contact_links:
3 | - name: 📖 OpenFGA's Documentation
4 | url: https://openfga.dev/docs
5 | about: Check OpenFGA's documentation for an in-depth overview
6 | - name: 👽 Community
7 | url: https://openfga.dev/community
8 | about: Join OpenFGA's community on Slack and GitHub Discussions
9 | - name: 📝 RFCs
10 | url: https://github.com/openfga/rfcs
11 | about: Check existing RFCs to understand where the project is headed
12 | - name: 💬 Discussions
13 | url: https://github.com/orgs/openfga/discussions
14 | about: Start a discussion about your authorization needs or questions
15 |
--------------------------------------------------------------------------------
/config/common/files/.github/dependabot.yaml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates: []
--------------------------------------------------------------------------------
/config/common/files/NOTICE.mustache:
--------------------------------------------------------------------------------
1 | {{packageDescription}}
2 | {{gitHost}}/{{gitUserId}}/{{gitRepoId}}
3 |
4 | {{{copyrightNotice}}}
5 |
6 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9 |
10 |
11 | --------------------------------------------------------------------------------
12 |
13 |
14 | {{>NOTICE_details}}
15 |
--------------------------------------------------------------------------------
/config/common/files/README_custom_badges.mustache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openfga/sdk-generator/d545d99d5ca559d36bf7b0ac79b8172ad17bb7e4/config/common/files/README_custom_badges.mustache
--------------------------------------------------------------------------------
/config/common/files/README_project_introduction.mustache:
--------------------------------------------------------------------------------
1 | [{{appName}}]({{websiteUrl}}) is an open source Fine-Grained Authorization solution inspired by [Google's Zanzibar paper](https://research.google/pubs/pub48190/). It was created by the FGA team at [Auth0](https://auth0.com) based on [Auth0 Fine-Grained Authorization (FGA)](https://fga.dev), available under [a permissive license (Apache-2)](https://{{gitHost}}/{{gitUserId}}/rfcs/blob/main/LICENSE) and welcomes community contributions.
2 |
3 | {{appName}} is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. {{appName}}’s design is optimized for reliability and low latency at a high scale.
4 |
--------------------------------------------------------------------------------
/config/common/files/README_retries.mustache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openfga/sdk-generator/d545d99d5ca559d36bf7b0ac79b8172ad17bb7e4/config/common/files/README_retries.mustache
--------------------------------------------------------------------------------
/config/common/files/VERSION.mustache:
--------------------------------------------------------------------------------
1 | {{packageVersion}}
2 |
--------------------------------------------------------------------------------
/config/common/files/assets/FGAIcon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/openfga/sdk-generator/d545d99d5ca559d36bf7b0ac79b8172ad17bb7e4/config/common/files/assets/FGAIcon.png
--------------------------------------------------------------------------------
/config/common/files/gitignore.mustache:
--------------------------------------------------------------------------------
1 | {{>gitignore_custom}}
2 |
3 | # IDEs
4 | .idea
5 | .vscode
6 | .sublime-workspace
7 | .sublime-project
8 | .idea/
9 | .vscode/
10 |
11 | # Possible credential files
12 | .env
13 | credentials.json
14 |
15 | # git conflict leftover files
16 | *.orig
17 |
18 | # Mac
19 | .DS_Store
20 |
21 | VERSION.txt
22 | git_push.sh
23 |
--------------------------------------------------------------------------------
/config/common/files/partial_header.mustache:
--------------------------------------------------------------------------------
1 | /**
2 | {{#packageDescription}}
3 | * {{{packageDescription}}}
4 | *
5 | {{/packageDescription}}
6 | {{#version}}
7 | * API version: {{{version}}}
8 | {{/version}}
9 | {{#websiteUrl}}
10 | * Website: {{{websiteUrl}}}
11 | {{/websiteUrl}}
12 | {{#docsUrl}}
13 | * Documentation: {{{docsUrl}}}
14 | {{/docsUrl}}
15 | {{#supportInfo}}
16 | * Support: {{{supportInfo}}}
17 | {{/supportInfo}}
18 | {{#licenseId}}
19 | * License: [{{{licenseId}}}](https://{{gitHost}}/{{gitUserId}}/{{gitRepoId}}/blob/main/LICENSE)
20 | {{/licenseId}}
21 | *
22 | * NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
23 | */
24 |
--------------------------------------------------------------------------------
/docker/nuget.Dockerfile:
--------------------------------------------------------------------------------
1 | FROM mono
2 |
3 | RUN mozroots --import --sync
4 | RUN nuget update -self
5 |
6 | WORKDIR /data
7 |
8 | ENTRYPOINT ["nuget"]
9 | CMD ["help"]
10 |
--------------------------------------------------------------------------------