From badec5abad55ddb6c6a746ee0fae6cca55c899e2 Mon Sep 17 00:00:00 2001 From: David vonThenen <12752197+dvonthenen@users.noreply.github.com> Date: Thu, 7 Nov 2024 07:27:20 -0800 Subject: [PATCH] Organize Deprecated Code --- .golangci.yaml | 4 +- pkg/api/live/v1/{legacy.go => deprecated.go} | 0 .../v1/{legacy.go => deprecated.go} | 0 pkg/client/listen/client.go | 109 ---------------- pkg/client/listen/deprecated.go | 123 ++++++++++++++++++ pkg/client/live/{legacy.go => deprecated.go} | 13 ++ .../prerecorded/{legacy.go => deprecated.go} | 4 + pkg/client/speak/client.go | 34 ----- pkg/client/speak/deprecated.go | 44 +++++++ 9 files changed, 186 insertions(+), 145 deletions(-) rename pkg/api/live/v1/{legacy.go => deprecated.go} (100%) rename pkg/api/prerecorded/v1/{legacy.go => deprecated.go} (100%) create mode 100644 pkg/client/listen/deprecated.go rename pkg/client/live/{legacy.go => deprecated.go} (87%) rename pkg/client/prerecorded/{legacy.go => deprecated.go} (86%) create mode 100644 pkg/client/speak/deprecated.go diff --git a/.golangci.yaml b/.golangci.yaml index 72989764..10f2debd 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -134,11 +134,11 @@ issues: linters: - staticcheck text: SA1019 - - path: pkg/client/live/legacy.go + - path: pkg/client/live/deprecated.go linters: - staticcheck text: SA1019 - - path: pkg/api/prerecorded/v1/legacy.go + - path: pkg/api/prerecorded/v1/deprecated.go linters: - staticcheck text: SA1019 diff --git a/pkg/api/live/v1/legacy.go b/pkg/api/live/v1/deprecated.go similarity index 100% rename from pkg/api/live/v1/legacy.go rename to pkg/api/live/v1/deprecated.go diff --git a/pkg/api/prerecorded/v1/legacy.go b/pkg/api/prerecorded/v1/deprecated.go similarity index 100% rename from pkg/api/prerecorded/v1/legacy.go rename to pkg/api/prerecorded/v1/deprecated.go diff --git a/pkg/client/listen/client.go b/pkg/client/listen/client.go index 67890e55..9dae227c 100644 --- a/pkg/client/listen/client.go +++ b/pkg/client/listen/client.go @@ -240,112 +240,3 @@ func NewWSUsingChanWithCancel(ctx context.Context, ctxCancel context.CancelFunc, func NewWebSocketUsingChanWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, chans msginterfaces.LiveMessageChan) (*listenv1ws.WSChannel, error) { return NewWSUsingChanWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, chans) } - -/***********************************/ -// Deprecated (THESE WILL STILL WORK, -// BUT WILL BE REMOVED IN A FUTURE RELEASE) -/***********************************/ -/* -NewWebSocketForDemo creates a new websocket connection with all default options - -Please see NewWebSocketUsingCallbackForDemo for more information. - -TODO: Deprecate this function later -*/ -func NewWebSocketForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*listenv1ws.Client, error) { - return NewWSUsingCallbackForDemo(ctx, options) -} - -/* -NewWebSocketWithDefaults creates a new websocket connection with all default options - -Please see NewWebSocketUsingCallbackWithDefaults for more information. - -TODO: Deprecate this function later -*/ -func NewWebSocketWithDefaults(ctx context.Context, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { - return NewWSUsingCallbackWithDefaults(ctx, tOptions, callback) -} - -/* -NewWebSocket creates a new websocket connection with the specified options - -Please see NewWebSocketUsingCallback for more information. - -TODO: Deprecate this function later -*/ -func NewWebSocket(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { - return NewWSUsingCallback(ctx, apiKey, cOptions, tOptions, callback) -} - -/* -NewWebSocketWithCancel creates a new websocket connection but has facilities to BYOC (Bring Your Own Cancel) - -Please see NewWebSocketUsingCallbackWithCancel for more information. - -TODO: Deprecate this function later -*/ -func NewWebSocketWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { - return NewWSUsingCallbackWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, callback) -} - -/***********************************/ -// REST Client -/***********************************/ -// PreRecordedClient is an alias for listenv1rest.Client -// -// Deprecated: This package is deprecated. Use RestClient instead. This will be removed in a future release. -type PreRecordedClient = listenv1rest.RESTClient - -// NewPreRecordedWithDefaults is an alias for NewRESTWithDefaults -// -// Deprecated: This package is deprecated. Use NewRESTWithDefaults instead. This will be removed in a future release. -func NewPreRecordedWithDefaults() *listenv1rest.RESTClient { - return NewRESTWithDefaults() -} - -// NewPreRecorded is an alias for NewREST -// -// Deprecated: This package is deprecated. Use NewREST instead. This will be removed in a future release. -func NewPreRecorded(apiKey string, options *interfaces.ClientOptions) *listenv1rest.RESTClient { - return NewREST(apiKey, options) -} - -/***********************************/ -// WebSocket / Streaming / Live -/***********************************/ -// LiveClient is an alias for listenv1rest.Client -// -// Deprecated: This alias is deprecated. Use WSCallback instead. This will be removed in a future release. -type LiveClient = listenv1ws.Client - -/* - Older "Live" functions -*/ -// NewLiveForDemo is an alias for NewWebSocketForDemo -// -// Deprecated: This package is deprecated. Use NewWebSocketForDemo instead. This will be removed in a future release. -func NewLiveForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*listenv1ws.WSCallback, error) { - return NewWebSocketForDemo(ctx, options) -} - -// NewLiveWithDefaults is an alias for NewWebSocketWithDefaults -// -// Deprecated: This package is deprecated. Use NewWebSocketWithDefaults instead. This will be removed in a future release. -func NewLiveWithDefaults(ctx context.Context, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { - return NewWebSocketWithDefaults(ctx, tOptions, callback) -} - -// NewLive is an alias for NewWebSocket -// -// Deprecated: This package is deprecated. Use NewWebSocket instead. This will be removed in a future release. -func NewLive(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { - return NewWebSocket(ctx, apiKey, cOptions, tOptions, callback) -} - -// NewLiveWithCancel is an alias for NewWebSocketWithCancel -// -// Deprecated: This package is deprecated. Use NewWebSocketWithCancel instead. This will be removed in a future release. -func NewLiveWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { - return NewWebSocketWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, callback) -} diff --git a/pkg/client/listen/deprecated.go b/pkg/client/listen/deprecated.go new file mode 100644 index 00000000..fb523877 --- /dev/null +++ b/pkg/client/listen/deprecated.go @@ -0,0 +1,123 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package listen + +import ( + "context" + + msginterfaces "github.com/deepgram/deepgram-go-sdk/pkg/api/listen/v1/websocket/interfaces" + interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces" + listenv1rest "github.com/deepgram/deepgram-go-sdk/pkg/client/listen/v1/rest" + listenv1ws "github.com/deepgram/deepgram-go-sdk/pkg/client/listen/v1/websocket" +) + +/***********************************/ +// Deprecated (THESE WILL STILL WORK, +// BUT WILL BE REMOVED IN A FUTURE RELEASE) +/***********************************/ +/* +NewWebSocketForDemo creates a new websocket connection with all default options + +Please see NewWebSocketUsingCallbackForDemo for more information. + +TODO: Deprecate this function later +*/ +func NewWebSocketForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*listenv1ws.Client, error) { + return NewWSUsingCallbackForDemo(ctx, options) +} + +/* +NewWebSocketWithDefaults creates a new websocket connection with all default options + +Please see NewWebSocketUsingCallbackWithDefaults for more information. + +TODO: Deprecate this function later +*/ +func NewWebSocketWithDefaults(ctx context.Context, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { + return NewWSUsingCallbackWithDefaults(ctx, tOptions, callback) +} + +/* +NewWebSocket creates a new websocket connection with the specified options + +Please see NewWebSocketUsingCallback for more information. + +TODO: Deprecate this function later +*/ +func NewWebSocket(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { + return NewWSUsingCallback(ctx, apiKey, cOptions, tOptions, callback) +} + +/* +NewWebSocketWithCancel creates a new websocket connection but has facilities to BYOC (Bring Your Own Cancel) + +Please see NewWebSocketUsingCallbackWithCancel for more information. + +TODO: Deprecate this function later +*/ +func NewWebSocketWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.Client, error) { + return NewWSUsingCallbackWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, callback) +} + +/***********************************/ +// REST Client +/***********************************/ +// PreRecordedClient is an alias for listenv1rest.Client +// +// Deprecated: This package is deprecated. Use RestClient instead. This will be removed in a future release. +type PreRecordedClient = listenv1rest.RESTClient + +// NewPreRecordedWithDefaults is an alias for NewRESTWithDefaults +// +// Deprecated: This package is deprecated. Use NewRESTWithDefaults instead. This will be removed in a future release. +func NewPreRecordedWithDefaults() *listenv1rest.RESTClient { + return NewRESTWithDefaults() +} + +// NewPreRecorded is an alias for NewREST +// +// Deprecated: This package is deprecated. Use NewREST instead. This will be removed in a future release. +func NewPreRecorded(apiKey string, options *interfaces.ClientOptions) *listenv1rest.RESTClient { + return NewREST(apiKey, options) +} + +/***********************************/ +// WebSocket / Streaming / Live +/***********************************/ +// LiveClient is an alias for listenv1rest.Client +// +// Deprecated: This alias is deprecated. Use WSCallback instead. This will be removed in a future release. +type LiveClient = listenv1ws.Client + +/* + Older "Live" functions +*/ +// NewLiveForDemo is an alias for NewWebSocketForDemo +// +// Deprecated: This package is deprecated. Use NewWebSocketForDemo instead. This will be removed in a future release. +func NewLiveForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*listenv1ws.WSCallback, error) { + return NewWebSocketForDemo(ctx, options) +} + +// NewLiveWithDefaults is an alias for NewWebSocketWithDefaults +// +// Deprecated: This package is deprecated. Use NewWebSocketWithDefaults instead. This will be removed in a future release. +func NewLiveWithDefaults(ctx context.Context, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { + return NewWebSocketWithDefaults(ctx, tOptions, callback) +} + +// NewLive is an alias for NewWebSocket +// +// Deprecated: This package is deprecated. Use NewWebSocket instead. This will be removed in a future release. +func NewLive(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { + return NewWebSocket(ctx, apiKey, cOptions, tOptions, callback) +} + +// NewLiveWithCancel is an alias for NewWebSocketWithCancel +// +// Deprecated: This package is deprecated. Use NewWebSocketWithCancel instead. This will be removed in a future release. +func NewLiveWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*listenv1ws.WSCallback, error) { + return NewWebSocketWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, callback) +} diff --git a/pkg/client/live/legacy.go b/pkg/client/live/deprecated.go similarity index 87% rename from pkg/client/live/legacy.go rename to pkg/client/live/deprecated.go index f56b4127..94103375 100644 --- a/pkg/client/live/legacy.go +++ b/pkg/client/live/deprecated.go @@ -26,6 +26,11 @@ const ( /***********************************/ // LiveClient /***********************************/ +/* +Client is an alias for the listenv1ws.Client + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. +*/ type Client = listenv1ws.Client /* @@ -33,6 +38,8 @@ NewForDemo creates a new websocket connection with all default options Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func NewForDemo(ctx context.Context, options *interfaces.LiveTranscriptionOptions) (*Client, error) { return listenv1ws.New(ctx, "", &interfaces.ClientOptions{}, options, nil) @@ -49,6 +56,8 @@ Input parameters: Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY - The callback handler is set to the default handler which just prints all messages to the console + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func NewWithDefaults(ctx context.Context, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { return listenv1ws.New(ctx, "", &interfaces.ClientOptions{}, tOptions, callback) @@ -67,6 +76,8 @@ Input parameters: Notes: - If apiKey is an empty string, the Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY - The callback handler is set to the default handler which just prints all messages to the console + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func New(ctx context.Context, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { ctx, ctxCancel := context.WithCancel(ctx) @@ -87,6 +98,8 @@ Input parameters: Notes: - If apiKey is an empty string, the Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY - The callback handler is set to the default handler which just prints all messages to the console + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func NewWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, tOptions *interfaces.LiveTranscriptionOptions, callback msginterfaces.LiveMessageCallback) (*Client, error) { return listenv1ws.NewUsingCallbackWithCancel(ctx, ctxCancel, apiKey, cOptions, tOptions, callback) diff --git a/pkg/client/prerecorded/legacy.go b/pkg/client/prerecorded/deprecated.go similarity index 86% rename from pkg/client/prerecorded/legacy.go rename to pkg/client/prerecorded/deprecated.go index d918cd79..3b451c67 100644 --- a/pkg/client/prerecorded/legacy.go +++ b/pkg/client/prerecorded/deprecated.go @@ -30,6 +30,8 @@ NewWithDefaults creates a new analyze/read client with all default options Notes: - The Deepgram API KEY is read from the environment variable DEEPGRAM_API_KEY + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func NewWithDefaults() *Client { return listenv1rest.NewWithDefaults() @@ -41,6 +43,8 @@ New creates a new prerecorded client with the specified options Input parameters: - apiKey: string containing the Deepgram API key - options: ClientOptions which allows overriding things like hostname, version of the API, etc. + +Deprecated: This package is deprecated. Use the listen package instead. This will be removed in a future release. */ func New(apiKey string, options *interfaces.ClientOptions) *Client { return listenv1rest.New(apiKey, options) diff --git a/pkg/client/speak/client.go b/pkg/client/speak/client.go index 600b350d..73139271 100644 --- a/pkg/client/speak/client.go +++ b/pkg/client/speak/client.go @@ -227,37 +227,3 @@ Notes: func NewWSUsingChanWithCancel(ctx context.Context, ctxCancel context.CancelFunc, apiKey string, cOptions *interfaces.ClientOptions, sOptions *interfaces.WSSpeakOptions, callback msginterfaces.SpeakMessageChan) (*speakv1ws.WSChannel, error) { return speakv1ws.NewUsingChanWithCancel(ctx, ctxCancel, apiKey, cOptions, sOptions, callback) } - -/***********************************/ -// Deprecated (THESE WILL STILL WORK, -// BUT WILL BE REMOVED IN A FUTURE RELEASE) -/***********************************/ -/* -Legacy Client Name - -Deprecated: This struct is deprecated. Please use RestClient struct. This will be removed in a future release. -*/ -type Client = speakv1rest.RESTClient - -/* -NewWithDefaults creates a new speak client with all default options - -Deprecated: This function is deprecated. Please use NewREST(). This will be removed in a future release. -*/ -func NewWithDefaults() *speakv1rest.RESTClient { - return speakv1rest.NewWithDefaults() -} - -/* -New creates a new speak client with the specified options - -Input parameters: -- ctx: context.Context object -- apiKey: string containing the Deepgram API key -- options: ClientOptions which allows overriding things like hostname, version of the API, etc. - -Deprecated: This function is deprecated. Please use NewREST(). This will be removed in a future release. -*/ -func New(apiKey string, options *interfaces.ClientOptions) *speakv1rest.RESTClient { - return speakv1rest.New(apiKey, options) -} diff --git a/pkg/client/speak/deprecated.go b/pkg/client/speak/deprecated.go new file mode 100644 index 00000000..6cb4b2a1 --- /dev/null +++ b/pkg/client/speak/deprecated.go @@ -0,0 +1,44 @@ +// Copyright 2024 Deepgram SDK contributors. All Rights Reserved. +// Use of this source code is governed by a MIT license that can be found in the LICENSE file. +// SPDX-License-Identifier: MIT + +package speak + +import ( + interfaces "github.com/deepgram/deepgram-go-sdk/pkg/client/interfaces/v1" + speakv1rest "github.com/deepgram/deepgram-go-sdk/pkg/client/speak/v1/rest" +) + +/***********************************/ +// Deprecated (THESE WILL STILL WORK, +// BUT WILL BE REMOVED IN A FUTURE RELEASE) +/***********************************/ +/* +Legacy Client Name + +Deprecated: This struct is deprecated. Please use RestClient struct. This will be removed in a future release. +*/ +type Client = speakv1rest.RESTClient + +/* +NewWithDefaults creates a new speak client with all default options + +Deprecated: This function is deprecated. Please use NewREST(). This will be removed in a future release. +*/ +func NewWithDefaults() *speakv1rest.RESTClient { + return speakv1rest.NewWithDefaults() +} + +/* +New creates a new speak client with the specified options + +Input parameters: +- ctx: context.Context object +- apiKey: string containing the Deepgram API key +- options: ClientOptions which allows overriding things like hostname, version of the API, etc. + +Deprecated: This function is deprecated. Please use NewREST(). This will be removed in a future release. +*/ +func New(apiKey string, options *interfaces.ClientOptions) *speakv1rest.RESTClient { + return speakv1rest.New(apiKey, options) +}