-
Notifications
You must be signed in to change notification settings - Fork 111
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
APP-7002: Implement “DeleteOAuthApplication” CLI command #4648
Open
gloriacai01
wants to merge
8
commits into
viamrobotics:main
Choose a base branch
from
gloriacai01:app-7002
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+130
−0
Open
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
a8aecec
add delete to cli
gloriacai01 9ddd024
Merge branch 'main' of github.com:viamrobotics/rdk into app-7002
gloriacai01 a3542e1
test
gloriacai01 c756fa7
add oauth-app flag
gloriacai01 834ef12
add deletion confirmation
gloriacai01 54f3713
lint
gloriacai01 56ff979
update message
gloriacai01 e445d50
capitalize oauth
gloriacai01 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -130,6 +130,7 @@ const ( | |||||
authApplicationFlagOriginURIs = "origin-uris" | ||||||
authApplicationFlagRedirectURIs = "redirect-uris" | ||||||
authApplicationFlagLogoutURI = "logout-uri" | ||||||
authApplicationFlagClientID = "client-id" | ||||||
|
||||||
cpFlagRecursive = "recursive" | ||||||
cpFlagPreserve = "preserve" | ||||||
|
@@ -425,6 +426,36 @@ var app = &cli.App{ | |||||
Usage: "work with organizations", | ||||||
HideHelpCommand: true, | ||||||
Subcommands: []*cli.Command{ | ||||||
{ | ||||||
Name: "auth-service", | ||||||
Usage: "manage auth-service", | ||||||
Subcommands: []*cli.Command{ | ||||||
{ | ||||||
Name: "oauth-app", | ||||||
Usage: "manage the oauth applications for an organization", | ||||||
Subcommands: []*cli.Command{ | ||||||
{ | ||||||
Name: "delete", | ||||||
Usage: "delete an oauth application", | ||||||
UsageText: createUsageText("delete", []string{generalFlagOrgID, authApplicationFlagClientID}, true), | ||||||
Flags: []cli.Flag{ | ||||||
&cli.StringFlag{ | ||||||
Name: generalFlagOrgID, | ||||||
Required: true, | ||||||
Usage: "organization ID tied to the oauth application", | ||||||
}, | ||||||
&cli.StringFlag{ | ||||||
Name: authApplicationFlagClientID, | ||||||
Required: true, | ||||||
Usage: "ID of the application to delete", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}, | ||||||
}, | ||||||
Action: createCommandWithT[deleteOAuthAppArgs](DeleteOAuthAppAction), | ||||||
}, | ||||||
}, | ||||||
}, | ||||||
}, | ||||||
}, | ||||||
{ | ||||||
Name: "list", | ||||||
Usage: "list organizations for the current user", | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -2050,3 +2050,37 @@ func logEntryFieldsToString(fields []*structpb.Struct) (string, error) { | |||||
} | ||||||
return message + "}", nil | ||||||
} | ||||||
|
||||||
type deleteOAuthAppArgs struct { | ||||||
OrgID string | ||||||
ClientID string | ||||||
} | ||||||
|
||||||
// DeleteOAuthAppAction is the corresponding action for 'auth-service update'. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
func DeleteOAuthAppAction(c *cli.Context, args deleteOAuthAppArgs) error { | ||||||
client, err := newViamClient(c) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
return client.deleteOAuthAppAction(c, args.OrgID, args.ClientID) | ||||||
} | ||||||
|
||||||
func (c *viamClient) deleteOAuthAppAction(cCtx *cli.Context, orgID, clientID string) error { | ||||||
if err := c.ensureLoggedIn(); err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
req := &apppb.DeleteOAuthAppRequest{ | ||||||
OrgId: orgID, | ||||||
ClientId: clientID, | ||||||
} | ||||||
|
||||||
_, err := c.client.DeleteOAuthApp(c.c.Context, req) | ||||||
if err != nil { | ||||||
return err | ||||||
} | ||||||
|
||||||
printf(cCtx.App.Writer, "Successfully deleted oauth application") | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
return nil | ||||||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Please provide an image in the description of what this looks like so that it's easy for us to check what this looks like in the end
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.
Oh, never mind! I didn't know what
UsageText
was and thought this wasUsage
. Looks good!