-
Notifications
You must be signed in to change notification settings - Fork 110
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
RSDK-9194: streamline app connection #4516
base: main
Are you sure you want to change the base?
RSDK-9194: streamline app connection #4516
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick question - how are we going to implement the interfaces for other clients, such as DataClient
and BillingClient
, here? (In the Python sdk, we define data_client as a property of the ViamClient class). I'm not sure if this is outside the scope of this PR, but I just want to clarify our approach moving forward :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a question about our approach towards building out the other clients w/ respect to ViamClient
(but again maybe that is out of scope of this ticket) so LGTM.
Similarly, the other clients would be part of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be better if there was an Options
struct that contained 2 fields: BaseUri string
and Credentials rpc.Credentials
. Then, have a func WithOptions
that takes in these options.
What I think can be improved from the current version is that baseURL
has to always be specified, even if just to be an empty string. Plus, there might be more ways in the future of connecting to app that this allows for.
And nothing is stopping us from making convenience functions like FromApiKey
so that the user can use API Keys instead of Options
app/viam_client.go
Outdated
// APIKeyOptions has what is necessary to connect through GRPC with an API key. | ||
type APIKeyOptions struct { | ||
baseURL string | ||
apiKey string | ||
apiKeyID string | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this
app/viam_client.go
Outdated
} | ||
|
||
// CreateViamClientWithAPIKey creates a ViamClient with an API key. | ||
func CreateViamClientWithAPIKey(ctx context.Context, apiKeyOptions APIKeyOptions, logger logging.Logger) (*ViamClient, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should take in normal Options
and apiKey
and apiKeyID
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious, if a user is going to pass in an Options
object, at that point, wouldn't they just set the APIKey themselves?
if !validateAPIKeyFormat(apiKey) { | ||
return nil, errors.New("API key should be a 32-char all-lowercase alphanumeric string") | ||
} | ||
if !validateAPIKeyIDFormat(apiKeyID) { | ||
return nil, errors.New("API key ID should be an all-lowercase alphanumeric string with this format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok to leave this in, but I do think it's unnecessary -- the server will tell the user that their creds are incorrect so no need to do client-side checking.
Jira ticket
Changes:
app/
ViamClient
structCreateViamClient
, which takes in api key for credentialsTesting: