swagger: "2.0"
info:
  title: GraphQL API
  description: API for querying DB.
  version: 1.0.0
host: 'adm.cloud.com'
schemes:
  - https
# tags are used for organizing operations
tags:
  - name: graphql
    description: GraphQL API
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  UserSecurity:
    type: basic
security:
  - UserSecurity: []
parameters:
  authParam:
      in: header
      name: Authorization
      type: string
      required: true
      description: Session Id for authentication.Should be mentioned in the format CwcAuth bearer=sessionIdValue.
paths:
  /massvc/{customerid}/graphql:
    post:
      summary: Query Analytics related models.
      operationId: post_graphql
      tags:
        - graphql
      description: GraphQL API Endpoint provides flexible querying capabilities. A basic sample GraphQL query looks like:- <br>
       ```query sampleQuery { customerTable (where:[{rpt_sample_time_gt:1580894702}],interval:"DAY",fieldArgs:[{name:transactionid,aggFunc:COUNT}],groupBy:[ip_address,vservername],orderBy:[rpt_sample_time_DESC],limit:100,offset:20){TotalCount:transactionid  ip_address vservername}}```<br>
       
       The basic schema for some of the GraphQL parameters are as follows:-<br>
            `query queryName{tableName (` <br><br>
              `where:`Array of whereCondition Objects. Every Object must have atleast one whereCondition as key-value pair. **Format**:-[{columnName_filter:value]. The list of available filters is given in Functionality section below. <br>**Example**:`[{rpt_sample_time_gt:1580894702}],`,<br><br>
              `interval:` Accepts either MINUTE,HOUR or DAY (for aggregated-data queries)<br>**Example**:-`"DAY",`<br><br>
              `fieldArgs:`Array of fieldArgs Objects for aggregation operations. Every Object must have columnName against **name** and aggregationFunction against **aggFunc**. **Format**:[{name:columnName,aggFunc:functionName}], The list of available aggregation functions is given in Functionality section below.<br> **Example**:- `[{name:transactionid,aggFunc:COUNT}],`<br><br>
              `groupBy:` Array of columnNames to group data by. It must be used along with aggregation functions. <br>**Example**:- `[ip_address,vservername],`<br><br>
              `orderBy:` Array of items to sort the result set. Every item is a columnName appended with '_ASC' or '_DESC' to determine the sorting direction.<br>**Example**:- `[rpt_sample_time_DESC],`<br><br>
              `limit:` Integer to limit number of result rows returned.<br>**Example**:- `100,`<br><br>
              `offset:` Integer to skip the number of rows before beginning to return the result.<br>**Example**:- `20`    <br>`)
              {`<br><br>Selection columns<br>**Example**:- `TotalCount:transactionid `<br>`ip_address`<br>`vservername`<br><br>`}}`<br><br>
              
              _FUNCTIONALITY SECTION_:-
              
              **1) Filters available for where conditions:-**<br><br>
                **_a) For String columns:<br>_**
                [
                columnName, columnName_not, columnName_contains, columnName_notcontains, columnName_startswith, columnName_notstartswith, columnName_endswith, columnName_notendswith, columnName_regex]<br>
                _Example:-_ vservername_startswith:"Lbv"<br><br>
                **_b) For Integer Columns:<br>_**
                [columnName, columnName_not, columnName_gt, columnName_gte, columnName_lt, columnName_lte, columnName]<br>
                _Example:-_ total_bytes_gte:200 (total_bytes greater than 200)<br><br>
                **_c) For availability in array:<br>_**
                [columnName_in,columnName_notin]<br>
                _Example:-_ ip_address_in:["1.1.1.1","0.0.0.0"]<br><br>
                
              **2) Aggregation Functions available in fieldArgs:<br>**
                [SUM,AVG,AVGZ,MIN,MAX,COUNT,COUNTD,DISTINCT]<br>
                _Example:-_ fieldArgs:[{name:ip_address,aggFunc:COUNTD] for count of Distinct IP addresses. <br><br> 
                **_The models that use this endpoint are:_**<br>
                * aa_transaction_l2<br>
                * app_summary<br>
                * aa_service_graph_nodes<br>
                * aa_service_graph_edges<br>
                * ns_event.<br>    
                * k8_service_nodes.<br>    
                * instance_score.<br>    
                * event.<br>    
                * app_summary_aa_client_summary_merged.<br>    
                * af_bot_attack_events_l2.<br>    
                * active_event.<br>    
                * aa_transaction_l2.<br>    
                * aa_ind_details_l2.<br>    
                * aa_events_l2.<br>    
                * aa_client_detail_events_l2.<br>    
                * aa_adc_prediction_l2.<br>    
                * app_summary.<br>    
                * app_health_summary.<br>    
                * app_counter_data.<br>    
                * af_bot_attack_summary.<br>    
                * af_bot_attack_details.<br>    
                * aa_vsvr_svc_mapping.<br>    
                * aa_vserver_transactions_summary.<br>    
                * aa_vserver_transaction_details.<br>    
                * aa_vserver_counters.<br>    
                * aa_vserver_client_summary.<br>    
                * aa_sys_counters.<br>    
                * aa_svc_counters.<br>    
                * aa_service_graph_nodes.<br>    
                * aa_service_graph_edges.<br>    
                * aa_client_summary.<br>    
                * aa_client_exp_score_summary.<br>    
                * aa_client_exp_score_details.<br>    
                * aa_app_prediction.<br>    
                
                
      security:
        - UserSecurity: []
      parameters:
        - $ref: '#/parameters/authParam'
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: body
          name: GraphQLRequestBody
          required: true
          schema:
            type: object
            required:
              - query
            properties:
              query:
                type: string
                example: 'query TRANSACTIONS_INFO{ aa_transaction_l2(limit:10,where: [{appresponsetime_gte: 500}, {ip_address_contains: "10.106", svcname_not: "citrix_1"}],orderBy: [rpt_sample_time_DESC],groupBy: [ctnsappname], fieldArgs: [{name: client_rtt, aggFunc: MIN}, {name: rpt_sample_time, aggFunc: MAX}, {name: ns_processing_time, aggFunc: AVG}]){ctnsappname ns_processing_time client_rtt rpt_sample_time }}'
      responses:
        200:
          description: Successful GraphQL response. Returns JSON which has resulting rows as a list of dictionaries.
          schema:
            type: object
            properties:
              data:
                type: object
                example: {
                          "data": {
                              "aa_transaction_l2": [
                                  {
                                      "ctnsappname": "mas_119",
                                      "ns_processing_time": 714.5,
                                      "client_rtt": 1,
                                      "rpt_sample_time": 1545198009.0
                                  },
                                  {
                                      "ctnsappname": "dns_154",
                                      "ns_processing_time": 0.0,
                                      "client_rtt": 1,
                                      "rpt_sample_time": 1545198009.0
                                  }
                              ]
                          }
                      }
        400:
          description: Bad Request(POST body sent invalid JSON).
        401:
          $ref: '#/responses/UnauthorizedError'
        500:
          description: Internal Server Error.
        
  /massvc/{customerid}/graphql/config:
    post:
      summary: Query Syslog and Infra-Analytics models.
      tags:
        - graphql
      operationId: post_graphqlconfig
      description: The '/graphql/config' endpoint supports all the salient features and format mentioned above for '/graphql' endpoint, but for Syslog and Infra-Analytics models.<br><br> **_The models that use this endpoint are:-_**<br>* syslog_messages<br>* syslog_generic.<br>* instance_score.
      security:
        - UserSecurity: []
      parameters:
        - $ref: '#/parameters/authParam'
        - in: path
          name: customerid
          type: string
          required: true
          description: Customer Id of the user
        - in: body
          name: GQLRequestBody
          required: true
          schema:
            type: object
            required:
              - query
            properties:
              query:
                type: string
                example: 'query SYSLOG_INFO{syslog_messages(limit: 10,  where: {severity_startswith: "INF"}, orderBy: [system_gmt_time_ASC]) { severity system_gmt_time  }}'
      responses:
        200:
          description: Successful GraphQL response. Returns JSON which has resulting rows as a list of dictionaries.
          schema:
            type: object
            properties:
              data:
                type: object
                example: {
                            "data": {
                                "syslog_messages": [
                                    {
                                        "severity": "INFO",
                                        "system_gmt_time": 1579577257
                                    },
                                    {
                                        "severity": "INFO",
                                        "system_gmt_time": 1579581453
                                    }
                                ]
                            }
                        }
        400:
          description: Bad Request (Please check JSON validity).
        401:
          $ref: '#/responses/UnauthorizedError'
        500:
          description: Internal Server Error.
          
responses:
  UnauthorizedError:
    description: Authentication information is missing or invalid.
          
          
          
