From 7bc894763cf1df1906b6aed4ad4cc06b3ed5f5f6 Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Fri, 14 Mar 2025 13:28:27 +0100 Subject: [PATCH 1/2] Add DoCustomRequestV5 --- api/api.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/api.go b/api/api.go index 8f94d7e..22d70f2 100644 --- a/api/api.go +++ b/api/api.go @@ -26,12 +26,22 @@ type APIHeader struct { } // DoCustomRequest Executes a Custom Request and returns a APIResponse +// +// Deprecated: DoCustomRequest is deprecated. Use DoCustomRequestV5 instead func (c *Client) DoCustomRequest(ctx context.Context, method, path, version string, body interface{}, opts interface{}) (*APIResponse, error) { _, response, err := c.DoCustomRequestAndReturnRawResponse(ctx, method, path, version, body, opts) return response, err } +// DoCustomRequestV5 Executes a Custom Request and returns a APIResponse +func (c *Client) DoCustomRequestV5(ctx context.Context, method, path string, body interface{}, opts interface{}) (*APIResponse, error) { + _, response, err := c.DoCustomRequestAndReturnRawResponseV5(ctx, method, path, body, opts) + return response, err +} + // DoCustomRequestAndReturnRawResponse Executes a Custom Request and returns a APIResponse and the Raw HTTP Response +// +// Deprecated: DoCustomRequestAndReturnRawResponse is deprecated. Use DoCustomRequestAndReturnRawResponseV5 instead func (c *Client) DoCustomRequestAndReturnRawResponse(ctx context.Context, method, path, version string, body interface{}, opts interface{}) (*http.Response, *APIResponse, error) { // version is no longer used and is ignored. return c.DoCustomRequestAndReturnRawResponseV5(ctx, method, path, body, opts) From 057d2e5f5953d422d813f9e897463057dad2c2cc Mon Sep 17 00:00:00 2001 From: Samuel Lorch Date: Fri, 14 Mar 2025 13:29:07 +0100 Subject: [PATCH 2/2] Migrate new things to DoCustomRequestV5, fix Comments --- api/metadata_sessionkey.go | 8 ++++---- api/metadata_settings.go | 4 ++-- api/metadatakey.go | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/api/metadata_sessionkey.go b/api/metadata_sessionkey.go index cf18abe..7cada9d 100644 --- a/api/metadata_sessionkey.go +++ b/api/metadata_sessionkey.go @@ -22,7 +22,7 @@ type MetadataSessionKeyData struct { SessionKeys []MetadataSessionKeyDataElement `json:"session_keys,omitempty"` } -// MetadataSessionKeyData is a MetadataSessionKeyData +// MetadataSessionKeyDataElement is a MetadataSessionKeyDataElement type MetadataSessionKeyDataElement struct { ForeignModel ForeignModelTypes `json:"foreign_model"` ForeignID string `json:"foreign_id"` @@ -30,9 +30,9 @@ type MetadataSessionKeyDataElement struct { Modified Time `json:"modified"` } -// GetMetadataTypeSettings gets the Servers Settings about which Types to use +// GetMetadataSessionKeys gets the Metadata Session Keys func (c *Client) GetMetadataSessionKeys(ctx context.Context) ([]MetadataSessionKey, error) { - msg, err := c.DoCustomRequest(ctx, "GET", "/metadata/session-keys.json", "v2", nil, nil) + msg, err := c.DoCustomRequestV5(ctx, "GET", "/metadata/session-keys.json", nil, nil) if err != nil { return nil, err } @@ -53,7 +53,7 @@ func (c *Client) DeleteSessionKey(ctx context.Context, sessionKeyID string) erro if err != nil { return fmt.Errorf("Checking ID format: %w", err) } - _, err = c.DoCustomRequest(ctx, "DELETE", "/metadata/session-keys/"+sessionKeyID+".json", "v2", nil, nil) + _, err = c.DoCustomRequestV5(ctx, "DELETE", "/metadata/session-keys/"+sessionKeyID+".json", nil, nil) if err != nil { return err } diff --git a/api/metadata_settings.go b/api/metadata_settings.go index b54158f..ae80715 100644 --- a/api/metadata_settings.go +++ b/api/metadata_settings.go @@ -9,7 +9,7 @@ type PassboltAPIVersionType string const ( PassboltAPIVersionTypeV4 PassboltAPIVersionType = "v4" - PassboltAPIVersionTypeV5 = "v5" + PassboltAPIVersionTypeV5 PassboltAPIVersionType = "v5" ) func (s PassboltAPIVersionType) IsValid() bool { @@ -59,7 +59,7 @@ func getV4DefaultMetadataTypeSettings() MetadataTypeSettings { // GetMetadataTypeSettings gets the Servers Settings about which Types to use func (c *Client) GetMetadataTypeSettings(ctx context.Context) (*MetadataTypeSettings, error) { - msg, err := c.DoCustomRequest(ctx, "GET", "/metadata/types/settings.json", "v3", nil, nil) + msg, err := c.DoCustomRequestV5(ctx, "GET", "/metadata/types/settings.json", nil, nil) if err != nil { return nil, err } diff --git a/api/metadatakey.go b/api/metadatakey.go index b968258..49db61c 100644 --- a/api/metadatakey.go +++ b/api/metadatakey.go @@ -9,7 +9,7 @@ type MetadataKeyType string const ( MetadataKeyTypeUserKey MetadataKeyType = "user_key" - MetadataKeyTypeSharedKey = "shared_key" + MetadataKeyTypeSharedKey MetadataKeyType = "shared_key" ) func (s MetadataKeyType) IsValid() bool { @@ -72,7 +72,7 @@ type GetMetadataKeysOptions struct { // GetMetadataKeys gets all Passbolt GetMetadataKeys func (c *Client) GetMetadataKeys(ctx context.Context, opts *GetMetadataKeysOptions) ([]MetadataKey, error) { - msg, err := c.DoCustomRequest(ctx, "GET", "/metadata/keys.json", "v2", nil, opts) + msg, err := c.DoCustomRequestV5(ctx, "GET", "/metadata/keys.json", nil, opts) if err != nil { return nil, err }