rebase: Bump github.com/IBM/keyprotect-go-client from 0.10.0 to 0.12.2

Bumps [github.com/IBM/keyprotect-go-client](https://github.com/IBM/keyprotect-go-client) from 0.10.0 to 0.12.2.
- [Release notes](https://github.com/IBM/keyprotect-go-client/releases)
- [Changelog](https://github.com/IBM/keyprotect-go-client/blob/master/CHANGELOG.md)
- [Commits](https://github.com/IBM/keyprotect-go-client/compare/v0.10.0...v0.12.2)

---
updated-dependencies:
- dependency-name: github.com/IBM/keyprotect-go-client
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
This commit is contained in:
dependabot[bot]
2023-08-29 08:13:35 +00:00
committed by mergify[bot]
parent eb24ae5cfc
commit 97d9f701ec
6 changed files with 176 additions and 99 deletions

View File

@ -3,6 +3,8 @@ package kp
import (
"context"
"fmt"
"net/http"
"strconv"
"time"
)
@ -18,7 +20,7 @@ type KeyRing struct {
type KeyRings struct {
Metadata KeysMetadata `json:"metadata"`
KeyRings []KeyRing `json:"resources"`
KeyRings []KeyRing `json:"resources"`
}
// CreateRing method creates a key ring in the instance with the provided name
@ -57,11 +59,24 @@ func (c *Client) GetKeyRings(ctx context.Context) (*KeyRings, error) {
return &rings, nil
}
type DeleteKeyRingQueryOption func(*http.Request)
func WithForce(force bool) DeleteKeyRingQueryOption {
return func(req *http.Request) {
query := req.URL.Query()
query.Add("force", strconv.FormatBool(force))
req.URL.RawQuery = query.Encode()
}
}
// DeleteRing method deletes the key ring with the provided name in the instance
// For information please refer to the link below:
// https://cloud.ibm.com/docs/key-protect?topic=key-protect-managing-key-rings#delete-key-ring-api
func (c *Client) DeleteKeyRing(ctx context.Context, id string) error {
func (c *Client) DeleteKeyRing(ctx context.Context, id string, opts ...DeleteKeyRingQueryOption) error {
req, err := c.newRequest("DELETE", fmt.Sprintf(path+"/%s", id), nil)
for _, opt := range opts {
opt(req)
}
if err != nil {
return err
}