Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update README examples with latest method names #153

Merged
merged 7 commits into from
Apr 25, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func main() {
}

// write a secret
_, err = client.Secrets.KVv2Write(ctx, "my-secret", schema.KVv2WriteRequest{
_, err = client.Secrets.KvV2Write(ctx, "my-secret", schema.KvV2WriteRequest{
Data: map[string]any{
"password1": "abc123",
"password2": "correct horse battery staple",
Expand All @@ -94,11 +94,11 @@ func main() {
log.Println("secret written successfully")

// read a secret
s, err := client.Secrets.KVv2Read(ctx, "my-secret")
s, err := client.Secrets.KvV2Read(ctx, "my-secret")
if err != nil {
log.Fatal(err)
}
log.Println("secret retrieved:", s.Data)
log.Println("secret retrieved:", s.Data.Data)
}
```

Expand Down Expand Up @@ -155,7 +155,7 @@ client.Delete(...)
client.DeleteWithParameters(...)
```

For example, `client.Secrets.KVv2Write(...)` from
For example, `client.Secrets.KvV2Write(...)` from
[Getting Started](#getting-started) section could be rewritten using a generic
`client.Write(...)` like so:

Expand All @@ -180,11 +180,11 @@ client.Identity // identity-related methods
client.System // various system-wide calls
```

Below is an example of accessing a generated `System.ReadMounts` method
Below is an example of accessing the generated `MountsListSecretsEngines` method
(equivalent to `vault secrets list` or `GET /v1/sys/mounts`):

```go
resp, err := client.System.ReadMounts(ctx)
resp, err := client.System.MountsListSecretsEngines(ctx)
if err != nil {
log.Fatal(err)
}
Expand All @@ -208,7 +208,7 @@ _ = client.SetToken("my-token")
_ = client.SetNamespace("my-namespace")

// per-request decorators take precedence over the client-level settings
resp, _ = client.Secrets.KVv2Read(
resp, _ = client.Secrets.KvV2Read(
ctx,
"my-secret",
vault.WithToken("request-specific-token"),
Expand All @@ -231,7 +231,7 @@ syntax:

```go
// Equivalent to client.Read(ctx, "my/mount/path/data/my-secret")
secret, err := client.Secrets.KVv2Read(
secret, err := client.Secrets.KvV2Read(
ctx,
"my-secret",
vault.WithMountPath("my/mount/path"),
Expand All @@ -245,7 +245,7 @@ more background information.

```go
// wrap the response with a 5 minute TTL
resp, _ := client.Secrets.KVv2Read(
resp, _ := client.Secrets.KvV2Read(
ctx,
"my-secret",
vault.WithResponseWrapping(5*time.Minute),
Expand All @@ -269,7 +269,7 @@ The client also provides a convenience function `vault.IsErrorStatus(...)` to
simplify error handling:

```go
s, err := client.Secrets.KVv2Read(ctx, "my-secret")
s, err := client.Secrets.KvV2Read(ctx, "my-secret")
if err != nil {
if vault.IsErrorStatus(err, http.StatusForbidden) {
// special handling for 403 errors
Expand Down Expand Up @@ -322,7 +322,7 @@ if err != nil {
log.Fatal(err)
}

resp, err := client.Auth.CertificatesLogin(ctx, schema.CertificatesLoginRequest{
resp, err := client.Auth.CertLogin(ctx, schema.CertLoginRequest{
Name: "my-cert",
})
if err != nil {
Expand Down Expand Up @@ -382,10 +382,10 @@ callbacks:
var state string

// write
_, err := client.Secrets.KVv2Write(
_, err := client.Secrets.KvV2Write(
ctx,
"my-secret",
schema.KVv2WriteRequest{
schema.KvV2WriteRequest{
Data: map[string]any{
"password1": "abc123",
"password2": "correct horse battery staple",
Expand All @@ -399,7 +399,7 @@ _, err := client.Secrets.KVv2Write(
)

// read
secret, err := client.Secrets.KVv2Read(
secret, err := client.Secrets.KvV2Read(
ctx,
"my-secret",
vault.WithRequestCallbacks(
Expand Down