Skip to content

Commit b4d1b33

Browse files
authored
Merge pull request #99 from MZC-CSC/develop
Update README and API documentation to include new commands - Modify command examples to reflect service name changes and enhance parameter descriptions for path and query strings. - Update README and API documentation to include new commands for managing resources and improve usage clarity. - Update API command documentation and examples to reflect service name changes from 'spider' to 'cb-spider' - Improve PathParam and QueryString usage instructions. - Modify related flags descriptions for clarity. API 명령어 사용 예시 보완 및 문서 보완
2 parents a54b9ab + d50e02f commit b4d1b33

File tree

5 files changed

+66
-20
lines changed

5 files changed

+66
-20
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,14 @@ $ ./mayfly infra run -s cb-spider
219219
$ ./mayfly infra run -s "cb-spider cb-tumblebug"
220220
```
221221

222+
223+
You can clean up migrated resources in CSP using the `api` command with cm-beetle's Deleteinfra API.
224+
```
225+
$ ./mayfly api --service cm-beetle --action Deleteinfra --pathParam "nsId:mig01 mciId:mmci01" --queryString "option=terminate"
226+
```
227+
For more details about the `api` command, please refer to the [api sub-command guide](https://github.com/cloud-barista/cm-mayfly/blob/main/docs/cm-mayfly-api.md).
228+
229+
222230
## 7. Trouble Shooting
223231
For some subsystems, including cm-cicada, the order of startup is important. Even if they are marked as healthy, they may not be running correctly.
224232
For cm-cicada, please check the logs and restart if any errors occur.

cmd/apicall/root.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,12 @@ var apiCmd = &cobra.Command{
7777
Long: `Call the action of the service defined in api.yaml. For example:
7878
./mayfly api --help
7979
./mayfly api --list
80-
./mayfly api --service spider --list
81-
./mayfly api --service spider --action ListCloudOS
82-
./mayfly api --service spider --action GetCloudDriver --pathParam driver_name:AWS
83-
./mayfly api --service spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName:aws-config01
80+
./mayfly api --service cb-spider --list
81+
./mayfly api --service cb-spider --action ListCloudOS
82+
./mayfly api --service cb-spider --action GetCloudDriver --pathParam driver_name:AWS
83+
./mayfly api --service cb-spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName=aws-config01
84+
./mayfly api --service cb-tumblebug --action Getmcivm --pathParam "nsId:ns01 mciId:mci01 vmId:vm01" --queryString "option=status&accessInfo=showSshKey"
85+
./mayfly api --service cm-beetle --action Deleteinfra --pathParam "nsId:mig01 mciId:mmci01" --queryString "option=terminate"
8486
`,
8587
PersistentPreRun: func(cmd *cobra.Command, args []string) {
8688
//fmt.Printf("len(args) : %d\n", len(args))
@@ -450,8 +452,8 @@ func init() {
450452
apiCmd.PersistentFlags().StringVarP(&actionName, "action", "a", "", "Action to perform")
451453
//apiCmd.PersistentFlags().StringVarP(&method, "method", "m", "", "HTTP Method")
452454
apiCmd.PersistentFlags().BoolVarP(&isVerbose, "verbose", "v", false, "Show more detail information")
453-
apiCmd.PersistentFlags().StringVarP(&pathParam, "pathParam", "p", "", "Variable path info set \"key1:value1 key2:value2\" for URIs")
454-
apiCmd.PersistentFlags().StringVarP(&queryString, "queryString", "q", "", "Use if you have a query string to add to URIs")
455+
apiCmd.PersistentFlags().StringVarP(&pathParam, "pathParam", "p", "", "Variable path info set \"key1:value1 key2:value2\" for URIs (separated by space)")
456+
apiCmd.PersistentFlags().StringVarP(&queryString, "queryString", "q", "", "Query string to add to URIs (format: \"param1=value1\" or \"param1=value1&param2=value2\")")
455457

456458
apiCmd.Flags().BoolVarP(&isListMode, "list", "l", false, "Show Service or Action list")
457459
apiCmd.PersistentFlags().StringVarP(&sendData, "data", "d", "", "Data to send to the server")

conf/docker/tool/mayfly

-8 Bytes
Binary file not shown.

docs/cm-mayfly-api.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,30 @@ serviceActions:
141141
resourcePath: /driver/{driver_name}
142142
```
143143

144-
`{driver_name}`처럼 {}로 지정된 액션의 경우에는, {}안에 있는 변수명이 매개변수 이름이되며, 사용자로부터 `-p` 또는 `--pathParam` 플래그를 이용해서 `--pathParam driver_name:AWS` 형태로 값을 전달 받을 수 있습니다.
144+
**PathParam 사용법**
145+
`{driver_name}`처럼 {}로 지정된 액션의 경우에는, {}안에 있는 변수명이 매개변수 이름이되며, 사용자로부터 `-p` 또는 `--pathParam` 플래그를 이용해서 `--pathParam driver_name:AWS` 형태로 값을 전달 받을 수 있습니다.
146+
여러 개의 PathParam이 필요한 경우 공백으로 구분하여 `"key1:value1 key2:value2"` 형태로 지정합니다.
145147

146148
```
147-
$ ./mayfly api --service spider --action GetCloudDriver --pathParam driver_name:AWS
149+
$ ./mayfly api --service cb-spider --action GetCloudDriver --pathParam driver_name:AWS
150+
151+
$ ./mayfly api -s cb-spider -a GetCloudDriver -p driver_name:AWS
152+
153+
$ ./mayfly api -s cb-spider -a GetCloudDriver -p driver_name:GCP
154+
```
148155

149-
$ ./mayfly api -s spider -a GetCloudDriver -p driver_name:AWS
156+
**QueryString 사용법**
157+
REST API에 쿼리 문자열이 필요한 경우 `-q` 또는 `--queryString` 플래그를 사용합니다.
158+
쿼리 문자열은 `param=value` 형태로 지정하며, 여러 개인 경우 `&`로 구분합니다.
159+
`?`는 자동으로 추가되므로 생략 가능하지만, 포함해도 정상 동작합니다.
150160

151-
$ ./mayfly api -s spider -a GetCloudDriver -p driver_name:GCP
161+
```
162+
# 단일 쿼리 문자열
163+
$ ./mayfly api -s cb-spider -a GetRegionZone -p region_name:ap-northeast-3 -q ConnectionName=aws-config01
164+
$ ./mayfly api -s cb-spider -a GetRegionZone -p region_name:ap-northeast-3 -q "?ConnectionName=aws-config01"
165+
166+
# 복수 쿼리 문자열 (&로 구분)
167+
$ ./mayfly api -s cb-tumblebug -a Getmcivm -p "nsId:ns01 mciId:mci01 vmId:vm01" -q "option=status&accessInfo=showSshKey"
152168
```
153169

154170
예로 설명드렸던, ListCloudOS와 GetCloudDriver 액션들의 최종 정의 형태는 아래와 같습니다.
@@ -222,10 +238,12 @@ Base Paht: /tumblebug
222238
Call the action of the service defined in api.yaml. For example:
223239
$ ./mayfly api --help
224240
$ ./mayfly api --list
225-
$ ./mayfly api --service spider --list
226-
$ ./mayfly api --service spider --action ListCloudOS
227-
$ ./mayfly api --service spider --action GetCloudDriver --pathParam driver_name:AWS
228-
$ ./mayfly api --service spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName:aws-config01
241+
$ ./mayfly api --service cb-spider --list
242+
$ ./mayfly api --service cb-spider --action ListCloudOS
243+
$ ./mayfly api --service cb-spider --action GetCloudDriver --pathParam driver_name:AWS
244+
$ ./mayfly api --service cb-spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName=aws-config01
245+
$ ./mayfly api --service cb-tumblebug --action Getmcivm --pathParam "nsId:ns01 mciId:mci01 vmId:vm01" --queryString "option=status&accessInfo=showSshKey"
246+
$ ./mayfly api --service cm-beetle --action Deleteinfra --pathParam "nsId:mig01 mciId:mmci01" --queryString "option=terminate"
229247
230248
Usage:
231249
mayfly api [flags]
@@ -254,8 +272,8 @@ Use "mayfly api [command] --help" for more information about a command.
254272
### 주요 flag 설명
255273
--service (-s) : 호출할 서비스의 이름을 지정합니다.
256274
--action (-a) : 호출할 액션의 이름을 지정합니다.
257-
--pathParam (-p) : 경로 파라미터를 지정합니다.
258-
--queryString (-q) : 쿼리 문자열을 지정합니다.
275+
--pathParam (-p) : 경로 파라미터를 지정합니다. (형식: "key1:value1 key2:value2")
276+
--queryString (-q) : 쿼리 문자열을 지정합니다. (형식: "param1=value1" 또는 "param1=value1&param2=value2")
259277
--data (-d) : 서버에 전송할 데이터를 지정합니다.
260278
--file (-f) : 서버에 전송할 데이터가 포함된 파일을 지정합니다.
261279
--output (-o) : 서버 응답을 파일에 저장합니다.
@@ -272,11 +290,12 @@ $ ./mayfly api -s <service_name> -a <action_name>
272290
```
273291

274292
만약, 가변 경로와 쿼리 스트링이 존재하는 경우 아래처럼 지정합니다.
275-
전달할 경로 파라메터가 많은 경우 "key1:value1 key2:value2"처럼 각각은 공백으로 구분합니다.
293+
전달할 경로 파라메터가 많은 경우 "key1:value1 key2:value2"처럼 각각은 공백으로 구분합니다.
294+
쿼리 문자열은 "param1=value1" 형태로 지정하며, 여러 개인 경우 "&"로 구분합니다.
276295
```
277-
$ ./mayfly api --service <service_name> --action <action_name> --pathParam <key1:value1 key2:value2> --queryString <query_string>
296+
$ ./mayfly api --service <service_name> --action <action_name> --pathParam "key1:value1 key2:value2" --queryString "param1=value1&param2=value2"
278297
279-
$ ./mayfly api -s <service_name> -a <action_name> -p <key1:value1 key2:value2> -queryString <query_string>
298+
$ ./mayfly api -s <service_name> -a <action_name> -p "key1:value1 key2:value2" -q "param1=value1&param2=value2"
280299
```
281300

282301
### 환경 설정 파일과 실행 명령의 맵핑 관계
@@ -286,12 +305,29 @@ $ ./mayfly api -s <service_name> -a <action_name> -p <key1:value1 key2:value2> -
286305

287306
### 기본 사용 예시
288307
```
308+
# 도움말 및 목록 조회
289309
$ ./mayfly api --help
290310
$ ./mayfly api --list
291311
$ ./mayfly api --service cb-spider --list
312+
313+
# 단순 액션 호출
292314
$ ./mayfly api --service cb-spider --action ListCloudOS
315+
316+
# PathParam 사용 (가변 경로)
293317
$ ./mayfly api --service cb-spider --action GetCloudDriver --pathParam driver_name:AWS
294-
$ ./mayfly api --service cb-spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName:aws-config01
318+
319+
# PathParam + QueryString 사용 (단일 쿼리)
320+
$ ./mayfly api --service cb-spider --action GetRegionZone --pathParam region_name:ap-northeast-3 --queryString ConnectionName=aws-config01
321+
322+
# PathParam + QueryString 사용 (복수 쿼리 - &로 구분)
323+
$ ./mayfly api --service cb-tumblebug --action Getmcivm --pathParam "nsId:ns01 mciId:mci01 vmId:vm01" --queryString "option=status&accessInfo=showSshKey"
324+
325+
# 마이그레이션된 인프라 삭제 (cm-beetle 사용 예시)
326+
$ ./mayfly api --service cm-beetle --action Deleteinfra --pathParam "nsId:mig01 mciId:mmci01" --queryString "option=terminate"
327+
328+
# 또는 짧은 플래그 사용
329+
$ ./mayfly api -s cb-tumblebug -a Getmcivm -p "nsId:ns01 mciId:mci01 vmId:vm01" -q "option=status&accessInfo=showSshKey"
330+
$ ./mayfly api -s cm-beetle -a Deleteinfra -p "nsId:mig01 mciId:mmci01" -q "option=terminate"
295331
```
296332

297333

mayfly

-24 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)