{
  "swagger": "2.0" ,
  "info": {
    "title": "CQA Test App API" ,
    "description": "CQA Test Application" ,
    "version": "1.0"
  },

  "tags": [
    {
      "name": "TestAPI" ,
      "description": "For Testing APIs"
    },
    {
      "name": "Webhooks" ,
      "description": "For Testing Webhooks"
    },
    {
      "name": "Authentication" ,
      "description": "For Athenz Authentication"
    },
    {
      "name": "TestFOSAPI" ,
      "description": "For Testing Flava Object Storage"
    }
  ],

  "paths": {

    "/": {
      "get": {
        "tags": [
          "TestAPI"
        ] ,
        "summary": "Test root path" ,
        "description": "Root Path for CQA Test App" ,
        "responses": {
          "200": {
            "description": "Root Path ok"
          }
        }
      }
    } ,

    "/test": {
      "get": {
        "tags": [
          "TestAPI"
        ] ,
        "summary": "Test Ping path" ,
        "description": "Just for ping test" ,
        "responses": {
          "200": {
            "description": "Ping Test ok"
          }
        }
      }
    } ,

    "/monitor/l7check": {
      "get": {
        "tags": [
          "TestAPI"
        ] ,
        "summary": "Health Check path for L7LB" ,
        "description": "Health Check basic path for L7LB Testing" ,
        "responses": {
          "200": {
            "description": "Health Check ok"
          }
        }
      }
    } ,

    "/run_cmd": {
      "post": {
        "tags": [
          "TestAPI"
        ] ,
        "summary": "Run shell command on server" ,
        "description": "Run shell command on server with cmd data" ,
        "parameters": [
          {
            "name": "cmd" ,
            "in": "body" ,
            "description": "Shell Command for sending server" ,
            "required": true ,
            "schema": {
              "type": "object" ,
              "properties": {
                "cmd": {
                  "type": "string" ,
                  "default": "pwd"
                }
              }
            }
          }
        ] ,
        "responses": {
          "200": {
            "description": "Run shell command on server ok"
          } ,
          "400": {
            "description": "Send wrong cmd data format or empty cmd data"
          }
        }
      }
    },

    "/webhook": {
      "post": {
        "tags": [
          "Webhooks"
        ],
        "summary": "Create a webhook",
        "parameters": [
          {
            "in": "body",
            "name": "payload",
            "description": "The payload of the webhook",
            "required": true,
            "schema": {
              "type": "object",
              "example": {
                "property1": "value1",
                "property2": "value2"
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Webhook received successfully"
          },
          "400": {
            "description": "Bad request"
          }
        }
      }
    },

    "/run_iperf": {
      "post": {
        "tags": [
          "TestAPI"
        ] ,
        "summary": "Run iperf3 test" ,
        "description": "Run iperf3 test client to iperf host server with parameter" ,
        "parameters": [
          {
            "name": "payload" ,
            "in": "body" ,
            "description": "host server ip or name for iperf test" ,
            "required": true ,
            "schema": {
              "type": "object" ,
              "properties": {
                "host_ip": {
                  "type": "string" ,
                  "default": "127.0.0.1"
                },
                "host_port": {
                  "type": "string" ,
                  "default": "5201"
                },
                "duration": {
                  "type": "int" ,
                  "default": 5
                },
                "protocol": {
                  "type": "string" ,
                  "default": "tcp"
                }
              }
            }
          }
        ] ,
        "responses": {
          "200": {
            "description": "Run iperf3 testing on server ok"
          } ,
          "400": {
            "description": "Bad Request, some params are empty or None.. \n Bad Request, protocol param must input 'tcp' or 'udp'.."
          },
          "500": {
            "description": "Internal Server Error, There is no \"iperf3\" in server, cannot run iperf testing.. \n Internal Server Error, iperf3 Error={error msg}.."
          }
        }
      }
    },

    "/athenz_access_token": {
      "post": {
        "tags": ["Authentication"],
        "summary": "Generate Athenz Access Token",
        "description": "Returns an access token for the specified service account name and provider domain",
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "description": "Service account name and provider domain",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "account_name": {
                  "type": "string",
                  "example": "qa-tester1"
                },
                "provider_domain": {
                  "type": "string",
                  "example": "flava-server.stage.flava-api-test"
                }
              },
              "required": ["account_name", "provider_domain"]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response"
          },
          "400": {
            "description": "Bad Request"
          },
          "500": {
            "description": "Internal Server Error"
          }
        }
      }
    },

    "/test_fos/buckets/{bucket_name}/{object_name}": {
      "put": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "Download and update test scenario",
        "description": "Do an integration test for the below flow \n : Flava CDN <-> Flava FEP <-> Flava ALB <-> Flava VM <-> Flava object storage ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "object_name",
            "in": "path",
            "description": "The name of the object (default=fos_test.txt)",
            "default": "fos_test.txt",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "description": "The data user wants to put",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "string",
                  "description": "New data to put in the FOS",
                  "example": "Please put the content"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully put the data into FOS"
          },
          "400": {
            "description": "Bad Request, invalid bucket or object"
          },
          "401": {
            "description": "Unauthorized, Authentication is required or failed"
          },
          "403": {
            "description": "Forbidden, You don't have permission to download or upload"
          },
          "404": {
            "description": "Not Found, The file to download does not exist "
          },
          "409": {
            "description": "Conflict, The file to upload already exists or there is a conflict"
          },
          "500": {
            "description": "Internal Server Error , An unexpected error occurred while processing on the server"
          }
        }
      }
    },

    "/get_fos_object/{bucket_name}/{object_name}": {
      "get": {
        "tags": [
          "TestFOSAPI"
        ] ,
        "summary": "GET FOS Object file API" ,
        "description": "GET FOS Object file for testing" ,
        "responses": {
          "200": {
            "description": "GET FOS Object file success"
          }
        },
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "object_name",
            "in": "path",
            "description": "The name of the object (default=fos_test.txt)",
            "default": "fos_test.txt",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully get object into FOS"
          },
          "400": {
            "description": "Bad Request, invalid bucket or object"
          },
          "401": {
            "description": "Unauthorized, Authentication is required or failed"
          },
          "403": {
            "description": "Forbidden, You don't have permission to get object"
          },
          "404": {
            "description": "Not Found, The file to get does not exist "
          },
          "500": {
            "description": "Internal Server Error , An unexpected error occurred while processing on the server"
          }
        }
      }
    },

      "/test_fos_crud/{bucket_name}/{object_name}": {
      "post": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "FOS CRUD test scenario",
        "description": "Do an CRUD feature test for FOS ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "object_name",
            "in": "path",
            "description": "The name of the object",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "description": "The data user wants to update",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "string",
                  "description": "Input Update data for CRUD test",
                  "example": "Please put the content"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successfully CRUD Testing for FOS"
          },
          "400": {
            "description": "Bad Request, invalid bucket or object"
          },
          "401": {
            "description": "Unauthorized, Authentication is required or failed"
          },
          "403": {
            "description": "Forbidden, You don't have permission to download or upload"
          },
          "404": {
            "description": "Not Found, target FOS bucket does not exist "
          },
          "409": {
            "description": "Conflict, already exists or there is a conflict"
          },
          "500": {
            "description": "Internal Server Error , An unexpected error occurred while processing on the server"
          }
        }
      }
    },

    "/create_fos_object/{bucket_name}/{object_name}": {
       "put": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "FOS CRUD individual test",
        "description": "Do an Create(upload object) feature test for FOS ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "object_name",
            "in": "path",
            "description": "The name of the object",
            "required": true,
            "type": "string"
          },
          {
            "name": "body",
            "in": "body",
            "description": "The data user wants to upload",
            "required": true,
            "schema": {
              "type": "object",
              "properties": {
                "data": {
                  "type": "string",
                  "description": "Input data for Create test",
                  "example": "Please put the content"
                }
              }
            }
          }
        ],
        "responses": {
          "200": {"description": "Successfully Create Testing for FOS"},
          "400": {"description": "Bad Request, invalid bucket or object"},
          "401": {"description": "Unauthorized, Authentication is required or failed"},
          "403": {"description": "Forbidden, You don't have permission to download or upload"},
          "404": {"description": "Not Found, target FOS bucket does not exist "},
          "409": {"description": "Conflict, already exists or there is a conflict"},
          "500": {"description": "Internal Server Error , An unexpected error occurred while processing on the server"}
        }
      }
    },

    "/delete_fos_object/{bucket_name}/{object_name}": {
       "delete": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "FOS CRUD individual test",
        "description": "Do an Delete feature test for FOS ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "object_name",
            "in": "path",
            "description": "The name of the object",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {"description": "Successfully Delete Testing for FOS"},
          "400": {"description": "Bad Request, invalid bucket or object"},
          "401": {"description": "Unauthorized, Authentication is required or failed"},
          "403": {"description": "Forbidden, You don't have permission to download or upload"},
          "404": {"description": "Not Found, target FOS bucket does not exist "},
          "409": {"description": "Conflict, already exists or there is a conflict"},
          "500": {"description": "Internal Server Error , An unexpected error occurred while processing on the server"}
        }
      }
    },

    "/list_objects/{bucket_name}": {
       "get": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "FOS CRUD individual test",
        "description": "Do an GET List feature test for FOS ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          }
        ],
        "responses": {
          "200": {"description": "Successfully Get list Testing for FOS"},
          "400": {"description": "Bad Request, invalid bucket or object"},
          "401": {"description": "Unauthorized, Authentication is required or failed"},
          "403": {"description": "Forbidden, You don't have permission to download or upload"},
          "404": {"description": "Not Found, target FOS bucket does not exist "},
          "409": {"description": "Conflict, already exists or there is a conflict"},
          "500": {"description": "Internal Server Error , An unexpected error occurred while processing on the server"}
        }
      }
    },
    "/update_bucket/{bucket_name}/{action}": {
       "post": {
        "tags": [
          "TestFOSAPI"
        ],
        "summary": "FOS CRUD individual test",
        "description": "Do an Update feature test for FOS ",
        "parameters": [
          {
            "name": "bucket_name",
            "in": "path",
            "description": "The name of the bucket (default=cqa-test-bucket)",
            "default": "cqa-test-bucket",
            "required": true,
            "type": "string"
          },
          {
            "name": "action",
            "in": "path",
            "description": "Set the Static website configuration (enable or disable)",
            "required": true,
            "type": "string",
            "enum": ["enable", "disable"],
            "example": "enable"
          }
        ],
        "responses": {
          "200": {"description": "Successfully Update bucket Testing for FOS"},
          "400": {"description": "Bad Request, invalid bucket or object"},
          "401": {"description": "Unauthorized, Authentication is required or failed"},
          "403": {"description": "Forbidden, You don't have permission to download or upload"},
          "404": {"description": "Not Found, target FOS bucket does not exist "},
          "409": {"description": "Conflict, already exists or there is a conflict"},
          "500": {"description": "Internal Server Error , An unexpected error occurred while processing on the server"}
        }
      }
    }
  }
}