-
Notifications
You must be signed in to change notification settings - Fork 14
CLOUDP-322242: Add Service account curl example to OAS #742
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3cc58f8
CLOUDP-322242: Add Service account curl example to OAS
andreaangiolillo 01743d7
Addressed Gustavo's comments
andreaangiolillo 25cd8ca
rename env variables
andreaangiolillo 97f9ab7
Rename `curl (Service Account Access Token)` to `curl (Service Accoun…
andreaangiolillo 073f8eb
Addressed Stephen's feedback
andreaangiolillo 4d443b2
fix unit tests
andreaangiolillo 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -54,9 +54,9 @@ func (f *CodeSampleFilter) Apply() error { | |
return nil | ||
} | ||
|
||
func (f *CodeSampleFilter) newCurlCodeSamplesForOperation(pathName, opMethod string) codeSample { | ||
func (f *CodeSampleFilter) newDigestCurlCodeSamplesForOperation(pathName, opMethod string) codeSample { | ||
version := apiVersion(f.metadata.targetVersion) | ||
source := "curl --user \"{PUBLIC-KEY}:{PRIVATE-KEY}\" \\\n --digest \\\n " + | ||
source := "curl --user \"${PUBLIC_KEY}:${PRIVATE_KEY}\" \\\n --digest \\\n " + | ||
"--header \"Accept: application/vnd.atlas." + version + "+json\" \\\n " | ||
|
||
switch opMethod { | ||
|
@@ -65,14 +65,37 @@ func (f *CodeSampleFilter) newCurlCodeSamplesForOperation(pathName, opMethod str | |
case "DELETE": | ||
source += "-X " + opMethod + " \"https://cloud.mongodb.com" + pathName + "\"" | ||
case "POST", "PATCH", "PUT": | ||
source += "--header \"Content-Type: application/vnd.atlas." + version + "+json\" \\\n " | ||
source += "--header \"Content-Type: application/json\" \\\n " | ||
source += "-X " + opMethod + " \"https://cloud.mongodb.com" + pathName + "\" \\\n " | ||
source += "-d " + "'{ <Payload> }'" | ||
} | ||
|
||
return codeSample{ | ||
Lang: "cURL", | ||
Label: "curl", | ||
Label: "curl (Digest)", | ||
Source: source, | ||
} | ||
} | ||
|
||
func (f *CodeSampleFilter) newServiceAccountCurlCodeSamplesForOperation(pathName, opMethod string) codeSample { | ||
version := apiVersion(f.metadata.targetVersion) | ||
source := "curl --header \"Authorization: Bearer ${ACCESS_TOKEN}\" \\\n " + | ||
"--header \"Accept: application/vnd.atlas." + version + "+json\" \\\n " | ||
|
||
switch opMethod { | ||
case "GET": | ||
source += "-X " + opMethod + " \"https://cloud.mongodb.com" + pathName + "?pretty=true\"" | ||
case "DELETE": | ||
source += "-X " + opMethod + " \"https://cloud.mongodb.com" + pathName + "\"" | ||
case "POST", "PATCH", "PUT": | ||
source += "--header \"Content-Type: application/json\" \\\n " | ||
source += "-X " + opMethod + " \"https://cloud.mongodb.com" + pathName + "\" \\\n " | ||
source += "-d " + "'{ <Payload> }'" | ||
} | ||
|
||
return codeSample{ | ||
Lang: "cURL", | ||
Label: "curl (Service Accounts)", | ||
Source: source, | ||
} | ||
} | ||
|
@@ -108,8 +131,9 @@ func (f *CodeSampleFilter) includeCodeSamplesForOperation(pathName, opMethod str | |
} | ||
|
||
op.Extensions[codeSampleExtensionName] = []codeSample{ | ||
f.newCurlCodeSamplesForOperation(pathName, opMethod), | ||
newAtlasCliCodeSamplesForOperation(op), | ||
f.newServiceAccountCurlCodeSamplesForOperation(pathName, opMethod), | ||
andreaangiolillo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
f.newDigestCurlCodeSamplesForOperation(pathName, opMethod), | ||
Comment on lines
+135
to
+136
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. the main change is here |
||
} | ||
return nil | ||
} |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
drive by fix to list upcoming api versions in the
version.json
file