mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Update go.mdx
This commit is contained in:
@@ -11,7 +11,7 @@ If you're working with Go Lang, the official [Infisical Go SDK](https://github.c
|
||||
- [Package](https://pkg.go.dev/github.com/infisical/go-sdk)
|
||||
- [Github Repository](https://github.com/infisical/go-sdk)
|
||||
|
||||
## Basic Usage
|
||||
# Basic Usage
|
||||
|
||||
```go
|
||||
package main
|
||||
@@ -66,7 +66,40 @@ This example demonstrates how to use the Infisical Go SDK in a simple Go applica
|
||||
$ go get github.com/infisical/go-sdk
|
||||
```
|
||||
|
||||
## Automatic token refreshing
|
||||
# Configuration
|
||||
|
||||
Import the SDK and create a client instance.
|
||||
|
||||
```go
|
||||
client := infisical.NewInfisicalClient(context.Background(), infisical.Config{
|
||||
SiteUrl: "https://app.infisical.com", // Optional, default is https://api.infisical.com
|
||||
})
|
||||
```
|
||||
|
||||
### Configuration Options
|
||||
|
||||
<ParamField query="options" type="object">
|
||||
<Expandable title="properties">
|
||||
<ParamField query="SiteUrl" type="string" optional default="https://app.infisical.com">
|
||||
The URL of the Infisical API..
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="UserAgent" type="string">
|
||||
Optionally set the user agent that will be used for HTTP requests. _(Not recommended)_
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="AutoTokenRefresh" type="boolean" default={true} optional>
|
||||
Whether or not to let the SDK handle the access token lifecycle. Defaults to true if not specified.
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="SilentMode" type="boolean" default={false} optional>
|
||||
Whether or not to suppress logs such as warnings from the token refreshing process. Defaults to false if not specified.
|
||||
</ParamField>
|
||||
</Expandable>
|
||||
|
||||
</ParamField>
|
||||
|
||||
# Automatic token refreshing
|
||||
|
||||
The Infisical Go SDK supports automatic token refreshing. After using one of the auth methods such as Universal Auth, the SDK will automatically renew and re-authenticate when needed.
|
||||
This behavior is enabled by default, but you can opt-out by setting `AutoTokenRefresh` to `false` in the client settings.
|
||||
@@ -93,41 +126,7 @@ When using automatic token refreshing it's important to understand how your appl
|
||||
This is only necessary if you are creating multiple instances of the client, and those instances are deleted or otherwise removed throughout the application lifecycle.
|
||||
If you are only creating one instance of the client, and it will be used throughout the lifetime of your application, you don't need to worry about this.
|
||||
|
||||
|
||||
# Configuration
|
||||
|
||||
Import the SDK and create a client instance.
|
||||
|
||||
```go
|
||||
client := infisical.NewInfisicalClient(context.Background(), infisical.Config{
|
||||
SiteUrl: "https://app.infisical.com", // Optional, default is https://api.infisical.com
|
||||
})
|
||||
```
|
||||
|
||||
### ClientSettings methods
|
||||
|
||||
<ParamField query="options" type="object">
|
||||
<Expandable title="properties">
|
||||
<ParamField query="SiteUrl" type="string" optional default="https://app.infisical.com">
|
||||
The URL of the Infisical API..
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="UserAgent" type="string">
|
||||
Optionally set the user agent that will be used for HTTP requests. _(Not recommended)_
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="AutoTokenRefresh" type="boolean" default={true} optional>
|
||||
Whether or not to let the SDK handle the access token lifecycle. Defaults to true if not specified.
|
||||
</ParamField>
|
||||
|
||||
<ParamField query="SilentMode" type="boolean" default={false} optional>
|
||||
Whether or not to suppress logs such as warnings from the token refreshing process. Defaults to false if not specified.
|
||||
</ParamField>
|
||||
</Expandable>
|
||||
|
||||
</ParamField>
|
||||
|
||||
### Authentication
|
||||
# Authentication
|
||||
|
||||
The SDK supports a variety of authentication methods. The most common authentication method is Universal Auth, which uses a client ID and client secret to authenticate.
|
||||
|
||||
@@ -260,9 +259,12 @@ if err != nil {
|
||||
}
|
||||
```
|
||||
|
||||
## Working with Secrets
|
||||
## Working With Secrets
|
||||
|
||||
### client.Secrets().List(options)
|
||||
### List Secrets
|
||||
`client.Secrets().List(options)`
|
||||
|
||||
Retrieve all secrets within the Infisical project and environment that client is connected to.
|
||||
|
||||
```go
|
||||
secrets, err := client.Secrets().List(infisical.ListSecretsOptions{
|
||||
@@ -273,9 +275,7 @@ secrets, err := client.Secrets().List(infisical.ListSecretsOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Retrieve all secrets within the Infisical project and environment that client is connected to
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object">
|
||||
<Expandable title="properties">
|
||||
@@ -310,7 +310,11 @@ Retrieve all secrets within the Infisical project and environment that client is
|
||||
|
||||
</ParamField>
|
||||
|
||||
### client.Secrets().Retrieve(options)
|
||||
###
|
||||
### Retrieve Secret
|
||||
`client.Secrets().Retrieve(options)`
|
||||
|
||||
Retrieve a secret from Infisical. By default `Secrets().Retrieve()` fetches and returns a shared secret.
|
||||
|
||||
```go
|
||||
secret, err := client.Secrets().Retrieve(infisical.RetrieveSecretOptions{
|
||||
@@ -320,11 +324,7 @@ secret, err := client.Secrets().Retrieve(infisical.RetrieveSecretOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Retrieve a secret from Infisical.
|
||||
|
||||
By default, `Secrets().Retrieve()` fetches and returns a shared secret.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -346,7 +346,11 @@ By default, `Secrets().Retrieve()` fetches and returns a shared secret.
|
||||
</Expandable>
|
||||
</ParamField>
|
||||
|
||||
### client.Secrets().Create(options)
|
||||
###
|
||||
### Create Secret
|
||||
`client.Secrets().Create(options)`
|
||||
|
||||
Create a new secret in Infisical.
|
||||
|
||||
```go
|
||||
secret, err := client.Secrets().Create(infisical.CreateSecretOptions{
|
||||
@@ -359,9 +363,8 @@ secret, err := client.Secrets().Create(infisical.CreateSecretOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Create a new secret in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -389,7 +392,12 @@ Create a new secret in Infisical.
|
||||
</Expandable>
|
||||
</ParamField>
|
||||
|
||||
### client.Secrets().Update(options)
|
||||
###
|
||||
### Update Secret
|
||||
|
||||
`client.Secrets().Update(options)`
|
||||
|
||||
Update an existing secret in Infisical.
|
||||
|
||||
```go
|
||||
secret, err := client.Secrets().Update(infisical.UpdateSecretOptions{
|
||||
@@ -401,9 +409,7 @@ secret, err := client.Secrets().Update(infisical.UpdateSecretOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Update an existing secret in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -431,7 +437,11 @@ Update an existing secret in Infisical.
|
||||
</Expandable>
|
||||
</ParamField>
|
||||
|
||||
### client.Secrets().Delete(options)
|
||||
###
|
||||
### Delete Secret
|
||||
`client.Secrets().Delete(options)`
|
||||
|
||||
Delete a secret in Infisical.
|
||||
|
||||
```go
|
||||
secret, err := client.Secrets().Delete(infisical.DeleteSecretOptions{
|
||||
@@ -441,9 +451,7 @@ secret, err := client.Secrets().Delete(infisical.DeleteSecretOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Delete a secret in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -465,10 +473,14 @@ Delete a secret in Infisical.
|
||||
</Expandable>
|
||||
</ParamField>
|
||||
|
||||
## Working with folders
|
||||
## Working With folders
|
||||
|
||||
|
||||
### client.Folders().List(options)
|
||||
###
|
||||
### List Folders
|
||||
`client.Folders().List(options)`
|
||||
|
||||
Retrieve all within the Infisical project and environment that client is connected to.
|
||||
|
||||
```go
|
||||
folders, err := client.Folders().List(infisical.ListFoldersOptions{
|
||||
@@ -478,9 +490,7 @@ folders, err := client.Folders().List(infisical.ListFoldersOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Retrieve all within the Infisical project and environment that client is connected to.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object">
|
||||
<Expandable title="properties">
|
||||
@@ -499,7 +509,11 @@ Retrieve all within the Infisical project and environment that client is connect
|
||||
|
||||
</ParamField>
|
||||
|
||||
### client.Folders().Create(options)
|
||||
###
|
||||
### Create Folder
|
||||
`client.Folders().Create(options)`
|
||||
|
||||
Create a new folder in Infisical.
|
||||
|
||||
```go
|
||||
folder, err := client.Folders().Create(infisical.CreateFolderOptions{
|
||||
@@ -510,9 +524,7 @@ folder, err := client.Folders().Create(infisical.CreateFolderOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Create a new folder in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -532,8 +544,11 @@ Create a new folder in Infisical.
|
||||
</ParamField>
|
||||
|
||||
|
||||
###
|
||||
### Update Folder
|
||||
`client.Folders().Update(options)`
|
||||
|
||||
### client.Folders().Update(options)
|
||||
Update an existing folder in Infisical.
|
||||
|
||||
```go
|
||||
folder, err := client.Folders().Update(infisical.UpdateFolderOptions{
|
||||
@@ -545,9 +560,7 @@ folder, err := client.Folders().Update(infisical.UpdateFolderOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Update an existing folder in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
@@ -569,7 +582,11 @@ Update an existing folder in Infisical.
|
||||
</Expandable>
|
||||
</ParamField>
|
||||
|
||||
### client.Folders().Delete(options)
|
||||
###
|
||||
### Delete Folder
|
||||
`client.Folders().Delete(options)`
|
||||
|
||||
Delete a folder in Infisical.
|
||||
|
||||
```go
|
||||
deletedFolder, err := client.Folders().Delete(infisical.DeleteFolderOptions{
|
||||
@@ -582,9 +599,7 @@ deletedFolder, err := client.Folders().Delete(infisical.DeleteFolderOptions{
|
||||
})
|
||||
```
|
||||
|
||||
Delete a folder in Infisical.
|
||||
|
||||
#### Parameters
|
||||
### Parameters
|
||||
|
||||
<ParamField query="Parameters" type="object" optional>
|
||||
<Expandable title="properties">
|
||||
|
||||
Reference in New Issue
Block a user