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

Organize Deprecated Code #271

Merged
merged 1 commit into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
109 changes: 0 additions & 109 deletions pkg/client/listen/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
123 changes: 123 additions & 0 deletions pkg/client/listen/deprecated.go
Original file line number Diff line number Diff line change
@@ -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)
}
13 changes: 13 additions & 0 deletions pkg/client/live/legacy.go → pkg/client/live/deprecated.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,20 @@ 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

/*
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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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)
Expand Down
34 changes: 0 additions & 34 deletions pkg/client/speak/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
44 changes: 44 additions & 0 deletions pkg/client/speak/deprecated.go
Original file line number Diff line number Diff line change
@@ -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)
}
Loading