-
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
Changes from 2 commits
3cc58f8
01743d7
25cd8ca
97f9ab7
073f8eb
4d443b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 " + | ||
andreaangiolillo marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
"--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 Account Access Token)", | ||
|
||
Source: source, | ||
} | ||
} | ||
|
@@ -108,7 +131,8 @@ func (f *CodeSampleFilter) includeCodeSamplesForOperation(pathName, opMethod str | |
} | ||
|
||
op.Extensions[codeSampleExtensionName] = []codeSample{ | ||
f.newCurlCodeSamplesForOperation(pathName, opMethod), | ||
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 |
||
newAtlasCliCodeSamplesForOperation(op), | ||
} | ||
return nil | ||
|
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