diff --git a/docs/sdks/languages/go.mdx b/docs/sdks/languages/go.mdx index a8affa154..2d5164b36 100644 --- a/docs/sdks/languages/go.mdx +++ b/docs/sdks/languages/go.mdx @@ -25,15 +25,10 @@ import ( func main() { - client, err := infisical.NewInfisicalClient(infisical.Config{ + client := infisical.NewInfisicalClient(infisical.Config{ SiteUrl: "https://app.infisical.com", // Optional, default is https://app.infisical.com }) - if err != nil { - fmt.Printf("Error: %v", err) - os.Exit(1) - } - _, err = client.Auth().UniversalAuthLogin("YOUR_CLIENT_ID", "YOUR_CLIENT_SECRET") if err != nil { @@ -74,14 +69,9 @@ $ go get github.com/infisical/go-sdk Import the SDK and create a client instance. ```go -client, err := infisical.NewInfisicalClient(infisical.Config{ +client := infisical.NewInfisicalClient(infisical.Config{ SiteUrl: "https://app.infisical.com", // Optional, default is https://api.infisical.com }) - -if err != nil { - fmt.Printf("Error: %v", err) - os.Exit(1) -} ``` ### ClientSettings methods @@ -435,4 +425,146 @@ Delete a secret in Infisical. The type of the secret. Valid options are "shared" or "personal". If not specified, the default value is "shared". + + +## Working with folders + + +### client.Folders().List(options) + +```go +folders, err := client.Folders().List(infisical.ListFoldersOptions{ + ProjectID: "PROJECT_ID", + Environment: "dev", + Path: "/", +}) +``` + +Retrieve all within the Infisical project and environment that client is connected to. + +#### Parameters + + + + + The slug name (dev, prod, etc) of the environment from where folders should be fetched from. + + + + The project ID where the folder lives in. + + + + The path from where folders should be fetched from. + + + + + +### client.Folders().Create(options) + +```go +folder, err := client.Folders().Create(infisical.CreateFolderOptions{ + ProjectID: "PROJECT_ID", + Name: "new=folder-name", + Environment: "dev", + Path: "/", +}) +``` + +Create a new folder in Infisical. + +#### Parameters + + + + + The ID of the project where the folder will be created. + + + The slug name (dev, prod, etc) of the environment where the folder will be created. + + + The path to create the folder in. The root path is `/`. + + + The name of the folder to create. + + + + + + +### client.Folders().Update(options) + +```go +folder, err := client.Folders().Update(infisical.UpdateFolderOptions{ + ProjectID: "PROJECT_ID", + Environment: "dev", + Path: "/", + FolderID: "FOLDER_ID_TO_UPDATE", + NewName: "new-folder-name", +}) +``` + +Update an existing folder in Infisical. + +#### Parameters + + + + + The ID of the project where the folder will be updated. + + + The slug name (dev, prod, etc) of the environment from where the folder lives in. + + + The path from where the folder should be updated. + + + The ID of the folder to update. + + + The new name of the folder. + + + + +### client.Folders().Delete(options) + +```go +deletedFolder, err := client.Folders().Delete(infisical.DeleteFolderOptions{ + // Either folder ID or folder name is required. + FolderName: "name-of-folder-to-delete", + FolderID: "folder-id-to-delete", + ProjectID: "PROJECT_ID", + Environment: "dev", + Path: "/", +}) +``` + +Delete a folder in Infisical. + +#### Parameters + + + + + The name of the folder to delete. Note that either `FolderName` or `FolderID` is required. + + + The ID of the folder to delete. Note that either `FolderName` or `FolderID` is required. + + + + The ID of the project where the folder lives in. + + + The slug name (dev, prod, etc) of the environment from where the folder lives in. + + + The path from where the folder should be deleted. + + \ No newline at end of file