AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.
Docs Menu

Atlas CLI 출력 사용자 지정

Go 템플릿 또는 JSON 경로를 사용하여 Atlas CLI 출력 필드와 형식을 사용자 지정할 수 있으며, 이를 통해 Atlas CLI의 출력을 기반으로 프로세스를 더 쉽게 자동화할 수 있습니다.

Atlas CLI 명령 내에서 또는 별도의 파일 통해 고 (Go) 템플릿을 지정할 수 있습니다. 고 (Go) 템플릿에 대해 자세히 학습하려면 패키지 템플릿을 참조하세요. 각 응답에 사용할 수 있는 유형 및 속성을 학습 Atlas 유형을 참조하세요.

--output 또는 -o 옵션을 사용하는 명령으로 템플릿을 지정할 수 있습니다.

--output|-o go-template="{{<template>}}"

또는 --output 또는 -o 옵션을 사용하여 파일을 통해 템플릿을 지정할 수 있습니다.

--output|-o go-template-file="<path-to-template-file>"

다음 명령은 템플릿을 사용하여 지정된 조직의 프로젝트 수를 검색합니다.

atlas projects ls --orgId 5ab5cedf5g5h5i5j5kl12mn4 -o go-template="Count: {{.TotalCount}}"

앞의 명령은 다음 출력을 반환합니다.

Count: 2

Atlas 다음 string Atlas cluster 설명 명령은 템플릿을 사용하여 이름이 인 cluster의 연결 을 getStarted 검색합니다. Atlas에 액세스할 때 기본 프로필을 사용합니다.

atlas clusters describe getStarted -o go-template="Parse: {{.SrvAddress}}"

이전 명령은 다음과 유사한 string 을 반환합니다.

Parse: mongodb+srv://getstarted.example.mongodb.net

You can use the MongoDB Shell, mongosh, to connect to the getStarted cluster with the srvAddress and the connection string. This example uses the connection string returned by the previous command for a user with the username User1.

mongo "mongodb+srv://getstarted.example.mongodb.net" --username User1 --password ChangeThisPasswordToSomethingSecure

json-path 출력 유형은 명령의 결과를 지정한 필드로 제한합니다.

명령에 --output 옵션을 추가할 때 json-path 유형을 지정할 수 있습니다. 결과와 비교하여 평가하려면 json-path 에 표현식을 제공해야 하며, 이는 명령에서 반환되는 json 필드를 알고 있어야 함을 의미합니다.

<command> --output|-o json-path='$<expression>'

json-path 표현식은 Atlas CLI 명령이 반환하는 JSON 요소를 나타냅니다. $ 문자는 일반적으로 객체 또는 배열 루트 요소를 나타냅니다.

유효한 문자 및 해당 함수의 목록은 JSONPath 표현식을 참조하세요.

다음 예시에서는 사용자가 자신의 API 키를 Atlas 조직 apiKeys 목록을 사용하여 조회합니다. json-path 표현식은 전체 키 목록을 반환하는 대신 출력을 첫 번째 키의 desc 필드로 제한합니다.

atlas organizations apikeys list --output json-path='$[0].desc'
> owner_key

로 동일한 명령을 실행하면 --output json API 에서 완전한 JSON 요소가 반환됩니다. json-path 로 작업하려면 명령이 반환하는 JSON 구조를 이해하는 것이 중요합니다.

다음의 전체 JSON 출력을 참조용으로 사용하면, $[0].desc 표현식이 포함된 --output json-path 이(가) "owner_key" 값만 찾아서 반환합니다.

[ //``$`` represents the outer array.
{ // ``[0]`` refers to the first element in the array (using a 0-based index).
"id": "60e736a95d585d2c9ccf2d19",
"desc": "owner_key", //``.desc`` refers to the ``desc`` field of that element.
"roles": [
{
"orgId": "5d961a949ccf64b4e7f53bac",
"roleName": "ORG_OWNER"
}
],
"privateKey": "********-****-****-c4e26334754f",
"publicKey": "xtfmtguk"
},
{
"id": "d2c9ccf2d1960e736a95d585",
"desc": "member_key",
"roles": [
{
"orgId": "5d961a949ccf64b4e7f53bac",
"roleName": "ORG_MEMBER"
}
],
"privateKey": "********-****-****-c4e26334754f",
"publicKey": "vfgcttku"
},
]

다음 예시에서는 사용자가 자신의 API 키를 Atlas 조직 apiKeys 목록을 사용하여 조회합니다. json-path 표현식은 id d2c9ccf2d1960e736a95d585을 가진 특정 JSON 객체의 desc 필드로 출력을 제한합니다.

atlas organizations apikeys list --output json-path='$[? @.id=="d2c9ccf2d1960e736a95d585"].desc'
> member_key

다음 예제에서는 사용자가 Atlas privateEndpoints Amazon Web Services describe 를 사용하여 비공개 엔드포인트에 대한 정보를 검색합니다. json-path 표현식은 출력을 루트 요소의 status 필드로 제한합니다.

atlas privateendpoints aws describe 601a4044da900269480a2533 --output json-path='$.status'
> WAITING_FOR_USER
이 페이지 평가하기