Merge pull request #1267 from Infisical/sdk/docs-update-2

Sdk/docs update 2
This commit is contained in:
Daniel Hougaard
2023-12-24 21:57:52 +04:00
committed by GitHub
4 changed files with 90 additions and 22 deletions
+15 -1
View File
@@ -19,6 +19,7 @@ public class Example {
ClientSettings settings = new ClientSettings(); ClientSettings settings = new ClientSettings();
settings.setClientID("MACHINE_IDENTITY_CLIENT_ID"); settings.setClientID("MACHINE_IDENTITY_CLIENT_ID");
settings.setClientSecret("MACHINE_IDENTITY_CLIENT_SECRET"); settings.setClientSecret("MACHINE_IDENTITY_CLIENT_SECRET");
settings.setCacheTTL(Long.valueOf(300)); // 300 seconds, 5 minutes
InfisicalClient client = new InfisicalClient(settings); InfisicalClient client = new InfisicalClient(settings);
@@ -88,6 +89,11 @@ public class App {
An access token obtained from the machine identity login endpoint. An access token obtained from the machine identity login endpoint.
</ParamField> </ParamField>
<ParamField query="setCacheTTL()" type="number" default="300" optional>
Time-to-live (in seconds) for refreshing cached secrets.
If manually set to 0, caching will be disabled, this is not recommended.
</ParamField>
<ParamField query="setSiteURL()" type="string" default="https://app.infisical.com" optional> <ParamField query="setSiteURL()" type="string" default="https://app.infisical.com" optional>
Your self-hosted absolute site URL including the protocol (e.g. `https://app.infisical.com`) Your self-hosted absolute site URL including the protocol (e.g. `https://app.infisical.com`)
</ParamField> </ParamField>
@@ -95,6 +101,10 @@ public class App {
</ParamField> </ParamField>
### Caching
To reduce the number of API requests, the SDK temporarily stores secrets it retrieves. By default, a secret remains cached for 5 minutes after it's first fetched. Each time it's fetched again, this 5-minute timer resets. You can adjust this caching duration by setting the "cacheTTL" option when creating the client.
## Working with Secrets ## Working with Secrets
### client.listSecrets(options) ### client.listSecrets(options)
@@ -127,7 +137,11 @@ Retrieve all secrets within the Infisical project and environment that client is
The path from where secrets should be fetched from. The path from where secrets should be fetched from.
</ParamField> </ParamField>
<ParamField query="setIncludeImports" type="string" default="https://app.infisical.com" optional> <ParamField query="setAttachToProcessEnv()" type="boolean" default="false" optional>
Whether or not to set the fetched secrets to the process environment. If true, you can access the secrets like so `System.getenv("SECRET_NAME")`.
</ParamField>
<ParamField query="setIncludeImports()" type="boolean" default="false" optional>
Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference) Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference)
</ParamField> </ParamField>
</Expandable> </Expandable>
+15 -1
View File
@@ -104,6 +104,11 @@ Import the SDK and create a client instance with your [Machine Identity](/docume
An access token obtained from the machine identity login endpoint. An access token obtained from the machine identity login endpoint.
</ParamField> </ParamField>
<ParamField query="cacheTtl" type="number" default="300" optional>
Time-to-live (in seconds) for refreshing cached secrets.
If manually set to 0, caching will be disabled, this is not recommended.
</ParamField>
<ParamField query="siteUrl" type="string" default="https://app.infisical.com" optional> <ParamField query="siteUrl" type="string" default="https://app.infisical.com" optional>
Your self-hosted absolute site URL including the protocol (e.g. `https://app.infisical.com`) Your self-hosted absolute site URL including the protocol (e.g. `https://app.infisical.com`)
</ParamField> </ParamField>
@@ -113,6 +118,11 @@ Import the SDK and create a client instance with your [Machine Identity](/docume
</Expandable> </Expandable>
</ParamField> </ParamField>
### Caching
To reduce the number of API requests, the SDK temporarily stores secrets it retrieves. By default, a secret remains cached for 5 minutes after it's first fetched. Each time it's fetched again, this 5-minute timer resets. You can adjust this caching duration by setting the "cacheTtl" option when creating the client.
## Working with Secrets ## Working with Secrets
### client.listSecrets(options) ### client.listSecrets(options)
@@ -143,7 +153,11 @@ Retrieve all secrets within the Infisical project and environment that client is
The path from where secrets should be fetched from. The path from where secrets should be fetched from.
</ParamField> </ParamField>
<ParamField query="includeImports" type="string" default="https://app.infisical.com" optional> <ParamField query="attachToProcessEnv" type="boolean" default="false" optional>
Whether or not to set the fetched secrets to the process environment. If true, you can access the secrets like so `process.env["SECRET_NAME"]`.
</ParamField>
<ParamField query="includeImports" type="false" default="boolean" optional>
Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference) Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference)
</ParamField> </ParamField>
</Expandable> </Expandable>
+40 -20
View File
@@ -62,24 +62,40 @@ client = InfisicalClient(ClientSettings(
### Parameters ### Parameters
<ParamField query="client_id" type="string" optional> <ParamField query="options" type="object">
Your Infisical Client ID. <Expandable title="properties">
</ParamField> <ParamField query="client_id" type="string" optional>
<ParamField query="client_secret" type="string" optional> Your Infisical Client ID.
Your Infisical Client Secret. </ParamField>
</ParamField> <ParamField query="client_secret" type="string" optional>
<ParamField query="access_token" type="string" optional> Your Infisical Client Secret.
If you want to directly pass an access token obtained from the authentication endpoints, you can do so. </ParamField>
</ParamField> <ParamField query="access_token" type="string" optional>
<ParamField If you want to directly pass an access token obtained from the authentication endpoints, you can do so.
query="site_url" </ParamField>
type="string"
default="https://app.infisical.com" <ParamField query="cache_ttl" type="number" default="300" optional>
optional Time-to-live (in seconds) for refreshing cached secrets.
> If manually set to 0, caching will be disabled, this is not recommended.
Your self-hosted absolute site URL including the protocol (e.g. </ParamField>
`https://app.infisical.com`)
</ParamField>
<ParamField
query="site_url"
type="string"
default="https://app.infisical.com"
optional
>
Your self-hosted absolute site URL including the protocol (e.g.
`https://app.infisical.com`)
</ParamField>
</Expandable>
</ParamField>
### Caching
To reduce the number of API requests, the SDK temporarily stores secrets it retrieves. By default, a secret remains cached for 5 minutes after it's first fetched. Each time it's fetched again, this 5-minute timer resets. You can adjust this caching duration by setting the "cache_ttl" option when creating the client.
## Working with Secrets ## Working with Secrets
@@ -109,7 +125,11 @@ Retrieve all secrets within the Infisical project and environment that client is
The path from where secrets should be fetched from. The path from where secrets should be fetched from.
</ParamField> </ParamField>
<ParamField query="include_imports" type="string" default="https://app.infisical.com" optional> <ParamField query="attach_to_process_env" type="boolean" default="false" optional>
Whether or not to set the fetched secrets to the process environment. If true, you can access the secrets like so `process.env["SECRET_NAME"]`.
</ParamField>
<ParamField query="include_imports" type="boolean" default="false" optional>
Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference) Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference)
</ParamField> </ParamField>
</Expandable> </Expandable>
@@ -148,7 +168,7 @@ By default, `getSecret()` fetches and returns a shared secret. If not found, it
<ParamField query="type" type="string" optional> <ParamField query="type" type="string" optional>
The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "personal". The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "personal".
</ParamField> </ParamField>
<ParamField query="include_imports" type="string" default="https://app.infisical.com" optional> <ParamField query="include_imports" type="boolean" default="false" optional>
Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference) Whether or not to include imported secrets from the current path. Read about [secret import](/documentation/platform/secret-reference)
</ParamField> </ParamField>
</Expandable> </Expandable>
+20
View File
@@ -31,3 +31,23 @@ From local development to production, Infisical SDKs provide the easiest way for
Manage secrets for your PHP application on demand Manage secrets for your PHP application on demand
</Card> </Card>
</CardGroup> </CardGroup>
## FAQ
<AccordionGroup>
<Accordion title="Isn't it inefficient if my app makes a request every time it needs a secret?">
The client SDK caches every secret and implements a 5-minute waiting period before re-requesting it. The waiting period can be controlled by
setting the `cacheTTL` parameter at the time of initializing the client.
Note: The exact parameter name may differ depending on the language.
</Accordion>
<Accordion title="Can I attach the environment variables to my process environment?">
Yes you can! The client SDK provides a method to attach the secrets to your process environment. When using the `listSecrets()` method, you
can pass a `attachToProcessEnv` parameter, which tells the SDK to attach all the found secrets to your process environment.
Note: The exact parameter name may differ depending on the language.
</Accordion>
<Accordion title="What if a request for a secret fails?">
The SDK caches every secret and falls back to the cached value if a request fails. If no cached value is found, and the request fails, then the SDK throws an error.
</Accordion>
</AccordionGroup>