From 0ccca3061bce9aca20fd74b38cef5ca4ef759c83 Mon Sep 17 00:00:00 2001 From: "promptless[bot]" Date: Mon, 19 Oct 2026 17:02:36 +0000 Subject: [PATCH 1/2] docs: fix Go SDK documentation accuracy issues --- README-v1.md | 93 +++++++++--------- README.md | 165 ++++++++++++++++++-------------- docs/advanced_initialization.md | 16 +++- docs/api_reference.md | 4 +- docs/auth_credentials.md | 6 +- docs/migrate_to_v2.md | 6 +- 6 files changed, 159 insertions(+), 131 deletions(-) diff --git a/README-v1.md b/README-v1.md index d57c223..a4b1228 100644 --- a/README-v1.md +++ b/README-v1.md @@ -149,12 +149,12 @@ var upsertOption = common.UpsertOptions{Table:"",Column:"", "" +record1["ids"] = []interface{}{ // List of SkyflowID's of the records to be fetched + "", "", } record1["table"] = "" // name of table holding the above skyflow_id's record1["redaction"] = common.PLAIN_TEXT // redaction to be applied to retrieved data @@ -545,8 +545,8 @@ func main() { var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) - record1["ids"] = [] string {} { - "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9" + record1["ids"] = []interface{}{ + "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9", } record1["table"] = "cards" record1["redaction"] = common.PLAIN_TEXT @@ -555,7 +555,7 @@ func main() { recordsArray = append(recordsArray, record1) records["records"] = recordsArray - res, err: = skyflowClient.GetById(records) + res, err := skyflowClient.GetById(records) if err == nil { fmt.Println("Records:",res.Records) @@ -620,8 +620,8 @@ import ( var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) -record1["ids"] = [] string {} { // List of SkyflowID's of the records to be fetched - "", "" +record1["ids"] = []interface{}{ // List of SkyflowID's of the records to be fetched + "", "", } record1["table"] = "" // Name of table holding the records in the vault. record1["redaction"] = common.PLAIN_TEXT // Redaction type to apply to retrieved data. @@ -646,8 +646,8 @@ import ( var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) -record1["ids"] = [] string {} { // List of SkyflowID's of the records to be fetched - "", "" +record1["ids"] = []interface{}{ // List of SkyflowID's of the records to be fetched + "", "", } record1["table"] = "" // // Name of table holding the records in the vault. @@ -670,8 +670,8 @@ import ( var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) -record1["columnValues"] = [] string {} { // List of given unique column values. - "", "" +record1["columnValues"] = []interface{}{ // List of given unique column values. + "", "", } record1["columnName"] = "" // Unique column name in the vault. record1["redaction"] = common.PLAIN_TEXT @@ -710,14 +710,14 @@ func main() { var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) - record1["ids"] = [] string {} { - "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9" + record1["ids"] = []interface{}{ + "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9", } record1["table"] = "cards" record1["redaction"] = common.PLAIN_TEXT var record2 = make(map[string] interface {}) - record2["ids"] = [] string {} { "invalid-id" } + record2["ids"] = []interface{}{ "invalid-id" } record2["table"] = "cards" record2["redaction"] = common.PLAIN_TEXT @@ -727,7 +727,7 @@ func main() { records["records"] = recordsArray - res, err: = skyflowClient.Get(records) + res, err := skyflowClient.Get(records) if err == nil { fmt.Println("Records:",res.Records) @@ -789,13 +789,13 @@ func main() { var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) - record1["ids"] = [] string {} { - "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9" + record1["ids"] = []interface{}{ + "f8d8a622-b557-4c6b-a12c-c5ebe0b0bfd9", "da26de53-95d5-4bdb-99db-8d8c66a35ff9", } record1["table"] = "cards" var record2 = make(map[string] interface {}) - record2["ids"] = [] string {} { "Invalid Skyflow ID" } + record2["ids"] = []interface{}{ "Invalid Skyflow ID" } record2["table"] = "cards" var recordsArray[] interface {} @@ -804,7 +804,7 @@ func main() { records["records"] = recordsArray - res, err: = skyflowClient.Get(records, common.GetOptions{Tokens: true}) + res, err := skyflowClient.Get(records, common.GetOptions{Tokens: true}) if err == nil { fmt.Println("Records:",res.Records) @@ -865,15 +865,15 @@ func main() { var records = make(map[string] interface {}) var record1 = make(map[string] interface {}) - record1["columnValues"] = [] string {} { - "123455432112345", "123455432112346" + record1["columnValues"] = []interface{}{ + "123455432112345", "123455432112346", } record1["columnName"] = "bank_account_number" record1["table"] = "account_details" record1["redaction"] = common.PLAIN_TEXT var record2 = make(map[string] interface {}) - record2["columnValues"] = [] string {} { "Invalid Skyflow column value" } + record2["columnValues"] = []interface{}{ "Invalid Skyflow column value" } record1["columnName"] = "bank_account_number" record2["table"] = "account_details" record2["redaction"] = common.PLAIN_TEXT @@ -885,7 +885,7 @@ func main() { records["records"] = recordsArray - res, err: = skyflowClient.Get(records) + res, err := skyflowClient.Get(records) if err == nil { fmt.Println("Records:",res.Records) @@ -972,6 +972,7 @@ An [example](https://github.com/skyflowapi/skyflow-go/blob/main/samples/v1/vault package main import ( + "encoding/json" "fmt" Skyflow "github.com/skyflowapi/skyflow-go/skyflow/client" "github.com/skyflowapi/skyflow-go/skyflow/common" @@ -985,17 +986,17 @@ func main() { pathParams["card_number"] = "1852-344-234-34251" requestHeader := make(map[string]string) - requestHeaders["Authorization"] = "" + requestHeader["Authorization"] = "" requestBody := make(map[string]interface{}) requestBody["expirationDate"] = "12/2026" - connectionConfig := common.ConnectionConfig{ConnectionURL : "",MethodName : "",PathParams : pathParams, RequestBody : requestBody, RequestHeaders : requestHeader} + connectionConfig := common.ConnectionConfig{ConnectionURL : "", MethodName : common.POST, PathParams : pathParams, RequestBody : requestBody, RequestHeader : requestHeader} - res, err: = skyflowClient.InvokeConnection(connectionConfig) + res, err := skyflowClient.InvokeConnection(connectionConfig) if err == nil { - jsonRes, err: = json.Marshal(res) + jsonRes, err := json.Marshal(res) if err == nil { fmt.Println("result: ", string(jsonRes)) } @@ -1004,7 +1005,7 @@ func main() { ``` Sample invokeConnection Response -```go +```json { "receivedTimestamp": "2021-11-05 13:43:12.534", "processingTimeinMs": 12, @@ -1022,7 +1023,7 @@ The skyflow-go SDK provides useful logging using go libray `github.com/sirupsen/ import "github.com/skyflowapi/skyflow-go/commonutils/logwrapper" // sets the skyflow-go SDK log level to INFO -logger.SetLogLevel(logger.LogLevel.INFO); +logger.SetLogLevel(logger.INFO) ``` Currently the following log levels are supported: @@ -1048,7 +1049,7 @@ Currently the following log levels are supported: `LogLevel.OFF` can be used to turn off all logging from the Skyflow SDK. `Note`: - - The ranking of logging levels is as follows : `DEBUG` < `INFO` < `WARN` < `ERROR`< `OFF` + - From most verbose to least verbose, the logging levels are: `DEBUG`, `INFO`, `WARN`, `ERROR`, `OFF` . ## Reporting a Vulnerability diff --git a/README.md b/README.md index 129e447..091888a 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ The Skyflow Go SDK is designed to help with integrating Skyflow into a go backen - [Insert data into the vault, get tokens back](#insert-data-into-the-vault-get-tokens-back) - [Upgrade from v1 to v2](#upgrade-from-v1-to-v2) - [Vault](#vault) - - [Insert data into the vault](#insert-data-into-the-vault-1) + - [Insert data into the vault](#insert-data-into-the-vault) - [Insert example with ContinueOnError option](#insert-example-with-continueonerror-option) - [Upsert request](#upsert-request) - [Detokenize](#detokenize) @@ -90,7 +90,7 @@ The Skyflow Go SDK is designed to help with integrating Skyflow into a go backen ## Install ### Requirements -- go 1.22.0 and above +- go 1.25.0 and above ### Configuration @@ -129,44 +129,35 @@ skyflowCredentials := common.Credentials{ApiKey: ""} // Replace "} ``` -For authenticating via generated bearer tokens including support for scoped tokens, context-aware access tokens, and more, refer to the [Authenticate with bearer tokens](#authenticate-with-bearer-tokens) section. +Generated bearer tokens support scoped tokens, context-aware access tokens, and more. See [Generate bearer tokens for authentication & authorization](#generate-bearer-tokens-for-authentication--authorization). ### Initialize the client To get started, you must first initialize the skyflow client. While initializing the skyflow client, you can specify different types of credentials. ```go -import ( - "context" - "fmt" - "github.com/skyflowapi/skyflow-go/v2/client" - "github.com/skyflowapi/skyflow-go/v2/utils/common" - "github.com/skyflowapi/skyflow-go/v2/utils/logger" -) +creds := common.Credentials{ + Path: "", // Replace with the path to the credentials file +} +vaultConfig1 := common.VaultConfig{ + VaultId: "", // Replace with the Vault ID of the first vault + ClusterId: "", // Replace with the Cluster ID of the first vault + Env: common.DEV, // Set the environment: SANDBOX, DEV, STAGE, or PROD + Credentials: creds, +} +var arr []common.VaultConfig +arr = append(arr, vaultConfig1) -func main() { - creds := common.Credentials{ - Path: "" - } // Replace with the path to the credentials file - vaultConfig1 := common.VaultConfig{ - VaultId: "", - ClusterId: "", - Env: common.DEV, - Credentials: creds - } // Replace with the Cluster and Vault ID of the first vault, Set the environment (e.g., DEV, STAGE, PROD) - var arr []common.VaultConfig - arr = append(arr, vaultConfig1) - // Create a Skyflow client and add vault configurations - skyflowClient, err := client.NewSkyflow( - client.WithVaults(arr...), // Add the first vault configuration - client.WithCredentials(common.Credentials{ - Token: "" - }), // Add the first vault configuration - client.WithLogLevel(logger.DEBUG), // Enable debugging for detailed logs - ) -} +// Create a Skyflow client and add vault configurations +skyflowClient, err := client.NewSkyflow( + client.WithVaults(arr...), // Add the first vault configuration + client.WithLogLevel(logger.DEBUG), // Enable debugging for detailed logs +) +if err != nil { + fmt.Println("Error creating Skyflow client:", err) +} ``` -See [docs/advanced_initialization.md](./docs/advanced_initialization.md) for advanced initialization examples including multiple vaults and different credential types. +See [docs/advanced_initialization.md](./docs/advanced_initialization.md) for advanced initialization examples including multiple vaults and different credential types. The remaining examples in this README reuse the `skyflowClient` you create here; the next section continues this snippet into one complete, runnable program. ### Insert data into the vault, get tokens back To insert data into your vault, use the `Insert` method. The `InsertRequest` struct creates an insert request, which includes the values to be inserted as a list of records. Below is a simple example to get started. For advanced options, check out [Insert data into the vault](#insert-data-into-the-vault) section. @@ -191,9 +182,29 @@ import ( ) func main() { - // Initialize Skyflow client + // Step 1: Initialize the Skyflow client (see Initialize the client above). + creds := common.Credentials{ + Path: "", // Replace with the path to the credentials file + } + vaultConfig1 := common.VaultConfig{ + VaultId: "", // Replace with the Vault ID of the first vault + ClusterId: "", // Replace with the Cluster ID of the first vault + Env: common.DEV, // Set the environment: SANDBOX, DEV, STAGE, or PROD + Credentials: creds, + } + var arr []common.VaultConfig + arr = append(arr, vaultConfig1) - // Step 1: Initialize data to be inserted into the Skyflow vault + skyflowClient, err := client.NewSkyflow( + client.WithVaults(arr...), + client.WithLogLevel(logger.DEBUG), // Enable debugging for detailed logs + ) + if err != nil { + fmt.Println("Error creating Skyflow client:", err) + return + } + + // Step 2: Prepare the data to be inserted into the Skyflow vault. ctx := context.TODO() // Create a context for the operation. // Create a slice to hold the data records for insertion. @@ -201,30 +212,32 @@ func main() { // Add a record with sensitive fields (e.g., card number and cardholder name). values = append(values, map[string]interface{}{ - "card_number": "4111111111111111",// Replace with actual card number (sensitive data) - "cardholder_name": "john doe", // Replace with the actual cardholder name (sensitive data) + "card_number": "4111111111111111", // Replace with actual card number (sensitive data) + "cardholder_name": "john doe", // Replace with the actual cardholder name (sensitive data) }) insertRequest := common.InsertRequest{ Table: "table1", // Specify the table in the vault where the data will be inserted Values: values, // Attach the data (records) to be inserted } insertOptions := common.InsertOptions{ - ReturnTokens: true, // Request tokenized values to be returned in the response. + ReturnTokens: true, // Request tokenized values to be returned in the response. } - // Step 2: Obtain a Vault service instance for performing operations. + + // Step 3: Obtain a Vault service instance for performing operations. service, serviceError := skyflowClient.Vault("9f27764a10f7946fe56b3258e117") // Replace the vault ID "9f27764a10f7946fe56b3258e117" with your actual Skyflow vault ID if serviceError != nil { // Handle errors while getting the vault service instance. fmt.Println("Error obtaining Vault service:", serviceError) + return } - // Step 3: Perform the insert operation using the Skyflow client - insert, err4 := service.Insert(ctx, insertRequest, insertOptions) - if err4 != nil { - // Step 4: Handle any errors that occur during the insert operation. - fmt.Println("Error occurred: ", *err4) + // Step 4: Perform the insert operation using the Skyflow client. + insert, insertErr := service.Insert(ctx, insertRequest, insertOptions) + if insertErr != nil { + // Step 5: Handle any errors that occur during the insert operation. + fmt.Println("Error occurred: ", *insertErr) } else { - // Step 5: Print the response from the insert operation. + // Step 6: Print the response from the insert operation. fmt.Println("Insert Response: ", insert) } } @@ -294,7 +307,10 @@ func main() { Table: "", // Replace with the actual table name in your Skyflow vault. Values: values, // Attach the data to be inserted. } - + insertOptions := common.InsertOptions{ + ReturnTokens: true, // Request tokenized values to be returned in the response. + } + // Step 3: Use the Skyflow client to perform the insert operation //Obtain a Vault service instance for performing operations. service, err := skyflowClient.Vault("") // Replace with your actual vault ID @@ -303,10 +319,10 @@ func main() { fmt.Println("Error obtaining Vault service:", err) } // Step 4: Perform the insert operation using the Vault service. - insert, errs := service.Insert(ctx, insertRequest) + insert, errs := service.Insert(ctx, insertRequest, insertOptions) if errs != nil { // Handle any exceptions that occur during the insert operation - fmt.Println("Error occurred while inserting data: ", *err4) + fmt.Println("Error occurred while inserting data: ", *errs) } else { // Print the response from the insert operation fmt.Println("Insert Response: ", insert) @@ -775,7 +791,7 @@ func main() { } else { // Step 4: Call the Skyflow vault to tokenize the sensitive data - res, tokenizeErr := service.Tokenize(ctx, reqArray) + res, tokenizeErr := service.Tokenize(ctx, reqArray, common.TokenizeOptions{}) if tokenizeErr != nil { // Step 5: Handle error during the tokenization process fmt.Println("Error occurred: ", tokenizeErr) @@ -827,7 +843,7 @@ func main() { fmt.Println(serviceErr) } else { // Step 4 : Call the Skyflow vault to tokenize the sensitive data - res, tokenizeErr := service.Tokenize(ctx, reqArray) + res, tokenizeErr := service.Tokenize(ctx, reqArray, common.TokenizeOptions{}) if tokenizeErr != nil { // Handle error during the tokenization process fmt.Println("Error occurred ", tokenizeErr) @@ -1405,7 +1421,7 @@ func main() { } // Step 3: Send the delete request to the Skyflow vault - deleteResponse, errDelete := service.Delete(ctx, deleteRequest) // Call to delete records from the vault + deleteResponse, errDelete := service.Delete(ctx, deleteRequest, common.DeleteOptions{}) // Call to delete records from the vault if errDelete != nil { // Handle errors during the delete operation fmt.Println("Error occurred", *errDelete) // Print the error message for debugging @@ -1463,7 +1479,7 @@ func main() { } // Step 3: Send the delete request to the Skyflow vault - deleteResponse, errDelete := service.Delete(context.TODO(), deleteRequest) + deleteResponse, errDelete := service.Delete(context.TODO(), deleteRequest, common.DeleteOptions{}) if errDelete != nil { // Handle errors that occur during the delete operation fmt.Println("Error occurred", *errDelete) // Print the error for debugging purposes @@ -1524,7 +1540,7 @@ func main() { ctx := context.TODO() // Using context to manage the API request lifecycle // Step 4: Execute the query request on the specified Skyflow vault - res, queryErr := service.Query(ctx, queryRequest) // Execute the query + res, queryErr := service.Query(ctx, queryRequest, common.QueryOptions{}) // Execute the query // Step 5: Handle the response or any errors from the query execution if queryErr != nil { @@ -1580,7 +1596,7 @@ func main() { // Step 3: Execute the query request on the specified Skyflow vault and handle the response ctx := context.TODO() // Context for managing the lifecycle of the query request - res, queryErr := service.Query(ctx, queryRequest) // Execute the query request + res, queryErr := service.Query(ctx, queryRequest, common.QueryOptions{}) // Execute the query request if queryErr != nil { // Handle any errors that occur during query execution @@ -1616,6 +1632,7 @@ package main import ( "context" "fmt" + "os" "github.com/skyflowapi/skyflow-go/v2/client" "github.com/skyflowapi/skyflow-go/v2/utils/common" ) @@ -1642,16 +1659,16 @@ func main() { } else { // Step 3: Create file request request := common.FileUploadRequest{ - Table: "", // Replace with the actual table name into which file is to upload + Table: "", // Replace with the actual table name into which file is to upload FileObject: *fileObj, // Optional - FilePath: "" // Optional - Base64: "" // Optional + FilePath: "", // Optional + Base64: "", // Optional ColumnName: "", // Replace column name with your file column SkyflowId: "", // Replace skyflow id for file upload - FileName: "" // Optional, File name is required in case of base64 + FileName: "", // Optional, File name is required in case of base64 } // Step 4: Send the file upload request to the Skyflow vault - fileResponse, errFile := service.UploadFile(ctx, request) + fileResponse, errFile := service.UploadFile(ctx, request, common.FileUploadOptions{}) // Step 5: Prints the response to confirm the success or failure of the update operation. if errFile != nil { // Handle errors that occur during the upload operation @@ -1677,6 +1694,7 @@ package main import ( "context" "fmt" + "os" "github.com/skyflowapi/skyflow-go/v2/client" "github.com/skyflowapi/skyflow-go/v2/utils/common" ) @@ -1708,16 +1726,16 @@ func main() { } else { // Step 3: Constructs an file upload request request := common.FileUploadRequest{ - Table: "table1", // Replace with the actual table name into which file is to upload + Table: "table1", // Replace with the actual table name into which file is to upload FileObject: *fileObj, // Optional - FilePath: filePath // Optional - Base64: "" // Optional + FilePath: filePath, // Optional + Base64: "", // Optional ColumnName: "file", // Replace column name with your file column SkyflowId: "5b699e2c-4301-4f9f-bcff-0a8fd3057413", // Replace skyflow id for file upload - FileName: "" // Optional, File name is required in case of base64 + FileName: "", // Optional, File name is required in case of base64 } // Step 4: Send the file upload request to the Skyflow vault - fileResponse, errFile := service.UploadFile(ctx, request) + fileResponse, errFile := service.UploadFile(ctx, request, common.FileUploadOptions{}) // Step 5: Prints the response to confirm the success or failure of the file upload operation. if errFile != nil { // Handle errors that occur during the upload operation @@ -1885,7 +1903,7 @@ func main() { }, } // Step 3: Call deidentifyText - deidentifyTextRes, deidentifyTextErr := service.DeidentifyText(ctx, request) + deidentifyTextRes, deidentifyTextErr := service.DeidentifyText(ctx, request, common.DeidentifyTextOptions{}) // Step 5: Handle the response and errors. if deidentifyTextErr != nil { fmt.Println("ERROR: ", *deidentifyTextErr) @@ -1961,7 +1979,7 @@ func main() { common.Dob, }, }, - }) + }, common.DeidentifyTextOptions{}) // Step 5: Handle the response and errors. if deidentifyTextErr != nil { fmt.Println("ERROR: ", *deidentifyTextErr) @@ -2052,7 +2070,7 @@ func main() { }, } // Call ReidentifyText - reidentifyTextResponse, reidentifyTextErr := service.ReidentifyText(ctx, request) + reidentifyTextResponse, reidentifyTextErr := service.ReidentifyText(ctx, request, common.ReidentifyTextOptions{}) // Handle the response and errors. if reidentifyTextErr != nil { @@ -2108,7 +2126,7 @@ func main() { }, } // Call ReidentifyText - reidentifyTextResponse, reidentifyTextErr := service.ReidentifyText(ctx, request) + reidentifyTextResponse, reidentifyTextErr := service.ReidentifyText(ctx, request, common.ReidentifyTextOptions{}) // Handle the response and errors. if reidentifyTextErr != nil { @@ -2201,7 +2219,7 @@ func main() { // OutputTranscription: common.PLAINTEXT_TRANSCRIPTION, } //Step 2: Construct the file input by providing either file or filePath but not both - deidentifyFileRes, deidentifyFileErr := service.DeidentifyFile(ctx, request) + deidentifyFileRes, deidentifyFileErr := service.DeidentifyFile(ctx, request, common.DeidentifyFileOptions{}) // Step 5: Handle the response and errors. if deidentifyFileErr != nil { @@ -2276,7 +2294,7 @@ func main() { }, } //Step 2: Construct the file input by providing either file or filePath but not both - deidentifyFileRes, deidentifyFileErr := service.DeidentifyFile(ctx, request) + deidentifyFileRes, deidentifyFileErr := service.DeidentifyFile(ctx, request, common.DeidentifyFileOptions{}) // Step 5: Handle the response and errors. if deidentifyFileErr != nil { @@ -2388,7 +2406,7 @@ func main() { request := common.GetDetectRunRequest{ RunId: "", } - getDetectRunRes, deidentifyFileErr := service.GetDetectRun(ctx, request) + getDetectRunRes, deidentifyFileErr := service.GetDetectRun(ctx, request, common.GetDetectRunOptions{}) // Step 5: Handle the response and errors. if deidentifyFileErr != nil { @@ -2424,7 +2442,7 @@ func main() { RunId: "89699e2c-4301-4f9f-bcff-0a8fd30574898", // Replace with the runId you received earlier } // Step 2: Call GetDetectRun - getDetectRunRes, deidentifyFileErr := service.GetDetectRun(ctx, request) + getDetectRunRes, deidentifyFileErr := service.GetDetectRun(ctx, request, common.GetDetectRunOptions{}) // Step 5: Handle the response and errors if deidentifyFileErr != nil { @@ -3260,13 +3278,16 @@ All SDK methods return `*skyflowError.SkyflowError` as the error type. Check for | `GetDetails()` | `[]interface{}` | Structured error details array from the API response. | | `GetResponseBody()` | `map[string]interface{}` | Raw response body from the API. | +The following continues the [Insert data into the vault](#insert-data-into-the-vault) example, reusing its `service`, `ctx`, and `insertRequest`: + ```go import ( "fmt" + "github.com/skyflowapi/skyflow-go/v2/utils/common" skyflowError "github.com/skyflowapi/skyflow-go/v2/utils/error" ) -res, err := service.Insert(ctx, insertRequest) +res, err := service.Insert(ctx, insertRequest, common.InsertOptions{}) if err != nil { fmt.Println("HTTP status:", err.GetHttpStatusCode()) fmt.Println("message:", err.GetMessage()) diff --git a/docs/advanced_initialization.md b/docs/advanced_initialization.md index 549218f..7aabf2c 100644 --- a/docs/advanced_initialization.md +++ b/docs/advanced_initialization.md @@ -1,6 +1,6 @@ # Advanced Skyflow Client Initialization -This guide demonstrates advanced initialization patterns for the Skyflow Python SDK, including multiple vault configurations and different credential types. +This guide demonstrates advanced initialization patterns for the Skyflow Go SDK, including multiple vault configurations and different credential types. Use multiple vault configurations when your application needs to access data across different Skyflow vaults, such as managing data across different geographic regions or distinct environments. @@ -24,6 +24,7 @@ Note: Only one type of credential can be used at a time. ```go package main import ( + "fmt" "github.com/skyflowapi/skyflow-go/v2/client" "github.com/skyflowapi/skyflow-go/v2/utils/common" "github.com/skyflowapi/skyflow-go/v2/utils/logger" @@ -48,7 +49,7 @@ func main() { // Step 2: Configure the primary vault details. // VaultConfig stores all necessary details to connect to a specific Skyflow vault. - primaryConfig: = common.VaultConfig { + primaryConfig := common.VaultConfig{ VaultId: "", // Replace with your primary vault's ID. ClusterId: "", // Replace with the cluster ID (part of the vault URL, e.g., https://{clusterId}.vault.skyflowapis.com). Env: common.DEV, // Set the environment (PROD, SANDBOX, STAGE, DEV). @@ -59,7 +60,7 @@ func main() { // Demonstrates an alternate approach to authenticate with Skyflow using a credentials object. credentialsObject := `` // Step 4: Use credentials string. - skyflowCredentials = common.Credentials { + skyflowCredentials := common.Credentials{ CredentialsString: credentialsObject, } @@ -94,19 +95,24 @@ func main() { // Step 9: Build and initialize the Skyflow client. // Skyflow client is configured with multiple vaults and credentials. - var arr[] common.VaultConfig + var arr []common.VaultConfig arr = append(arr, primaryConfig, secondaryConfig, tertiaryConfig) - skyflowClient, err: = client.NewSkyflow( + skyflowClient, err := client.NewSkyflow( client.WithVaults(arr...), client.WithCredentials(skyflowCredentials), // Add JSON-formatted credentials if applicable. client.WithLogLevel(logger.DEBUG), // Set log level for debugging or monitoring purposes. ) + if err != nil { + fmt.Println("Error creating Skyflow client:", err) + return + } // The Skyflow client is now fully initialized. // Use the `skyflowClient` object to perform secure operations such as: // - Inserting data // - Retrieving data // - Deleting data // within the configured Skyflow vaults. + _ = skyflowClient } ``` diff --git a/docs/api_reference.md b/docs/api_reference.md index d30d061..cabbb15 100644 --- a/docs/api_reference.md +++ b/docs/api_reference.md @@ -415,7 +415,7 @@ Returned by `vault.Insert()`. | Field | Type | Description | |-------|------|-------------| -| `InsertedFields` | `[]map[string]interface{}` | One entry per inserted record. Each map contains `skyflow_id`; with `ReturnTokens: true`, also a token per column; with `ContinueOnError: true`, also a `request_index`. | +| `InsertedFields` | `[]map[string]interface{}` | One entry per inserted record. Each map contains `SkyflowId` (also returned as the deprecated `skyflow_id` alias); with `ReturnTokens: true`, also a token per column; with `ContinueOnError: true`, also `RequestIndex` (also returned as the deprecated `request_index` alias). | | `Errors` | `[]map[string]interface{}` | Per-record errors when `ContinueOnError: true`. Each map contains `request_index`, `error`, and `http_code`. | ### `DetokenizeResponse` @@ -442,7 +442,7 @@ Returned by `vault.Update()`. | Field | Type | Description | |-------|------|-------------| -| `UpdatedField` | `map[string]interface{}` | The updated record's `skyflow_id` and, when `ReturnTokens: true`, a token per updated column. | +| `UpdatedField` | `map[string]interface{}` | The updated record's `SkyflowId` (also returned as the deprecated `skyflowId` alias) and, when `ReturnTokens: true`, a token per updated column. | | `Errors` | `[]map[string]interface{}` | Errors, if any. | ### `DeleteResponse` diff --git a/docs/auth_credentials.md b/docs/auth_credentials.md index 69ea12e..12f194e 100644 --- a/docs/auth_credentials.md +++ b/docs/auth_credentials.md @@ -1,6 +1,6 @@ # Authentication credentials options -> **Note:** Only one type of credential can be used at a time. If multiple credentials are provided, the last one added takes precedence. +> **Note:** A single `Credentials` struct accepts only one credential type. Passing more than one in the same struct is a validation error. When credentials are set at more than one level, vault-level credentials take precedence over client-level (common) credentials. Client-level credentials take precedence over the `SKYFLOW_CREDENTIALS` environment variable. 1. **API keys** @@ -19,7 +19,7 @@ ```go credentials := common.Credentials{ - Token: "" + Token: "", } ``` @@ -30,7 +30,7 @@ ```go credentials := common.Credentials{ - Path: "" + Path: "", } ``` diff --git a/docs/migrate_to_v2.md b/docs/migrate_to_v2.md index ce6d9d8..3c5413e 100644 --- a/docs/migrate_to_v2.md +++ b/docs/migrate_to_v2.md @@ -214,8 +214,8 @@ if serviceError != nil { "InsertedFields": [ { "card_number": "5484-7829-1702-9110", - "request_index": "0", - "skyflow_id": "9fac9201-7b8a-4446-93f8-5244e1213bd1", + "RequestIndex": "0", + "SkyflowId": "9fac9201-7b8a-4446-93f8-5244e1213bd1", "cardholder_name": "b2308e2a-c1f5-469b-97b7-1f193159399b" } ], @@ -288,4 +288,4 @@ Response maps now use `SkyflowId` (PascalCase). The legacy keys are still presen --- -For the full list of changes see [CHANGELOG.md](../CHANGELOG.md). +For the full list of changes see [GitHub Releases](https://github.com/skyflowapi/skyflow-go/releases). From 95ab447e29f842bee17a1cf4340b9f0827d2a250 Mon Sep 17 00:00:00 2001 From: "promptless[bot]" Date: Mon, 19 Oct 2026 17:19:17 +0000 Subject: [PATCH 2/2] docs: fix the same ConnectionConfig field bug in the InvokeConnection signature snippet --- README-v1.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README-v1.md b/README-v1.md index a4b1228..b2c91b8 100644 --- a/README-v1.md +++ b/README-v1.md @@ -949,7 +949,7 @@ The InvokeConnection method lets you bypass handling sensitive data by integrati requestBody := make(map[string]interface{}) requestBody[""] = "" - connectionConfig := common.ConnectionConfig{ConnectionURL : "",MethodName : "",PathParams : pathParams,QueryParams : queryParams, RequestBody : requestBody, RequestHeaders : requestHeader} + connectionConfig := common.ConnectionConfig{ConnectionURL : "",MethodName : common.POST,PathParams : pathParams,QueryParams : queryParams, RequestBody : requestBody, RequestHeader : requestHeader} skyflowClient.InvokeConnection(connectionConfig)