influxdata / openapi

An OpenAPI specification for influx (cloud/oss) apis.
MIT License
17 stars 10 forks source link

/telegrafs POST are requestBody properties up-to-date? #611

Open karel-rehor opened 1 year ago

karel-rehor commented 1 year ago

After comparing a POST request to /telegrafs sent from the UI to the definitions in openapi (components/schemas/TelegrafPluginRequest) there appears to be a number of differences.

The UI request body looks like this.

{
   "name":"Ferret Config",
   "description":"asdf",
   "agent":{"collectionInterval":10000},
   "orgID":"9c5955fc99a60b8f",
   "plugins":
      [
         {
            "name":"influxdb_v2",
            "type":
            "output",
            "config":
               {
                  "urls":
                     [
                        "https://twodotoh-dev-bonitoo-kk.remocal.influxdev.co"
                     ],
                  "token":"$INFLUX_TOKEN",
                  "organization":"dev",
                  "bucket":"devbucket"
               }
         },
         {
            "name":"cpu",
            "type":"input"
        }
      ]
}

There are five top level properties name, description, agent, orgID, plugins.

The document components/schemas/TelegrafPluginRequest.yml also includes fields for metadata and config, however it makes no mention of an agent field. Also during blackbox testing, when sending a request body with a combination {name, description, orgID, config} the server returns HTTP 500.

The fields metadata and config do show up as part of the response, however the response config field seems to ignore the config field sent in the request. I see the word "legacy" in the comments of the yaml document, So, the question arises: are these schema definitions up-to-date?

# This defines the 'legacy' `TelegrafConfigDecode` type in the api.
type: object
properties:
  name:
    type: string
  description:
    type: string
  plugins:
    type: array
    items:
      type: object
      properties:
        type:
          type: string
        name:
          type: string
        alias:
          type: string
        description:
          type: string
        config:
          type: string
  metadata:
    type: object
    properties:
      buckets:
        type: array
        items:
          type: string
  config:
    type: string
  orgID:
    type: string

Related Issue

610

karel-rehor commented 1 year ago

As a further note, the config field needs to be in TOML format, otherwise it causes an HTTP 500 error.