From 814c4080cad6aafdbb21bfb568c1568ea36a6cde Mon Sep 17 00:00:00 2001 From: Christopher Henn Date: Mon, 29 Jul 2019 14:41:32 -0700 Subject: [PATCH] refactor(ui): inline API type generation Part of #14482 --- http/swagger.yml | 888 +- ui/cypress/e2e/buckets.test.ts | 2 +- ui/cypress/e2e/collectors.test.ts | 2 +- ui/cypress/e2e/dashboardsIndex.test.ts | 2 +- ui/cypress/e2e/dashboardsView.test.ts | 2 +- ui/cypress/e2e/explorer.test.ts | 2 +- ui/cypress/e2e/labels.test.ts | 4 +- ui/cypress/e2e/scrapers.test.ts | 2 +- ui/cypress/e2e/tasks.test.ts | 2 +- ui/cypress/e2e/tokens.test.ts | 10 +- ui/cypress/e2e/variables.test.ts | 2 +- ui/package.json | 6 +- ui/src/alerting/actions/checks.ts | 44 +- ui/src/alerting/actions/notificationRules.ts | 58 +- ui/src/alerting/components/CheckCard.tsx | 12 +- ui/src/alerting/components/EditCheckEO.tsx | 4 +- ui/src/alerting/components/NewCheckEO.tsx | 4 +- .../components/NotificationRuleCard.tsx | 16 +- ui/src/alerting/constants/index.ts | 53 +- .../components/BucketsSelector.tsx | 2 +- .../components/BucketsTabBody.tsx | 2 +- .../components/BucketsTokenOverlay.tsx | 4 +- ui/src/authorizations/utils/permissions.ts | 3 +- ui/src/buckets/actions/index.ts | 49 +- .../buckets/components/BucketOverlayForm.tsx | 10 +- .../components/CreateBucketOverlay.tsx | 12 +- .../buckets/components/RenameBucketForm.tsx | 3 +- ui/src/buckets/components/Retention.tsx | 2 +- .../buckets/components/RetentionDuration.tsx | 3 +- .../components/UpdateBucketOverlay.tsx | 23 +- ui/src/client/index.ts | 8149 +++++++++++++++++ ui/src/dashboards/actions/notes.ts | 5 +- ui/src/dashboards/apis/index.ts | 104 +- ui/src/dashboards/components/NewVEO.tsx | 4 +- .../dashboard_index/DashboardCard.tsx | 17 +- ui/src/dashboards/constants/cellEditor.ts | 10 +- ui/src/dashboards/resources.ts | 7 +- .../components/BucketsDropdown.tsx | 2 +- .../CollectorsStepSwitcher.tsx | 2 +- .../collectorsWizard/CollectorsWizard.tsx | 3 +- .../select/SelectCollectorsStep.tsx | 2 +- .../select/StreamingSelector.tsx | 2 +- .../lineProtocolWizard/LineProtocolWizard.tsx | 2 +- .../verify/LineProtocolStepSwitcher.tsx | 2 +- ui/src/labels/actions/index.ts | 4 +- ui/src/labels/components/LabelCard.tsx | 12 +- ui/src/labels/components/LabelList.tsx | 13 +- ui/src/labels/components/LabelsTab.tsx | 12 +- .../labels/components/UpdateLabelOverlay.tsx | 8 +- ui/src/labels/selectors/index.ts | 4 +- .../components/CreateOrgOverlay.tsx | 15 +- .../scrapers/components/CreateScraperForm.tsx | 2 +- .../components/CreateScraperOverlay.tsx | 4 +- ui/src/scrapers/components/Scrapers.tsx | 4 +- ui/src/shared/components/CheckPlot.tsx | 14 +- .../shared/components/ColorSchemeDropdown.tsx | 4 +- ui/src/shared/components/GaugeChart.tsx | 4 +- ui/src/shared/components/HeatmapPlot.tsx | 4 +- ui/src/shared/components/HistogramPlot.tsx | 4 +- ui/src/shared/components/RefreshingView.tsx | 29 +- ui/src/shared/components/ScatterPlot.tsx | 4 +- ui/src/shared/components/SingleStat.tsx | 6 +- ui/src/shared/components/ThresholdMarkers.tsx | 16 +- .../components/ThresholdsSettings.test.tsx | 9 +- ui/src/shared/components/ViewSwitcher.tsx | 32 +- ui/src/shared/components/XYPlot.tsx | 4 +- ui/src/shared/components/cells/Cell.tsx | 13 +- .../shared/components/cells/CellContext.tsx | 4 +- ui/src/shared/components/cells/View.tsx | 4 +- .../inlineLabels/InlineLabelPopover.tsx | 4 +- .../components/inlineLabels/InlineLabels.tsx | 16 +- .../inlineLabels/InlineLabelsEditor.tsx | 28 +- .../inlineLabels/InlineLabelsList.tsx | 4 +- ui/src/shared/components/tables/TableCell.tsx | 4 +- .../shared/components/tables/TableGraph.tsx | 4 +- .../components/tables/TableGraphTable.tsx | 4 +- .../components/tables/TableGraphTransform.tsx | 4 +- .../shared/components/tables/TableGraphs.tsx | 4 +- ui/src/shared/constants/colorOperations.ts | 6 +- .../shared/utils/mocks/resourceToTemplate.ts | 25 +- .../shared/utils/resourceToTemplate.test.ts | 4 +- ui/src/shared/utils/resourceToTemplate.ts | 4 +- ui/src/shared/utils/useVisDomainSettings.ts | 2 +- ui/src/shared/utils/view.ts | 113 +- ui/src/shared/utils/vis.ts | 22 +- .../components/TasksOptionsBucketDropdown.tsx | 3 +- ui/src/telegrafs/components/Collectors.tsx | 4 +- ui/src/timeMachine/actions/index.ts | 6 +- ui/src/timeMachine/components/Queries.tsx | 5 +- .../components/QueriesSwitcher.tsx | 4 +- .../components/view_options/Geom.tsx | 26 +- .../view_options/HeatmapOptions.tsx | 8 +- .../view_options/HistogramOptions.tsx | 4 +- .../components/view_options/LineOptions.tsx | 6 +- .../view_options/OptionsSwitcher.tsx | 18 +- .../view_options/ScatterOptions.tsx | 6 +- .../view_options/SingleStatOptions.tsx | 6 +- .../components/view_options/TableOptions.tsx | 4 +- ui/src/timeMachine/constants/visGraphics.tsx | 58 +- ui/src/timeMachine/reducers/index.test.ts | 62 +- ui/src/timeMachine/reducers/index.ts | 53 +- ui/src/timeMachine/selectors/index.ts | 18 +- ui/src/types/alerting.ts | 35 +- ui/src/types/buckets.ts | 6 +- ui/src/types/colors.ts | 47 +- ui/src/types/dashboards.ts | 337 +- ui/src/types/labels.ts | 12 +- ui/src/variables/components/VariableCard.tsx | 2 +- ui/yarn.lock | 90 +- 109 files changed, 9510 insertions(+), 1326 deletions(-) create mode 100644 ui/src/client/index.ts diff --git a/http/swagger.yml b/http/swagger.yml index 322aa94cd2a..c23d90ed4fe 100644 --- a/http/swagger.yml +++ b/http/swagger.yml @@ -2841,19 +2841,19 @@ paths: application/json: schema: $ref: "#/components/schemas/Error" - /query/suggestions/{name}: - parameters: - - $ref: '#/components/parameters/TraceSpan' - - in: path - name: name - schema: - type: string - required: true - description: name of branching suggestion + '/query/suggestions/{name}': get: operationId: GetQuerySuggestionsName tags: - Query + parameters: + - $ref: '#/components/parameters/TraceSpan' + - in: path + name: name + schema: + type: string + required: true + description: name of branching suggestion responses: '200': description: Suggestions for next functions in call chain @@ -6962,8 +6962,7 @@ components: The extents of an axis in the form [lower, upper]. Clients determine whether bounds are to be inclusive or exclusive of their limits items: - type: integer - format: int64 + type: string label: description: label is a description of this Axis type: string @@ -6976,15 +6975,17 @@ components: base: description: Base represents the radix for formatting axis values. type: string + enum: ['', '2', '10'] scale: - $ref: '#/components/schemas/AxisScaleType' - AxisScaleType: + $ref: '#/components/schemas/AxisScale' + AxisScale: description: 'Scale is the axis formatting scale. Supported: "log", "linear"' type: string enum: ['log', 'linear'] DashboardColor: type: object description: Color defines an encoding of data value into color space + required: [id, type, hex, name, value] properties: id: description: ID is the unique id of the view color @@ -6996,6 +6997,9 @@ components: - min - max - threshold + - scale + - text + - background hex: description: Hex is the hex number of the color type: string @@ -7022,94 +7026,130 @@ components: visible: description: Indicates whether this field should be visible on the table type: boolean - LogViewProperties: - description: Contains the configuration for the log viewer + XYViewProperties: type: object required: - - columns - - shape - - type + - type + - geom + - queries + - shape + - axes + - colors + - legend + - note + - showNoteWhenEmpty properties: - columns: - description: Defines the order, names, and visibility of columns in the log - viewer table + type: + type: string + enum: [xy] + queries: type: array items: - "$ref": "#/components/schemas/LogViewerColumn" - example: - columns: - - name: severity - position: 0 - settings: - - type: label - value: icon - - type: label - value: text - - type: visibility - value: visible - - type: color - name: ruby - value: emergency - - type: color - name: rainforest - value: info - - type: displayName - value: Log Severity! - - name: messages - position: 1 - settings: - - type: visibility - value: hidden - LogViewerColumn: - description: Contains a specific column's settings. + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + axes: + $ref: '#/components/schemas/Axes' + legend: + $ref: '#/components/schemas/Legend' + xColumn: + type: string + yColumn: + type: string + shadeBelow: + type: boolean + geom: + $ref: '#/components/schemas/XYGeom' + XYGeom: + type: string + enum: [line, step, stacked, bar, monotoneX] + LinePlusSingleStatProperties: type: object required: - - name - - position - - settings + - type + - queries + - shape + - axes + - colors + - legend + - note + - showNoteWhenEmpty + - prefix + - suffix + - decimalPlaces properties: - name: - description: Unique identifier name of the column + type: type: string - position: - type: integer - format: int32 - settings: - description: Composable settings options for the column + enum: [line-plus-single-stat] + queries: type: array items: - description: Type and value and optional name of a setting. - type: object - required: - - type - - value - properties: - type: - type: string - value: - type: string - name: - type: string - example: - name: severity - position: 0 - settings: - - type: label - value: icon - - type: label - value: text - - type: visibility - value: visible - - type: color - name: ruby - value: emergency - - type: color - name: rainforest - value: info - - type: displayName - value: Log Severity! - ViewProperties: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + axes: + $ref: '#/components/schemas/Axes' + legend: + $ref: '#/components/schemas/Legend' + xColumn: + type: string + yColumn: + type: string + shadeBelow: + type: boolean + prefix: + type: string + suffix: + type: string + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' + ScatterViewProperties: + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - fillColumns + - symbolColumns + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix properties: + type: + type: string + enum: [scatter] queries: type: array items: @@ -7118,245 +7158,367 @@ components: description: Colors define color encoding of data into a visualization type: array items: - $ref: "#/components/schemas/DashboardColor" + type: string shape: type: string enum: ['chronograf-v2'] note: type: string - type: - $ref: "#/components/schemas/ViewType" showNoteWhenEmpty: description: if true, will display note when empty type: boolean - required: [type] - LinePlusSingleStatProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - axes: - $ref: '#/components/schemas/Axes' - legend: - $ref: '#/components/schemas/Legend' - prefix: - type: string - suffix: - type: string - decimalPlaces: - $ref: '#/components/schemas/DecimalPlaces' - XYViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - axes: - $ref: '#/components/schemas/Axes' - legend: - $ref: '#/components/schemas/Legend' - xColumn: - type: string - yColumn: - type: string - ShadeBelow: - type: boolean - geom: - $ref: '#/components/schemas/XYGeomType' - XYGeomType: - type: string - enum: ["line", "step", "stacked", "bar", "monotoneX"] - ScatterViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - xColumn: - type: string - yColumn: - type: string - fillColumns: - type: array - items: - type: string - symbolColumns: - type: array - items: - type: string - xDomain: - type: array - items: - type: number - maxItems: 2 - yDomain: - type: array - items: - type: number - maxItems: 2 - xAxisLabel: - type: string - yAxisLabel: - type: string - xPrefix: - type: string - xSuffix: - type: string - yPrefix: - type: string - ySuffix: - type: string + xColumn: + type: string + yColumn: + type: string + fillColumns: + type: array + items: + type: string + symbolColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string HeatmapViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - xColumn: - type: string - yColumn: - type: string - xDomain: - type: array - items: - type: number - maxItems: 2 - yDomain: - type: array - items: - type: number - maxItems: 2 - xAxisLabel: - type: string - yAxisLabel: - type: string - xPrefix: - type: string - xSuffix: - type: string - yPrefix: - type: string - ySuffix: - type: string - binSize: - type: number + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - yColumn + - xDomain + - yDomain + - xAxisLabel + - yAxisLabel + - xPrefix + - yPrefix + - xSuffix + - ySuffix + - binSize + properties: + type: + type: string + enum: [heatmap] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + type: string + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + xColumn: + type: string + yColumn: + type: string + xDomain: + type: array + items: + type: number + maxItems: 2 + yDomain: + type: array + items: + type: number + maxItems: 2 + xAxisLabel: + type: string + yAxisLabel: + type: string + xPrefix: + type: string + xSuffix: + type: string + yPrefix: + type: string + ySuffix: + type: string + binSize: + type: number SingleStatViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - prefix: - type: string - suffix: - type: string - legend: - $ref: '#/components/schemas/Legend' - decimalPlaces: - $ref: "#/components/schemas/DecimalPlaces" + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - prefix + - suffix + - legend + - decimalPlaces + properties: + type: + type: string + enum: [single-stat] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + prefix: + type: string + suffix: + type: string + legend: + $ref: '#/components/schemas/Legend' + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" HistogramViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - xColumn: - type: string - fillColumns: - type: array - items: - type: string - xDomain: - type: array - items: - type: number - format: float - xAxisLabel: - type: string - position: - type: string - binCount: - type: integer + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - xColumn + - fillColumns + - xDomain + - xAxisLabel + - position + - binCount + properties: + type: + type: string + enum: [histogram] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + xColumn: + type: string + fillColumns: + type: array + items: + type: string + xDomain: + type: array + items: + type: number + format: float + xAxisLabel: + type: string + position: + type: string + enum: [overlaid, stacked] + binCount: + type: integer GaugeViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - prefix: - type: string - suffix: - type: string - legend: - $ref: '#/components/schemas/Legend' - decimalPlaces: - $ref: '#/components/schemas/DecimalPlaces' + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - prefix + - suffix + - legend + - decimalPlaces + properties: + type: + type: string + enum: [gauge] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + prefix: + type: string + suffix: + type: string + legend: + $ref: '#/components/schemas/Legend' + decimalPlaces: + $ref: "#/components/schemas/DecimalPlaces" TableViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object + type: object + required: + - type + - queries + - colors + - shape + - note + - showNoteWhenEmpty + - tableOptions + - fieldOptions + - timeFormat + - decimalPlaces + properties: + type: + type: string + enum: [table] + queries: + type: array + items: + $ref: "#/components/schemas/DashboardQuery" + colors: + description: Colors define color encoding of data into a visualization + type: array + items: + $ref: "#/components/schemas/DashboardColor" + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + showNoteWhenEmpty: + description: if true, will display note when empty + type: boolean + tableOptions: properties: - tableOptions: - properties: - verticalTimeAxis: - description: >- - verticalTimeAxis describes the orientation of the table by - indicating whether the time axis will be displayed vertically - type: boolean - sortBy: - $ref: "#/components/schemas/RenamableField" - wrapping: - description: wrapping describes the text wrapping style to be used in table views - type: string - enum: - - truncate - - wrap - - single-line - fixFirstColumn: - description: >- - fixFirstColumn indicates whether the first column of the table - should be locked - type: boolean - fieldOptions: + verticalTimeAxis: description: >- - fieldOptions represent the fields retrieved by the query with - customization options - type: array - items: - $ref: '#/components/schemas/RenamableField' - timeFormat: - description: >- - timeFormat describes the display format for time values according to - moment.js date formatting + verticalTimeAxis describes the orientation of the table by + indicating whether the time axis will be displayed vertically + type: boolean + sortBy: + $ref: "#/components/schemas/RenamableField" + wrapping: + description: wrapping describes the text wrapping style to be used in table views type: string - decimalPlaces: - $ref: '#/components/schemas/DecimalPlaces' + enum: + - truncate + - wrap + - single-line + fixFirstColumn: + description: >- + fixFirstColumn indicates whether the first column of the table + should be locked + type: boolean + fieldOptions: + description: >- + fieldOptions represent the fields retrieved by the query with + customization options + type: array + items: + $ref: '#/components/schemas/RenamableField' + timeFormat: + description: >- + timeFormat describes the display format for time values according to + moment.js date formatting + type: string + decimalPlaces: + $ref: '#/components/schemas/DecimalPlaces' MarkdownViewProperties: type: object + required: + - type + - shape + - note properties: - note: - type: string type: type: string - enum: ["markdown"] - EmptyViewProperties: + enum: [markdown] + shape: + type: string + enum: ['chronograf-v2'] + note: + type: string + CheckViewProperties: + type: object + required: + - type + - shape + - checkID + - check properties: type: type: string - enum: ["empty"] - CheckViewProperties: - allOf: - - $ref: '#/components/schemas/ViewProperties' - - type: object - properties: - checkID: - type: string - check: - $ref: '#/components/schemas/Check' + enum: [check] + shape: + type: string + enum: ['chronograf-v2'] + checkID: + type: string + check: + $ref: '#/components/schemas/Check' Axes: description: The viewport for a View's visualizations type: object + required: ['x', 'y'] properties: x: $ref: '#/components/schemas/Axis' "y": # Quoted to prevent YAML parser from interpreting y as shorthand for true. $ref: '#/components/schemas/Axis' - y2: - $ref: '#/components/schemas/Axis' Legend: description: Legend define encoding of data into a view's legend type: object @@ -7391,7 +7553,7 @@ components: properties: type: type: string - enum: ["constant"] + enum: [constant] values: type: array items: @@ -7400,7 +7562,7 @@ components: properties: type: type: string - enum: ["map"] + enum: [map] values: type: object additionalProperties: @@ -7409,7 +7571,7 @@ components: properties: type: type: string - enum: ["query"] + enum: [query] values: type: object properties: @@ -7503,7 +7665,22 @@ components: type: array items: $ref: "#/components/schemas/Variable" + ViewProperties: + oneOf: + - $ref: "#/components/schemas/LinePlusSingleStatProperties" + - $ref: "#/components/schemas/XYViewProperties" + - $ref: "#/components/schemas/SingleStatViewProperties" + - $ref: "#/components/schemas/HistogramViewProperties" + - $ref: "#/components/schemas/GaugeViewProperties" + - $ref: "#/components/schemas/TableViewProperties" + - $ref: "#/components/schemas/MarkdownViewProperties" + - $ref: "#/components/schemas/CheckViewProperties" + - $ref: "#/components/schemas/ScatterViewProperties" + - $ref: "#/components/schemas/HeatmapViewProperties" View: + required: + - name + - properties properties: links: type: object @@ -7517,36 +7694,7 @@ components: name: type: string properties: - oneOf: - - $ref: "#/components/schemas/LinePlusSingleStatProperties" - - $ref: "#/components/schemas/XYViewProperties" - - $ref: "#/components/schemas/SingleStatViewProperties" - - $ref: "#/components/schemas/HistogramViewProperties" - - $ref: "#/components/schemas/GaugeViewProperties" - - $ref: "#/components/schemas/TableViewProperties" - - $ref: "#/components/schemas/MarkdownViewProperties" - - $ref: "#/components/schemas/LogViewProperties" - - $ref: "#/components/schemas/EmptyViewProperties" - - $ref: "#/components/schemas/CheckViewProperties" - - $ref: "#/components/schemas/ScatterViewProperties" - - $ref: "#/components/schemas/HeatmapViewProperties" - discriminator: - propertyName: type - mapping: - line-plus-single-stat: "#/components/schemas/LinePlusSingleStatProperties" - xy: "#/components/schemas/XYViewProperties" - single-stat: "#/components/schemas/SingleStatViewProperties" - histogram: "#/components/schemas/HistogramViewProperties" - gauge: "#/components/schemas/GaugeViewProperties" - table: "#/components/schemas/TableViewProperties" - markdown: "#/components/schemas/MarkdownViewProperties" - log-viewer: "#/components/schemas/LogViewProperties" - check: "#/components/schemas/CheckViewProperties" - scatter: "#/components/schemas/ScatterViewProperties" - heatmap: "#/components/schemas/HeatmapViewProperties" - ViewType: - type: string - enum: ['xy', 'line-plus-single-stat', 'single-stat', 'gauge', 'table', 'markdown', 'log-viewer', 'histogram', 'heatmap', 'scatter', 'check', 'empty'] + $ref: '#/components/schemas/ViewProperties' Views: type: object properties: @@ -8687,14 +8835,6 @@ components: oneOf: - $ref: "#/components/schemas/DeadmanCheck" - $ref: "#/components/schemas/ThresholdCheck" - discriminator: - propertyName: type - mapping: - deadman: "#/components/schemas/DeadmanCheck" - threshold: "#/components/schemas/ThresholdCheck" - CheckType: - type: string - enum: [deadman, threshold] Checks: properties: checks: @@ -8708,9 +8848,6 @@ components: id: readOnly: true type: string - type: - type: string - $ref: "#/components/schemas/CheckType" name: type: string orgID: @@ -8765,24 +8902,26 @@ components: - $ref: "#/components/schemas/CheckBase" - type: object properties: + type: + type: string + enum: [threshold] thresholds: type: array items: - oneOf: - - $ref: "#/components/schemas/GreaterThreshold" - - $ref: "#/components/schemas/LesserThreshold" - - $ref: "#/components/schemas/RangeThreshold" - discriminator: - propertyName: type - mapping: - greater: "#/components/schemas/GreaterThreshold" - lesser: "#/components/schemas/LesserThreshold" - range: "#/components/schemas/RangeThreshold" + $ref: "#/components/schemas/Threshold" + Threshold: + oneOf: + - $ref: "#/components/schemas/GreaterThreshold" + - $ref: "#/components/schemas/LesserThreshold" + - $ref: "#/components/schemas/RangeThreshold" DeadmanCheck: allOf: - $ref: "#/components/schemas/CheckBase" - type: object properties: + type: + type: string + enum: [deadman] timeSince: description: seconds before deadman triggers type: integer @@ -8798,14 +8937,15 @@ components: allValues: description: if true, only alert if all values meet threshold type: boolean - type: - $ref: "#/components/schemas/ThresholdType" - required: [type] GreaterThreshold: allOf: - $ref: "#/components/schemas/ThresholdBase" - type: object + required: [type, value] properties: + type: + type: string + enum: [greater] value: type: number format: float @@ -8813,7 +8953,11 @@ components: allOf: - $ref: "#/components/schemas/ThresholdBase" - type: object + required: [type, value] properties: + type: + type: string + enum: [lesser] value: type: number format: float @@ -8821,7 +8965,11 @@ components: allOf: - $ref: "#/components/schemas/ThresholdBase" - type: object + required: [type, min, max, within] properties: + type: + type: string + enum: [range] min: type: number format: float @@ -8830,9 +8978,6 @@ components: format: float within: type: boolean - ThresholdType: - type: string - enum: [greater, lesser, range] CheckStatusLevel: description: the state to record if check matches a criteria type: string @@ -8854,12 +8999,6 @@ components: - $ref: "#/components/schemas/SlackNotificationRule" - $ref: "#/components/schemas/SMTPNotificationRule" - $ref: "#/components/schemas/PagerDutyNotificationRule" - discriminator: - propertyName: type - mapping: - slack: "#/components/schemas/SlackNotificationRule" - smtp: "#/components/schemas/SMTPNotificationRule" - pagerduty: "#/components/schemas/PagerDutyNotificationRule" NotificationRules: properties: notificationRules: @@ -8870,6 +9009,13 @@ components: $ref: "#/components/schemas/Links" NotificationRuleBase: type: object + required: + - id + - orgid + - status + - name + - tagRules + - statusRules properties: id: readOnly: true @@ -8897,8 +9043,6 @@ components: name: description: human-readable name describing the notification rule type: string - type: - $ref: "#/components/schemas/NotificationRuleType" sleepUntil: type: string every: @@ -8934,7 +9078,6 @@ components: $ref: "#/components/schemas/StatusRule" labels: $ref: "#/components/schemas/Labels" - required: [type] TagRule: type: object properties: @@ -8968,7 +9111,11 @@ components: allOf: - $ref: "#/components/schemas/NotificationRuleBase" - type: object + required: [type, messageTemplate] properties: + type: + type: string + enum: [slack] channel: type: string messageTemplate: @@ -8977,7 +9124,11 @@ components: allOf: - $ref: "#/components/schemas/NotificationRuleBase" - type: object + required: [type, subjectTemplate, to] properties: + type: + type: string + enum: [smtp] subjectTemplate: type: string bodyTemplate: @@ -8988,12 +9139,13 @@ components: allOf: - $ref: "#/components/schemas/NotificationRuleBase" - type: object + required: [type, messageTemplate] properties: + type: + type: string + enum: [pagerduty] messageTemplate: type: string - NotificationRuleType: - type: string - enum: ['slack', 'smtp', 'pagerduty'] NotificationEndpoint: oneOf: - $ref: "#/components/schemas/SlackNotificationEndpoint" diff --git a/ui/cypress/e2e/buckets.test.ts b/ui/cypress/e2e/buckets.test.ts index 72c664f5816..177e13e9b05 100644 --- a/ui/cypress/e2e/buckets.test.ts +++ b/ui/cypress/e2e/buckets.test.ts @@ -1,4 +1,4 @@ -import {Bucket, Organization} from '@influxdata/influx' +import {Bucket, Organization} from '../../src/types' describe('Buckets', () => { beforeEach(() => { diff --git a/ui/cypress/e2e/collectors.test.ts b/ui/cypress/e2e/collectors.test.ts index 1d4b909d5a1..431ec11d42b 100644 --- a/ui/cypress/e2e/collectors.test.ts +++ b/ui/cypress/e2e/collectors.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' describe('Collectors', () => { beforeEach(() => { diff --git a/ui/cypress/e2e/dashboardsIndex.test.ts b/ui/cypress/e2e/dashboardsIndex.test.ts index 83ca0c3a2ec..b7878bc862d 100644 --- a/ui/cypress/e2e/dashboardsIndex.test.ts +++ b/ui/cypress/e2e/dashboardsIndex.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' const newLabelName = 'click-me' const dashboardName = 'Bee Happy' diff --git a/ui/cypress/e2e/dashboardsView.test.ts b/ui/cypress/e2e/dashboardsView.test.ts index 26fd02c181b..d7dd4fec1b9 100644 --- a/ui/cypress/e2e/dashboardsView.test.ts +++ b/ui/cypress/e2e/dashboardsView.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' describe('Dashboard', () => { beforeEach(() => { diff --git a/ui/cypress/e2e/explorer.test.ts b/ui/cypress/e2e/explorer.test.ts index 51884f16189..4cb0bf66c74 100644 --- a/ui/cypress/e2e/explorer.test.ts +++ b/ui/cypress/e2e/explorer.test.ts @@ -1,5 +1,5 @@ import {Doc} from 'codemirror' -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' import { FROM, RANGE, diff --git a/ui/cypress/e2e/labels.test.ts b/ui/cypress/e2e/labels.test.ts index dae964eb31c..f32a57affbc 100644 --- a/ui/cypress/e2e/labels.test.ts +++ b/ui/cypress/e2e/labels.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' describe('labels', () => { beforeEach(() => { @@ -18,7 +18,7 @@ describe('labels', () => { function hex2BgColor(hex: string): string { hex = hex.replace('#', '') - let subvals: string[] = hex.match(/.{1,2}/g) + let subvals = hex.match(/.{1,2}/g) as string[] let red: number = parseInt(subvals[0], 16) let green: number = parseInt(subvals[1], 16) let blue: number = parseInt(subvals[2], 16) diff --git a/ui/cypress/e2e/scrapers.test.ts b/ui/cypress/e2e/scrapers.test.ts index a9530fc2f81..e8c795d2311 100644 --- a/ui/cypress/e2e/scrapers.test.ts +++ b/ui/cypress/e2e/scrapers.test.ts @@ -1,4 +1,4 @@ -import {Organization, Bucket} from '@influxdata/influx' +import {Organization, Bucket} from '../../src/types' describe('Scrapers', () => { beforeEach(() => { diff --git a/ui/cypress/e2e/tasks.test.ts b/ui/cypress/e2e/tasks.test.ts index 03ffd748d6f..9173395d076 100644 --- a/ui/cypress/e2e/tasks.test.ts +++ b/ui/cypress/e2e/tasks.test.ts @@ -1,4 +1,4 @@ -import {Organization, Bucket} from '@influxdata/influx' +import {Organization, Bucket} from '../../src/types' import _ from 'lodash' describe('Tasks', () => { diff --git a/ui/cypress/e2e/tokens.test.ts b/ui/cypress/e2e/tokens.test.ts index a6c299bb0e8..fa837512347 100644 --- a/ui/cypress/e2e/tokens.test.ts +++ b/ui/cypress/e2e/tokens.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' describe('tokens', () => { let authData: {description: string; status: boolean; id: string}[] @@ -150,9 +150,9 @@ describe('tokens', () => { // @ts-ignore cy.request( 'api/v2/authorizations/' + - authData.find(function(item) { + (authData.find(function(item) { return item.description === 'token test 02' - }).id + }) as any).id ).then(resp => { expect(resp.body.status).equals('active') }) @@ -180,9 +180,9 @@ describe('tokens', () => { // @ts-ignore cy.request( 'api/v2/authorizations/' + - authData.find(function(item) { + (authData.find(function(item) { return item.description === 'token test 02' - }).id + }) as any).id ).then(resp => { expect(resp.body.status).equals('inactive') }) diff --git a/ui/cypress/e2e/variables.test.ts b/ui/cypress/e2e/variables.test.ts index ffdccf35229..3ed96b57c79 100644 --- a/ui/cypress/e2e/variables.test.ts +++ b/ui/cypress/e2e/variables.test.ts @@ -1,4 +1,4 @@ -import {Organization} from '@influxdata/influx' +import {Organization} from '../../src/types' describe('Variables', () => { beforeEach(() => { diff --git a/ui/package.json b/ui/package.json index 13618e99472..41e933d37a1 100644 --- a/ui/package.json +++ b/ui/package.json @@ -34,7 +34,8 @@ "tsc": "tsc -p ./tsconfig.json --noEmit --pretty --skipLibCheck", "tsc:cypress": "tsc -p ./cypress/tsconfig.json --noEmit --pretty --skipLibCheck", "cy": "CYPRESS_baseUrl=http://localhost:9999 cypress open", - "cy:dev": "CYPRESS_baseUrl=http://localhost:8080 cypress open" + "cy:dev": "CYPRESS_baseUrl=http://localhost:8080 cypress open", + "generate": "oats ../http/swagger.yml > src/client/index.ts" }, "jest": { "setupFilesAfterEnv": [ @@ -80,6 +81,7 @@ "devDependencies": { "@babel/core": "^7.5.5", "@babel/preset-env": "^7.5.5", + "@chnn/oats": "^0.2.0", "@cypress/webpack-preprocessor": "^4.0.3", "@types/chroma-js": "^1.3.4", "@types/codemirror": "^0.0.56", @@ -149,7 +151,7 @@ "ts-loader": "^5.3.3", "ts-node": "^8.3.0", "tslib": "^1.9.0", - "typescript": "^3.3.3", + "typescript": "3.3.3", "webpack": "^4.37.0", "webpack-cli": "^3.3.6", "webpack-dev-server": "^3.7.2", diff --git a/ui/src/alerting/actions/checks.ts b/ui/src/alerting/actions/checks.ts index 6b274aafbaa..e42ecadb7e8 100644 --- a/ui/src/alerting/actions/checks.ts +++ b/ui/src/alerting/actions/checks.ts @@ -1,10 +1,12 @@ // Libraries -import {client} from 'src/utils/api' import {Dispatch} from 'react' // Constants import * as copy from 'src/shared/copy/notifications' +// APIs +import * as api from 'src/client' + //Actions import { notify, @@ -62,9 +64,13 @@ export const getChecks = () => async ( }, } = getState() - const checks = await client.checks.getAll(orgID) + const resp = await api.getChecks({query: {orgID}}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - dispatch(setAllChecks(RemoteDataState.Done, checks)) + dispatch(setAllChecks(RemoteDataState.Done, resp.data.checks)) } catch (e) { console.error(e) dispatch(setAllChecks(RemoteDataState.Error)) @@ -78,9 +84,13 @@ export const getCurrentCheck = (checkID: string) => async ( try { dispatch(setCurrentCheck(RemoteDataState.Loading)) - const check = await client.checks.get(checkID) + const resp = await api.getCheck({checkID}) - dispatch(setCurrentCheck(RemoteDataState.Done, check)) + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(setCurrentCheck(RemoteDataState.Done, resp.data)) } catch (e) { console.error(e) dispatch(setCurrentCheck(RemoteDataState.Error)) @@ -88,11 +98,15 @@ export const getCurrentCheck = (checkID: string) => async ( } } -export const createCheck = (check: Check) => async ( +export const createCheck = (check: Partial) => async ( dispatch: Dispatch ) => { try { - client.checks.create(check) + const resp = await api.postCheck({data: check as Check}) + + if (resp.status !== 201) { + throw new Error(resp.data.message) + } } catch (e) { console.error(e) dispatch(notify(copy.createCheckFailed(e.message))) @@ -103,8 +117,13 @@ export const updateCheck = (check: Partial) => async ( dispatch: Dispatch ) => { try { - const updatedCheck = await client.checks.update(check.id, check) - dispatch(setCheck(updatedCheck)) + const resp = await api.patchCheck({checkID: check.id, data: check as Check}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(setCheck(resp.data)) } catch (e) { console.error(e) dispatch(notify(copy.updateCheckFailed(e.message))) @@ -115,7 +134,12 @@ export const deleteCheck = (checkID: string) => async ( dispatch: Dispatch ) => { try { - await client.checks.delete(checkID) + const resp = await api.deleteCheck({checkID}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } + dispatch(removeCheck(checkID)) } catch (e) { console.error(e) diff --git a/ui/src/alerting/actions/notificationRules.ts b/ui/src/alerting/actions/notificationRules.ts index 563efb84deb..72e4afcb15d 100644 --- a/ui/src/alerting/actions/notificationRules.ts +++ b/ui/src/alerting/actions/notificationRules.ts @@ -1,10 +1,12 @@ // Libraries -import {client} from 'src/utils/api' import {Dispatch} from 'react' // Constants import * as copy from 'src/shared/copy/notifications' +// APIs +import * as api from 'src/client' + // Actions import { notify, @@ -59,11 +61,15 @@ export const getNotificationRules = () => async ( }, } = getState() - const notificationRules = (await client.notificationRules.getAll( - orgID - )) as NotificationRule[] + const resp = await api.getNotificationRules({query: {orgID}}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - dispatch(setAllNotificationRules(RemoteDataState.Done, notificationRules)) + dispatch( + setAllNotificationRules(RemoteDataState.Done, resp.data.notificationRules) + ) } catch (e) { console.error(e) dispatch(setAllNotificationRules(RemoteDataState.Error)) @@ -77,11 +83,13 @@ export const getCurrentNotificationRule = ( try { dispatch(setCurrentNotificationRule(RemoteDataState.Loading)) - const notificationRule = (await client.notificationRules.get( - notificationRuleID - )) as NotificationRule + const resp = await api.getNotificationRule({ruleID: notificationRuleID}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - dispatch(setCurrentNotificationRule(RemoteDataState.Done, notificationRule)) + dispatch(setCurrentNotificationRule(RemoteDataState.Done, resp.data)) } catch (e) { console.error(e) dispatch(setCurrentNotificationRule(RemoteDataState.Error)) @@ -90,10 +98,16 @@ export const getCurrentNotificationRule = ( } export const createNotificationRule = ( - notificationRule: NotificationRule + notificationRule: Partial ) => async (dispatch: Dispatch) => { try { - client.notificationRules.create(notificationRule) + const resp = await api.postNotificationRule({ + data: notificationRule as NotificationRule, + }) + + if (resp.status !== 201) { + throw new Error(resp.data.message) + } } catch (e) { console.error(e) dispatch(notify(copy.createNotificationRuleFailed(e.message))) @@ -104,11 +118,16 @@ export const updateNotificationRule = ( notificationRule: Partial ) => async (dispatch: Dispatch) => { try { - const updatedNotificationRule = (await client.notificationRules.update( - notificationRule.id, - notificationRule - )) as NotificationRule - dispatch(setNotificationRule(updatedNotificationRule)) + const resp = await api.putNotificationRule({ + ruleID: notificationRule.id, + data: notificationRule as NotificationRule, + }) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(setNotificationRule(resp.data)) } catch (e) { console.error(e) dispatch(notify(copy.updateNotificationRuleFailed(e.message))) @@ -119,7 +138,12 @@ export const deleteNotificationRule = (notificationRuleID: string) => async ( dispatch: Dispatch ) => { try { - await client.notificationRules.delete(notificationRuleID) + const resp = await api.deleteNotificationRule({ruleID: notificationRuleID}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } + dispatch(removeNotificationRule(notificationRuleID)) } catch (e) { console.error(e) diff --git a/ui/src/alerting/components/CheckCard.tsx b/ui/src/alerting/components/CheckCard.tsx index e84190f191e..014165e191b 100644 --- a/ui/src/alerting/components/CheckCard.tsx +++ b/ui/src/alerting/components/CheckCard.tsx @@ -14,7 +14,7 @@ import {DEFAULT_CHECK_NAME} from 'src/alerting/constants' import {updateCheck, deleteCheck} from 'src/alerting/actions/checks' // Types -import {Check, CheckBase} from 'src/types' +import {Check} from 'src/types' interface DispatchProps { updateCheck: typeof updateCheck @@ -47,10 +47,8 @@ const CheckCard: FunctionComponent = ({ const onClone = () => {} const onToggle = () => { - const status = - check.status == CheckBase.StatusEnum.Active - ? CheckBase.StatusEnum.Inactive - : CheckBase.StatusEnum.Active + const status = check.status === 'active' ? 'inactive' : 'active' + updateCheck({id: check.id, status}) } @@ -75,7 +73,7 @@ const CheckCard: FunctionComponent = ({ } toggle={ = ({ } // description // labels - disabled={check.status == CheckBase.StatusEnum.Inactive} + disabled={check.status === 'inactive'} contextMenu={ = ({ useEffect(() => { // create view properties from check - const view = createView(ViewType.XY) + const view = createView('xy') onSetActiveTimeMachine(TimeMachineEnum.Alerting, {view}) }, [check.id]) diff --git a/ui/src/alerting/components/NewCheckEO.tsx b/ui/src/alerting/components/NewCheckEO.tsx index 318e9863f34..63574ab93ed 100644 --- a/ui/src/alerting/components/NewCheckEO.tsx +++ b/ui/src/alerting/components/NewCheckEO.tsx @@ -19,7 +19,7 @@ import {setActiveTimeMachine} from 'src/timeMachine/actions' import {createView} from 'src/shared/utils/view' // Types -import {Check, AppState, RemoteDataState, XYView, ViewType} from 'src/types' +import {Check, AppState, RemoteDataState, XYViewProperties} from 'src/types' import {DEFAULT_CHECK} from 'src/alerting/constants' import {TimeMachineEnum} from 'src/timeMachine/constants' @@ -46,7 +46,7 @@ const NewCheckOverlay: FunctionComponent = ({ }) => { useEffect(() => { setCurrentCheck(RemoteDataState.Done, DEFAULT_CHECK) - const view = createView(ViewType.XY) + const view = createView('xy') onSetActiveTimeMachine(TimeMachineEnum.Alerting, {view}) }, []) diff --git a/ui/src/alerting/components/NotificationRuleCard.tsx b/ui/src/alerting/components/NotificationRuleCard.tsx index 8caee2fd63a..d2e4d516c72 100644 --- a/ui/src/alerting/components/NotificationRuleCard.tsx +++ b/ui/src/alerting/components/NotificationRuleCard.tsx @@ -17,7 +17,7 @@ import { } from 'src/alerting/actions/notificationRules' // Types -import {NotificationRule, NotificationRuleBase} from 'src/types' +import {NotificationRule} from 'src/types' interface DispatchProps { updateNotificationRule: typeof updateNotificationRule @@ -50,10 +50,8 @@ const NotificationRuleCard: FunctionComponent = ({ const onClone = () => {} const onToggle = () => { - const status = - notificationRule.status == NotificationRuleBase.StatusEnum.Active - ? NotificationRuleBase.StatusEnum.Inactive - : NotificationRuleBase.StatusEnum.Active + const status = notificationRule.status === 'active' ? 'inactive' : 'active' + updateNotificationRule({id: notificationRule.id, status}) } @@ -78,9 +76,7 @@ const NotificationRuleCard: FunctionComponent = ({ } toggle={ = ({ } // description // labels - disabled={ - notificationRule.status == NotificationRuleBase.StatusEnum.Inactive - } + disabled={notificationRule.status === 'inactive'} contextMenu={ = { name: DEFAULT_CHECK_NAME, - type: CheckType.Threshold, - status: CheckBase.StatusEnum.Active, + type: 'threshold', + status: 'active', thresholds: [], } export const query: DashboardQuery = { text: 'this is query', - editMode: QueryEditMode.Advanced, + editMode: 'advanced', builderConfig: null, name: 'great q', } export const check1: Check = { id: '1', - type: CheckType.Threshold, + type: 'threshold', name: 'Amoozing check', orgID: 'lala', - createdAt: new Date('December 17, 2019'), - updatedAt: new Date('April 17, 2019'), + createdAt: '2019-12-17T00:00', + updatedAt: '2019-05-17T00:00', query: query, - status: CheckBase.StatusEnum.Active, + status: 'active', every: '2d', offset: '1m', tags: [{key: 'a', value: 'b'}], statusMessageTemplate: 'this is a great message template', thresholds: [ { - level: CheckStatusLevel.WARN, + level: 'WARN', allValues: false, - type: ThresholdType.Greater, - }, + type: 'greater', + } as GreaterThreshold, ], } export const check2: Check = { id: '2', - type: CheckType.Threshold, + type: 'threshold', name: 'Another check', orgID: 'lala', - createdAt: new Date('December 17, 2019'), - updatedAt: new Date('April 17, 2019'), + createdAt: '2019-12-17T00:00', + updatedAt: '2019-05-17T00:00', query: query, - status: CheckBase.StatusEnum.Active, + status: 'active', every: '2d', offset: '1m', tags: [{key: 'a', value: 'b'}], statusMessageTemplate: 'this is a great message template', thresholds: [ { - level: CheckStatusLevel.WARN, + level: 'WARN', allValues: false, - type: ThresholdType.Greater, - }, + type: 'greater', + } as GreaterThreshold, ], } @@ -79,15 +73,18 @@ export const notificationRule: NotificationRule = { id: '3', notifyEndpointID: '2', orgID: 'lala', - createdAt: new Date('December 17, 2019'), - updatedAt: new Date('April 17, 2019'), - status: NotificationRuleBase.StatusEnum.Active, + createdAt: '2019-12-17T00:00', + updatedAt: '2019-05-17T00:00', + status: 'active', + description: '', name: 'amazing notification rule', - type: NotificationRuleType.Slack, + type: 'slack', every: '2d', offset: '5m', limitEvery: 1, limit: 5, tagRules: [], statusRules: [], + channel: '#monitoring-team', + messageTemplate: 'hello, this is a NotificationRule fixture speaking :)', } diff --git a/ui/src/authorizations/components/BucketsSelector.tsx b/ui/src/authorizations/components/BucketsSelector.tsx index bd2e8f79084..e9f68cf9a87 100644 --- a/ui/src/authorizations/components/BucketsSelector.tsx +++ b/ui/src/authorizations/components/BucketsSelector.tsx @@ -8,7 +8,7 @@ import {BucketTab} from 'src/authorizations/utils/permissions' import BucketsTabSelector from 'src/authorizations/components/BucketsTabSelector' // Types -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' import { ComponentSpacer, AlignItems, diff --git a/ui/src/authorizations/components/BucketsTabBody.tsx b/ui/src/authorizations/components/BucketsTabBody.tsx index 89602dc830b..c6898a490de 100644 --- a/ui/src/authorizations/components/BucketsTabBody.tsx +++ b/ui/src/authorizations/components/BucketsTabBody.tsx @@ -6,7 +6,7 @@ import BuilderCard from 'src/timeMachine/components/builderCard/BuilderCard' import SelectorList from 'src/timeMachine/components/SelectorList' // Types -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' import {Input} from '@influxdata/clockface' import SortingHat from 'src/shared/components/sorting_hat/SortingHat' import FilterList from 'src/shared/components/Filter' diff --git a/ui/src/authorizations/components/BucketsTokenOverlay.tsx b/ui/src/authorizations/components/BucketsTokenOverlay.tsx index 9b232f4976d..a9ecf0b6511 100644 --- a/ui/src/authorizations/components/BucketsTokenOverlay.tsx +++ b/ui/src/authorizations/components/BucketsTokenOverlay.tsx @@ -36,8 +36,8 @@ import {createAuthorization} from 'src/authorizations/actions' import {ErrorHandling} from 'src/shared/decorators/errors' // Types -import {AppState} from 'src/types' -import {Bucket, Permission, Authorization} from '@influxdata/influx' +import {AppState, Bucket} from 'src/types' +import {Permission, Authorization} from '@influxdata/influx' interface StateProps { buckets: Bucket[] diff --git a/ui/src/authorizations/utils/permissions.ts b/ui/src/authorizations/utils/permissions.ts index 86af507f979..2bfd3292e0c 100644 --- a/ui/src/authorizations/utils/permissions.ts +++ b/ui/src/authorizations/utils/permissions.ts @@ -1,4 +1,5 @@ -import {Permission, PermissionResource, Bucket} from '@influxdata/influx' +import {Permission, PermissionResource} from '@influxdata/influx' +import {Bucket} from 'src/types' // Types diff --git a/ui/src/buckets/actions/index.ts b/ui/src/buckets/actions/index.ts index e00d8186f69..b9160159eb1 100644 --- a/ui/src/buckets/actions/index.ts +++ b/ui/src/buckets/actions/index.ts @@ -1,7 +1,7 @@ import {Dispatch} from 'redux-thunk' // API -import {client} from 'src/utils/api' +import * as api from 'src/client' // Types import {RemoteDataState, AppState, Bucket} from 'src/types' @@ -86,9 +86,13 @@ export const getBuckets = () => async ( orgs: {org}, } = getState() - const buckets = await client.buckets.getAll(org.id) + const resp = await api.getBuckets({query: {orgID: org.id}}) - dispatch(setBuckets(RemoteDataState.Done, buckets)) + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(setBuckets(RemoteDataState.Done, resp.data.buckets)) } catch (e) { console.error(e) dispatch(setBuckets(RemoteDataState.Error)) @@ -105,12 +109,13 @@ export const createBucket = (bucket: Bucket) => async ( orgs: {org}, } = getState() - const createdBucket = await client.buckets.create({ - ...bucket, - orgID: org.id, - }) + const resp = await api.postBucket({data: {...bucket, orgID: org.id}}) - dispatch(addBucket(createdBucket)) + if (resp.status !== 201) { + throw new Error(resp.data.message) + } + + dispatch(addBucket(resp.data)) dispatch(checkBucketLimits()) } catch (error) { console.error(error) @@ -123,9 +128,16 @@ export const updateBucket = (updatedBucket: Bucket) => async ( dispatch: Dispatch ) => { try { - const bucket = await client.buckets.update(updatedBucket.id, updatedBucket) + const resp = await api.patchBucket({ + bucketID: updatedBucket.id, + data: updatedBucket, + }) - dispatch(editBucket(bucket)) + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(editBucket(resp.data)) dispatch(notify(bucketUpdateSuccess(updatedBucket.name))) } catch (e) { console.error(e) @@ -139,9 +151,16 @@ export const renameBucket = ( updatedBucket: Bucket ) => async (dispatch: Dispatch) => { try { - const bucket = await client.buckets.update(updatedBucket.id, updatedBucket) + const resp = await api.patchBucket({ + bucketID: updatedBucket.id, + data: updatedBucket, + }) - dispatch(editBucket(bucket)) + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + dispatch(editBucket(resp.data)) dispatch(notify(bucketRenameSuccess(updatedBucket.name))) } catch (e) { console.error(e) @@ -153,7 +172,11 @@ export const deleteBucket = (id: string, name: string) => async ( dispatch: Dispatch ) => { try { - await client.buckets.delete(id) + const resp = await api.deleteBucket({bucketID: id}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } dispatch(removeBucket(id)) dispatch(checkBucketLimits()) diff --git a/ui/src/buckets/components/BucketOverlayForm.tsx b/ui/src/buckets/components/BucketOverlayForm.tsx index 55b7ba2258e..51773fa5f17 100644 --- a/ui/src/buckets/components/BucketOverlayForm.tsx +++ b/ui/src/buckets/components/BucketOverlayForm.tsx @@ -10,7 +10,6 @@ import Retention from 'src/buckets/components/Retention' import {MIN_RETENTION_SECONDS} from 'src/buckets/constants' // Types -import {BucketRetentionRules} from '@influxdata/influx' import { ButtonType, ComponentColor, @@ -21,11 +20,11 @@ interface Props { name: string nameErrorMessage: string retentionSeconds: number - ruleType: BucketRetentionRules.TypeEnum + ruleType: 'expire' onSubmit: (e: FormEvent) => void onCloseModal: () => void onChangeRetentionRule: (seconds: number) => void - onChangeRuleType: (t: BucketRetentionRules.TypeEnum) => void + onChangeRuleType: (t: 'expire') => void onChangeInput: (e: ChangeEvent) => void nameInputStatus: ComponentStatus buttonText: string @@ -134,10 +133,7 @@ export default class BucketOverlayForm extends PureComponent { private get retentionIsTooShort(): boolean { const {retentionSeconds, ruleType} = this.props - return ( - ruleType === BucketRetentionRules.TypeEnum.Expire && - retentionSeconds < MIN_RETENTION_SECONDS - ) + return ruleType === 'expire' && retentionSeconds < MIN_RETENTION_SECONDS } private get ruleErrorMessage(): string { diff --git a/ui/src/buckets/components/CreateBucketOverlay.tsx b/ui/src/buckets/components/CreateBucketOverlay.tsx index 9155ec9902d..1241a4c5e47 100644 --- a/ui/src/buckets/components/CreateBucketOverlay.tsx +++ b/ui/src/buckets/components/CreateBucketOverlay.tsx @@ -6,7 +6,7 @@ import {Overlay, ComponentStatus} from '@influxdata/clockface' import BucketOverlayForm from 'src/buckets/components/BucketOverlayForm' // Types -import {Bucket, BucketRetentionRules, Organization} from '@influxdata/influx' +import {Organization, Bucket} from 'src/types' interface Props { org: Organization @@ -16,7 +16,7 @@ interface Props { interface State { bucket: Bucket - ruleType: BucketRetentionRules.TypeEnum + ruleType: 'expire' nameInputStatus: ComponentStatus nameErrorMessage: string } @@ -67,9 +67,7 @@ export default class CreateBucketOverlay extends PureComponent { } private get retentionSeconds(): number { - const rule = this.state.bucket.retentionRules.find( - r => r.type === BucketRetentionRules.TypeEnum.Expire - ) + const rule = this.state.bucket.retentionRules.find(r => r.type === 'expire') if (!rule) { return 3600 @@ -81,9 +79,7 @@ export default class CreateBucketOverlay extends PureComponent { private handleChangeRetentionRule = (everySeconds: number): void => { const bucket = { ...this.state.bucket, - retentionRules: [ - {type: BucketRetentionRules.TypeEnum.Expire, everySeconds}, - ], + retentionRules: [{type: 'expire' as 'expire', everySeconds}], } this.setState({bucket}) diff --git a/ui/src/buckets/components/RenameBucketForm.tsx b/ui/src/buckets/components/RenameBucketForm.tsx index fa900250c70..05ac7667631 100644 --- a/ui/src/buckets/components/RenameBucketForm.tsx +++ b/ui/src/buckets/components/RenameBucketForm.tsx @@ -21,8 +21,7 @@ import { import {renameBucket} from 'src/buckets/actions' // Types -import {IBucket as Bucket} from '@influxdata/influx' -import {AppState} from 'src/types' +import {AppState, Bucket} from 'src/types' interface State { bucket: Bucket diff --git a/ui/src/buckets/components/Retention.tsx b/ui/src/buckets/components/Retention.tsx index 8c0cf2da927..e03e79ca547 100644 --- a/ui/src/buckets/components/Retention.tsx +++ b/ui/src/buckets/components/Retention.tsx @@ -16,7 +16,7 @@ import {BucketRetentionRules} from '@influxdata/influx' interface Props { retentionSeconds: number - type: BucketRetentionRules.TypeEnum + type: 'expire' onChangeRetentionRule: (seconds: number) => void onChangeRuleType: (type: BucketRetentionRules.TypeEnum) => void } diff --git a/ui/src/buckets/components/RetentionDuration.tsx b/ui/src/buckets/components/RetentionDuration.tsx index 8b9177ec1c9..e83e14b3ffc 100644 --- a/ui/src/buckets/components/RetentionDuration.tsx +++ b/ui/src/buckets/components/RetentionDuration.tsx @@ -8,11 +8,10 @@ import {Form, Input, Grid} from '@influxdata/clockface' import {secondsToDuration} from 'src/utils/formatting' // Types -import {BucketRetentionRules} from '@influxdata/influx' import {Columns, InputType} from '@influxdata/clockface' interface Props { - type: BucketRetentionRules.TypeEnum + type: 'expire' retentionSeconds: number onChangeInput: (e: ChangeEvent) => void } diff --git a/ui/src/buckets/components/UpdateBucketOverlay.tsx b/ui/src/buckets/components/UpdateBucketOverlay.tsx index c56c071d126..a24a302ce80 100644 --- a/ui/src/buckets/components/UpdateBucketOverlay.tsx +++ b/ui/src/buckets/components/UpdateBucketOverlay.tsx @@ -14,13 +14,12 @@ import {updateBucket} from 'src/buckets/actions' import {DEFAULT_SECONDS} from 'src/buckets/components/Retention' // Types -import {IBucket as Bucket, BucketRetentionRules} from '@influxdata/influx' -import {AppState} from 'src/types' +import {AppState, Bucket} from 'src/types' interface State { bucket: Bucket nameErrorMessage: string - ruleType: BucketRetentionRules.TypeEnum + ruleType: 'expire' nameInputStatus: ComponentStatus } @@ -76,9 +75,7 @@ class UpdateBucketOverlay extends PureComponent { } private get retentionSeconds(): number { - const rule = this.state.bucket.retentionRules.find( - r => r.type === BucketRetentionRules.TypeEnum.Expire - ) + const rule = this.state.bucket.retentionRules.find(r => r.type === 'expire') if (!rule) { return DEFAULT_SECONDS @@ -87,30 +84,26 @@ class UpdateBucketOverlay extends PureComponent { return rule.everySeconds } - private ruleType = (bucket: Bucket): BucketRetentionRules.TypeEnum => { - const rule = bucket.retentionRules.find( - r => r.type === BucketRetentionRules.TypeEnum.Expire - ) + private ruleType = (bucket: Bucket): 'expire' => { + const rule = bucket.retentionRules.find(r => r.type === 'expire') if (!rule) { return null } - return BucketRetentionRules.TypeEnum.Expire + return 'expire' } private handleChangeRetentionRule = (everySeconds: number): void => { const bucket = { ...this.state.bucket, - retentionRules: [ - {type: BucketRetentionRules.TypeEnum.Expire, everySeconds}, - ], + retentionRules: [{type: 'expire' as 'expire', everySeconds}], } this.setState({bucket}) } - private handleChangeRuleType = (ruleType: BucketRetentionRules.TypeEnum) => { + private handleChangeRuleType = (ruleType: 'expire') => { this.setState({ruleType}) } diff --git a/ui/src/client/index.ts b/ui/src/client/index.ts new file mode 100644 index 00000000000..1d62228983a --- /dev/null +++ b/ui/src/client/index.ts @@ -0,0 +1,8149 @@ +// This file is generated by [oats][0] and should not be edited by hand. +// +// [0]: https://github.com/chnn/oats + +export interface Error { + readonly code: + | 'internal error' + | 'not found' + | 'conflict' + | 'invalid' + | 'unprocessable entity' + | 'empty value' + | 'unavailable' + | 'forbidden' + | 'too many requests' + | 'unauthorized' + | 'method not allowed' + readonly message: string + readonly op?: string + readonly err?: string +} + +export interface Routes { + authorizations?: string + buckets?: string + dashboards?: string + external?: { + statusFeed?: string + } + variables?: string + me?: string + orgs?: string + query?: { + self?: string + ast?: string + analyze?: string + suggestions?: string + } + setup?: string + signin?: string + signout?: string + sources?: string + system?: { + metrics?: string + debug?: string + health?: string + } + tasks?: string + telegrafs?: string + users?: string + write?: string +} + +export interface IsOnboarding { + allowed?: boolean +} + +export interface OnboardingRequest { + username: string + password: string + org: string + bucket: string + retentionPeriodHrs?: number +} + +export interface OnboardingResponse { + user?: User + org?: Organization + bucket?: Bucket + auth?: Authorization +} + +export interface User { + readonly id?: string + oauthID?: string + name: string + status?: 'active' | 'inactive' + readonly links?: { + self?: string + logs?: string + } +} + +export interface Organization { + readonly links?: { + self?: Link + members?: Link + owners?: Link + labels?: Link + secrets?: Link + buckets?: Link + tasks?: Link + dashboards?: Link + logs?: Link + } + readonly id?: string + name: string + description?: string + readonly createdAt?: string + readonly updatedAt?: string + status?: 'active' | 'inactive' +} + +export type Link = string + +export interface Bucket { + readonly links?: { + labels?: Link + logs?: Link + members?: Link + org?: Link + owners?: Link + self?: Link + write?: Link + } + readonly id?: string + name: string + description?: string + orgID?: string + rp?: string + readonly createdAt?: string + readonly updatedAt?: string + retentionRules: Array<{ + type: 'expire' + everySeconds: number + }> + labels?: Labels +} + +export type Labels = Label[] + +export interface Label { + readonly id?: string + readonly orgID?: string + name?: string + properties?: any +} + +export type Authorization = AuthorizationUpdateRequest & { + orgID?: string + permissions?: Permission[] + readonly id?: string + readonly token?: string + readonly userID?: string + readonly user?: string + readonly org?: string + readonly links?: { + readonly self?: string + readonly user?: string + } +} + +export interface AuthorizationUpdateRequest { + status?: 'active' | 'inactive' + description?: string +} + +export interface Permission { + action: 'read' | 'write' + resource: { + type: + | 'authorizations' + | 'buckets' + | 'dashboards' + | 'orgs' + | 'sources' + | 'tasks' + | 'telegrafs' + | 'users' + | 'variables' + | 'scrapers' + | 'secrets' + | 'labels' + | 'views' + | 'documents' + id?: string + name?: string + orgID?: string + org?: string + } +} + +export interface Documents { + documents?: DocumentListEntry[] +} + +export interface DocumentListEntry { + readonly id: string + meta: DocumentMeta + labels?: Labels + readonly links?: { + self?: Link + } +} + +export interface DocumentMeta { + name: string + type?: string + description?: string + version: string + readonly createdAt?: string + readonly updatedAt?: string +} + +export interface DocumentCreate { + meta: DocumentMeta + content: any + org?: string + orgID?: string + labels?: string[] +} + +export interface Document { + readonly id: string + meta: DocumentMeta + content: any + labels?: Labels + readonly links?: { + self?: Link + } +} + +export interface DocumentUpdate { + meta?: DocumentMeta + content?: any +} + +export interface LabelsResponse { + labels?: Labels + links?: Links +} + +export interface Links { + next?: Link + self: Link + prev?: Link +} + +export interface LabelMapping { + labelID?: string +} + +export interface LabelResponse { + label?: Label + links?: Links +} + +export interface Telegrafs { + configurations?: Telegraf[] +} + +export type Telegraf = TelegrafRequest & { + readonly id?: string + readonly links?: { + self?: Link + labels?: Link + members?: Link + owners?: Link + } + readonly labels?: Labels +} + +export interface TelegrafRequest { + name?: string + description?: string + agent?: { + collectionInterval?: number + } + plugins?: TelegrafRequestPlugin[] + orgID?: string +} + +export type TelegrafRequestPlugin = + | TelegrafPluginInputCpu + | TelegrafPluginInputDisk + | TelegrafPluginInputDiskio + | TelegrafPluginInputDocker + | TelegrafPluginInputFile + | TelegrafPluginInputKubernetes + | TelegrafPluginInputLogParser + | TelegrafPluginInputProcstat + | TelegrafPluginInputPrometheus + | TelegrafPluginInputRedis + | TelegrafPluginInputSyslog + | TelegrafPluginOutputFile + | TelegrafPluginOutputInfluxDBV2 + +export interface TelegrafPluginInputCpu { + name: 'cpu' + type: 'input' + comment?: string +} + +export interface TelegrafPluginInputDisk { + name: 'disk' + type: 'input' + comment?: string +} + +export interface TelegrafPluginInputDiskio { + name: 'diskio' + type: 'input' + comment?: string +} + +export interface TelegrafPluginInputDocker { + name: 'docker' + type: 'input' + comment?: string + config: TelegrafPluginInputDockerConfig +} + +export interface TelegrafPluginInputDockerConfig { + endpoint: string +} + +export interface TelegrafPluginInputFile { + name: 'file' + type: 'input' + comment?: string + config: TelegrafPluginInputFileConfig +} + +export interface TelegrafPluginInputFileConfig { + files?: string[] +} + +export interface TelegrafPluginInputKubernetes { + name: 'kubernetes' + type: 'input' + comment?: string + config: TelegrafPluginInputKubernetesConfig +} + +export interface TelegrafPluginInputKubernetesConfig { + url?: string +} + +export interface TelegrafPluginInputLogParser { + name: 'logparser' + type: 'input' + comment?: string + config: TelegrafPluginInputLogParserConfig +} + +export interface TelegrafPluginInputLogParserConfig { + files?: string[] +} + +export interface TelegrafPluginInputProcstat { + name: 'procstat' + type: 'input' + comment?: string + config: TelegrafPluginInputProcstatConfig +} + +export interface TelegrafPluginInputProcstatConfig { + exe?: string +} + +export interface TelegrafPluginInputPrometheus { + name: 'prometheus' + type: 'input' + comment?: string + config: TelegrafPluginInputPrometheusConfig +} + +export interface TelegrafPluginInputPrometheusConfig { + urls?: string[] +} + +export interface TelegrafPluginInputRedis { + name: 'redis' + type: 'input' + comment?: string + config: TelegrafPluginInputRedisConfig +} + +export interface TelegrafPluginInputRedisConfig { + servers?: string[] + password?: string +} + +export interface TelegrafPluginInputSyslog { + name: 'syslog' + type: 'input' + comment?: string + config: TelegrafPluginInputSyslogConfig +} + +export interface TelegrafPluginInputSyslogConfig { + server?: string +} + +export interface TelegrafPluginOutputFile { + name: 'file' + type: 'output' + comment?: string + config: TelegrafPluginOutputFileConfig +} + +export interface TelegrafPluginOutputFileConfig { + files: Array<{ + type?: 'stdout' | 'path' + path?: string + }> +} + +export interface TelegrafPluginOutputInfluxDBV2 { + name: 'influxdb_v2' + type: 'output' + comment?: string + config: TelegrafPluginOutputInfluxDBV2Config +} + +export interface TelegrafPluginOutputInfluxDBV2Config { + urls: string[] + token: string + organization: string + bucket: string +} + +export interface ResourceMembers { + links?: { + self?: string + } + users?: ResourceMember[] +} + +export type ResourceMember = User & { + role?: 'member' +} + +export interface AddResourceMemberRequestBody { + id: string + name?: string +} + +export interface ResourceOwners { + links?: { + self?: string + } + users?: ResourceOwner[] +} + +export type ResourceOwner = User & { + role?: 'owner' +} + +export interface ScraperTargetResponses { + configurations?: ScraperTargetResponse[] +} + +export type ScraperTargetResponse = ScraperTargetRequest & { + readonly id?: string + org?: string + bucket?: string + readonly links?: { + self?: Link + members?: Link + owners?: Link + bucket?: Link + organization?: Link + } +} + +export interface ScraperTargetRequest { + name?: string + type?: 'prometheus' + url?: string + orgID?: string + bucketID?: string +} + +export interface Variables { + variables?: Variable[] +} + +export interface Variable { + readonly links?: { + self?: string + org?: string + labels?: string + } + readonly id?: string + orgID: string + name: string + description?: string + selected?: string[] + labels?: Labels + arguments: + | QueryVariableProperties + | ConstantVariableProperties + | MapVariableProperties + createdAt?: string + updatedAt?: string +} + +export interface QueryVariableProperties { + type?: 'query' + values?: { + query?: string + language?: string + } +} + +export interface ConstantVariableProperties { + type?: 'constant' + values?: string[] +} + +export interface MapVariableProperties { + type?: 'map' + values?: any +} + +export interface LineProtocolError { + readonly code: + | 'internal error' + | 'not found' + | 'conflict' + | 'invalid' + | 'empty value' + | 'unavailable' + readonly message: string + readonly op: string + readonly err: string + readonly line?: number +} + +export interface LineProtocolLengthError { + readonly code: 'invalid' + readonly message: string + readonly maxLength: number +} + +export interface Ready { + status?: 'ready' + started?: string + up?: string +} + +export interface HealthCheck { + name: string + message?: string + checks?: HealthCheck[] + status: 'pass' | 'fail' +} + +export interface Sources { + links?: { + self?: string + } + sources?: Source[] +} + +export interface Source { + links?: { + self?: string + query?: string + health?: string + buckets?: string + } + id?: string + orgID?: string + default?: boolean + name?: string + type?: 'v1' | 'v2' | 'self' + url?: string + insecureSkipVerify?: boolean + telegraf?: string + token?: string + username?: string + password?: string + sharedSecret?: string + metaUrl?: string + defaultRP?: string + readonly languages?: Array<'flux' | 'influxql'> +} + +export interface Buckets { + readonly links?: Links + buckets?: Bucket[] +} + +export interface LabelCreateRequest { + orgID: string + name?: string + properties?: any +} + +export interface LabelUpdate { + name?: string + properties?: any +} + +export interface Dashboards { + links?: Links + dashboards?: Dashboard[] +} + +export type Dashboard = CreateDashboardRequest & { + links?: { + self?: Link + cells?: Link + members?: Link + owners?: Link + logs?: Link + labels?: Link + org?: Link + } + readonly id?: string + meta?: { + createdAt?: string + updatedAt?: string + } + cells?: Cells + labels?: Labels +} + +export interface CreateDashboardRequest { + orgID: string + name: string + description?: string +} + +export type Cells = Cell[] + +export interface Cell { + id?: string + links?: { + self?: string + view?: string + } + x?: number + y?: number + w?: number + h?: number + viewID?: string +} + +export interface CreateCell { + name?: string + x?: number + y?: number + w?: number + h?: number + usingView?: string +} + +export interface CellUpdate { + x?: number + y?: number + w?: number + h?: number +} + +export interface View { + readonly links?: { + self?: string + } + readonly id?: string + name: string + properties: ViewProperties +} + +export type ViewProperties = + | LinePlusSingleStatProperties + | XYViewProperties + | SingleStatViewProperties + | HistogramViewProperties + | GaugeViewProperties + | TableViewProperties + | MarkdownViewProperties + | CheckViewProperties + | ScatterViewProperties + | HeatmapViewProperties + +export interface LinePlusSingleStatProperties { + type: 'line-plus-single-stat' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + axes: Axes + legend: Legend + xColumn?: string + yColumn?: string + shadeBelow?: boolean + prefix: string + suffix: string + decimalPlaces: DecimalPlaces +} + +export interface DashboardQuery { + text?: string + editMode?: QueryEditMode + name?: string + builderConfig?: BuilderConfig +} + +export type QueryEditMode = 'builder' | 'advanced' + +export interface BuilderConfig { + buckets?: string[] + tags?: BuilderTagsType[] + functions?: BuilderFunctionsType[] + aggregateWindow?: { + period?: string + } +} + +export interface BuilderTagsType { + key?: string + values?: string[] +} + +export interface BuilderFunctionsType { + name?: string +} + +export interface DashboardColor { + id: string + type: 'min' | 'max' | 'threshold' | 'scale' | 'text' | 'background' + hex: string + name: string + value: number +} + +export interface Axes { + x: Axis + y: Axis +} + +export interface Axis { + bounds?: string[] + label?: string + prefix?: string + suffix?: string + base?: '' | '2' | '10' + scale?: AxisScale +} + +export type AxisScale = 'log' | 'linear' + +export interface Legend { + type?: 'static' + orientation?: 'top' | 'bottom' | 'left' | 'right' +} + +export interface DecimalPlaces { + isEnforced?: boolean + digits?: number +} + +export interface XYViewProperties { + type: 'xy' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + axes: Axes + legend: Legend + xColumn?: string + yColumn?: string + shadeBelow?: boolean + geom: XYGeom +} + +export type XYGeom = 'line' | 'step' | 'stacked' | 'bar' | 'monotoneX' + +export interface SingleStatViewProperties { + type: 'single-stat' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + prefix: string + suffix: string + legend: Legend + decimalPlaces: DecimalPlaces +} + +export interface HistogramViewProperties { + type: 'histogram' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + xColumn: string + fillColumns: string[] + xDomain: number[] + xAxisLabel: string + position: 'overlaid' | 'stacked' + binCount: number +} + +export interface GaugeViewProperties { + type: 'gauge' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + prefix: string + suffix: string + legend: Legend + decimalPlaces: DecimalPlaces +} + +export interface TableViewProperties { + type: 'table' + queries: DashboardQuery[] + colors: DashboardColor[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + tableOptions: { + verticalTimeAxis?: boolean + sortBy?: RenamableField + wrapping?: 'truncate' | 'wrap' | 'single-line' + fixFirstColumn?: boolean + } + fieldOptions: RenamableField[] + timeFormat: string + decimalPlaces: DecimalPlaces +} + +export interface RenamableField { + readonly internalName?: string + displayName?: string + visible?: boolean +} + +export interface MarkdownViewProperties { + type: 'markdown' + shape: 'chronograf-v2' + note: string +} + +export interface CheckViewProperties { + type: 'check' + shape: 'chronograf-v2' + checkID: string + check: Check +} + +export type Check = DeadmanCheck | ThresholdCheck + +export type DeadmanCheck = CheckBase & { + type?: 'deadman' + timeSince?: number + reportZero?: boolean + level?: CheckStatusLevel +} + +export interface CheckBase { + readonly id?: string + name: string + orgID: string + readonly authorizationID?: string + readonly createdAt?: string + readonly updatedAt?: string + query: DashboardQuery + status?: TaskStatusType + every?: string + offset?: string + cron?: string + tags?: Array<{ + key?: string + value?: string + }> + description?: string + statusMessageTemplate?: string + labels?: Labels +} + +export type TaskStatusType = 'active' | 'inactive' + +export type CheckStatusLevel = 'UNKNOWN' | 'OK' | 'INFO' | 'CRIT' | 'WARN' + +export type ThresholdCheck = CheckBase & { + type?: 'threshold' + thresholds?: Threshold[] +} + +export type Threshold = GreaterThreshold | LesserThreshold | RangeThreshold + +export type GreaterThreshold = ThresholdBase & { + type: 'greater' + value: number +} + +export interface ThresholdBase { + level?: CheckStatusLevel + allValues?: boolean +} + +export type LesserThreshold = ThresholdBase & { + type: 'lesser' + value: number +} + +export type RangeThreshold = ThresholdBase & { + type: 'range' + min: number + max: number + within: boolean +} + +export interface ScatterViewProperties { + type: 'scatter' + queries: DashboardQuery[] + colors: string[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + xColumn: string + yColumn: string + fillColumns: string[] + symbolColumns: string[] + xDomain: number[] + yDomain: number[] + xAxisLabel: string + yAxisLabel: string + xPrefix: string + xSuffix: string + yPrefix: string + ySuffix: string +} + +export interface HeatmapViewProperties { + type: 'heatmap' + queries: DashboardQuery[] + colors: string[] + shape: 'chronograf-v2' + note: string + showNoteWhenEmpty: boolean + xColumn: string + yColumn: string + xDomain: number[] + yDomain: number[] + xAxisLabel: string + yAxisLabel: string + xPrefix: string + xSuffix: string + yPrefix: string + ySuffix: string + binSize: number +} + +export interface OperationLogs { + logs?: OperationLog[] + links?: Links +} + +export interface OperationLog { + description?: string + time?: string + userID?: string + links?: { + user?: Link + } +} + +export interface LanguageRequest { + query: string +} + +export interface ASTResponse { + ast?: Package +} + +export interface Package { + type?: NodeType + path?: string + package?: string + files?: File[] +} + +export type NodeType = string + +export interface File { + type?: NodeType + name?: string + package?: PackageClause + imports?: ImportDeclaration[] + body?: Statement[] +} + +export interface PackageClause { + type?: NodeType + name?: Identifier +} + +export interface Identifier { + type?: NodeType + name?: string +} + +export interface ImportDeclaration { + type?: NodeType + as?: Identifier + path?: StringLiteral +} + +export interface StringLiteral { + type?: NodeType + value?: string +} + +export type Statement = + | BadStatement + | VariableAssignment + | MemberAssignment + | ExpressionStatement + | ReturnStatement + | OptionStatement + | BuiltinStatement + | TestStatement + +export interface BadStatement { + type?: NodeType + text?: string +} + +export interface VariableAssignment { + type?: NodeType + id?: Identifier + init?: Expression +} + +export type Expression = + | ArrayExpression + | FunctionExpression + | BinaryExpression + | CallExpression + | ConditionalExpression + | LogicalExpression + | MemberExpression + | IndexExpression + | ObjectExpression + | PipeExpression + | UnaryExpression + | BooleanLiteral + | DateTimeLiteral + | DurationLiteral + | FloatLiteral + | IntegerLiteral + | PipeLiteral + | RegexpLiteral + | StringLiteral + | UnsignedIntegerLiteral + | Identifier + +export interface ArrayExpression { + type?: NodeType + elements?: Expression[] +} + +export interface FunctionExpression { + type?: NodeType + params?: Property[] + body?: Node +} + +export interface Property { + type?: NodeType + key?: PropertyKey + value?: Expression +} + +export type PropertyKey = Identifier | StringLiteral + +export type Node = Expression | Block + +export interface Block { + type?: NodeType + body?: Statement[] +} + +export interface BinaryExpression { + type?: NodeType + operator?: string + left?: Expression + right?: Expression +} + +export interface CallExpression { + type?: NodeType + callee?: Expression + arguments?: Expression[] +} + +export interface ConditionalExpression { + type?: NodeType + test?: Expression + alternate?: Expression + consequent?: Expression +} + +export interface LogicalExpression { + type?: NodeType + operator?: string + left?: Expression + right?: Expression +} + +export interface MemberExpression { + type?: NodeType + object?: Expression + property?: PropertyKey +} + +export interface IndexExpression { + type?: NodeType + array?: Expression + index?: Expression +} + +export interface ObjectExpression { + type?: NodeType + properties?: Property[] +} + +export interface PipeExpression { + type?: NodeType + argument?: Expression + call?: CallExpression +} + +export interface UnaryExpression { + type?: NodeType + operator?: string + argument?: Expression +} + +export interface BooleanLiteral { + type?: NodeType + value?: boolean +} + +export interface DateTimeLiteral { + type?: NodeType + value?: string +} + +export interface DurationLiteral { + type?: NodeType + values?: Duration[] +} + +export interface Duration { + type?: NodeType + magnitude?: number + unit?: string +} + +export interface FloatLiteral { + type?: NodeType + value?: number +} + +export interface IntegerLiteral { + type?: NodeType + value?: string +} + +export interface PipeLiteral { + type?: NodeType +} + +export interface RegexpLiteral { + type?: NodeType + value?: string +} + +export interface UnsignedIntegerLiteral { + type?: NodeType + value?: string +} + +export interface MemberAssignment { + type?: NodeType + member?: MemberExpression + init?: Expression +} + +export interface ExpressionStatement { + type?: NodeType + expression?: Expression +} + +export interface ReturnStatement { + type?: NodeType + argument?: Expression +} + +export interface OptionStatement { + type?: NodeType + assignment?: VariableAssignment | MemberAssignment +} + +export interface BuiltinStatement { + type?: NodeType + id?: Identifier +} + +export interface TestStatement { + type?: NodeType + assignment?: VariableAssignment +} + +export interface FluxSuggestions { + funcs?: { + name?: string + params?: any + } +} + +export interface Authorizations { + readonly links?: Links + authorizations?: Authorization[] +} + +export interface Query { + extern?: File + query: string + type?: 'flux' | 'influxql' + db?: string + rp?: string + cluster?: string + dialect?: Dialect +} + +export interface Dialect { + header?: boolean + delimiter?: string + annotations?: Array<'group' | 'datatype' | 'default'> + commentPrefix?: string + dateTimeFormat?: 'RFC3339' | 'RFC3339Nano' +} + +export interface AnalyzeQueryResponse { + errors?: Array<{ + line?: number + column?: number + character?: number + message?: string + }> +} + +export interface Organizations { + links?: Links + orgs?: Organization[] +} + +export type SecretKeysResponse = SecretKeys & { + readonly links?: { + self?: string + org?: string + } +} + +export interface SecretKeys { + secrets?: string[] +} + +export type Secrets = any + +export interface Tasks { + readonly links?: Links + tasks?: Task[] +} + +export interface Task { + readonly id: string + orgID: string + org?: string + name: string + description?: string + status?: TaskStatusType + labels?: Labels + authorizationID?: string + flux: string + every?: string + cron?: string + offset?: string + readonly latestCompleted?: string + readonly createdAt?: string + readonly updatedAt?: string + readonly links?: { + self?: Link + owners?: Link + members?: Link + runs?: Link + logs?: Link + labels?: Link + } +} + +export interface TaskCreateRequest { + orgID?: string + org?: string + status?: 'active' | 'inactive' + flux: string + token: string +} + +export interface TaskUpdateRequest { + status?: 'active' | 'inactive' + flux?: string + name?: string + every?: string + cron?: string + offset?: string + token?: string +} + +export interface Runs { + readonly links?: Links + runs?: Run[] +} + +export interface Run { + readonly id?: string + readonly taskID?: string + readonly status?: 'scheduled' | 'started' | 'failed' | 'success' | 'canceled' + scheduledFor?: string + log?: Array<{ + runID?: string + time?: string + message?: string + }> + readonly startedAt?: string + readonly finishedAt?: string + readonly requestedAt?: string + readonly links?: { + self?: string + task?: string + logs?: string + retry?: string + } +} + +export interface RunManually { + scheduledFor?: string +} + +export interface Logs { + readonly events?: LogEvent[] +} + +export interface LogEvent { + readonly time?: string + readonly message?: string +} + +export interface PasswordResetBody { + password: string +} + +export interface Users { + links?: { + self?: string + } + users?: User[] +} + +export interface Checks { + checks?: Check[] + links?: Links +} + +export interface NotificationRules { + notificationRules?: NotificationRule[] + links?: Links +} + +export type NotificationRule = + | SlackNotificationRule + | SMTPNotificationRule + | PagerDutyNotificationRule + +export type SlackNotificationRule = NotificationRuleBase & { + type: 'slack' + channel?: string + messageTemplate: string +} + +export interface NotificationRuleBase { + readonly id: string + readonly notifyEndpointID?: string + orgID?: string + readonly authorizationID?: string + readonly createdAt?: string + readonly updatedAt?: string + status: TaskStatusType + name: string + sleepUntil?: string + every?: string + offset?: string + cron?: string + runbookLink?: string + limitEvery?: number + limit?: number + tagRules: TagRule[] + description?: string + statusRules: StatusRule[] + labels?: Labels +} + +export interface TagRule { + key?: string + value?: string + operator?: 'equal' | 'notequal' | 'equalregex' | 'notequalregex' +} + +export interface StatusRule { + currentLevel?: LevelRule + previousLevel?: LevelRule + count?: number + period?: string +} + +export interface LevelRule { + level?: CheckStatusLevel + operation?: 'equal' | 'notequal' +} + +export type SMTPNotificationRule = NotificationRuleBase & { + type: 'smtp' + subjectTemplate: string + bodyTemplate: string + to: string +} + +export type PagerDutyNotificationRule = NotificationRuleBase & { + type: 'pagerduty' + messageTemplate: string +} + +export interface NotificationRuleUpdate { + name?: string + description?: string + status?: 'active' | 'inactive' +} + +export interface NotificationEndpoints { + notificationEndpoints?: NotificationEndpoint[] + links?: Links +} + +export type NotificationEndpoint = + | (SlackNotificationEndpoint & {type: string}) + | (SMTPNotificationEndpoint & {type: string}) + | (PagerDutyNotificationEndpoint & {type: string}) + | (WebhookNotificationEndpoint & {type: string}) + +export type SlackNotificationEndpoint = NotificationEndpointBase & any + +export interface NotificationEndpointBase { + id?: string + orgID?: string + userID?: string + readonly createdAt?: string + readonly updatedAt?: string + description?: string + name?: string + status?: 'active' | 'inactive' + labels?: Labels + type: NotificationEndpointType +} + +export type NotificationEndpointType = + | 'slack' + | 'smtp' + | 'pagerduty' + | 'webhook' + +export type SMTPNotificationEndpoint = NotificationEndpointBase & any + +export type PagerDutyNotificationEndpoint = NotificationEndpointBase & any + +export type WebhookNotificationEndpoint = NotificationEndpointBase & any + +interface RequestOptions { + signal?: AbortSignal +} + +const request = async ( + method: string, + url: string, + params: any = {}, + options: RequestOptions = {} +): Promise => { + const requestHeaders = new Headers(params.headers) + const contentType = requestHeaders.get('Content-Type') || '' + + const body = + params.data && contentType.includes('json') + ? JSON.stringify(params.data) + : params.data + + const query = params.query ? `?${new URLSearchParams(params.query)}` : '' + + const response = await fetch(`${url}${query}`, { + method, + body, + credentials: 'same-origin', + signal: options.signal, + headers: requestHeaders, + }) + + const {status, headers} = response + const responseContentType = headers.get('Content-Type') + + let data + + if (responseContentType.includes('json')) { + data = await response.json() + } else if (responseContentType.includes('octet-stream')) { + data = await response.blob() + } else if (responseContentType.includes('text')) { + data = await response.text() + } + + return {status, headers, data} +} + +export interface PostSigninParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostSigninResult = + | PostSigninNoContentResult + | PostSigninUnauthorizedResult + | PostSigninDefaultResult + +interface PostSigninNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PostSigninUnauthorizedResult { + status: 401 + headers: Headers + data: Error +} + +interface PostSigninDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postSignin = ( + params: PostSigninParams, + options: RequestOptions = {} +): Promise => + request('POST', '/api/v2/signin', params, options) as Promise< + PostSigninResult + > + +export interface PostSignoutParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostSignoutResult = + | PostSignoutNoContentResult + | PostSignoutUnauthorizedResult + | PostSignoutDefaultResult + +interface PostSignoutNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PostSignoutUnauthorizedResult { + status: 401 + headers: Headers + data: Error +} + +interface PostSignoutDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postSignout = ( + params: PostSignoutParams, + options: RequestOptions = {} +): Promise => + request('POST', '/api/v2/signout', params, options) as Promise< + PostSignoutResult + > + +export interface GetParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetResult = GetDefaultResult + +interface GetDefaultResult { + status: 500 + headers: Headers + data: Routes +} + +export const get = ( + params: GetParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/', params, options) as Promise + +export interface GetSetupParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetSetupResult = GetSetupOKResult + +interface GetSetupOKResult { + status: 200 + headers: Headers + data: IsOnboarding +} + +export const getSetup = ( + params: GetSetupParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/setup', params, options) as Promise + +export interface PostSetupParams { + data: OnboardingRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostSetupResult = PostSetupCreatedResult + +interface PostSetupCreatedResult { + status: 201 + headers: Headers + data: OnboardingResponse +} + +export const postSetup = ( + params: PostSetupParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/setup', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetDocumentsTemplatesParams { + query?: { + org?: string + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDocumentsTemplatesResult = + | GetDocumentsTemplatesOKResult + | GetDocumentsTemplatesDefaultResult + +interface GetDocumentsTemplatesOKResult { + status: 200 + headers: Headers + data: Documents +} + +interface GetDocumentsTemplatesDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDocumentsTemplates = ( + params: GetDocumentsTemplatesParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/documents/templates', params, options) as Promise< + GetDocumentsTemplatesResult + > + +export interface PostDocumentsTemplateParams { + data: DocumentCreate + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDocumentsTemplateResult = + | PostDocumentsTemplateCreatedResult + | PostDocumentsTemplateDefaultResult + +interface PostDocumentsTemplateCreatedResult { + status: 201 + headers: Headers + data: Document +} + +interface PostDocumentsTemplateDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDocumentsTemplate = ( + params: PostDocumentsTemplateParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/documents/templates', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetDocumentsTemplateParams { + templateID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDocumentsTemplateResult = + | GetDocumentsTemplateOKResult + | GetDocumentsTemplateDefaultResult + +interface GetDocumentsTemplateOKResult { + status: 200 + headers: Headers + data: Document +} + +interface GetDocumentsTemplateDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDocumentsTemplate = ( + params: GetDocumentsTemplateParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/documents/templates/${params.templateID}`, + params, + options + ) as Promise + +export interface PutDocumentsTemplateParams { + templateID: string + + data: DocumentUpdate + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutDocumentsTemplateResult = + | PutDocumentsTemplateOKResult + | PutDocumentsTemplateDefaultResult + +interface PutDocumentsTemplateOKResult { + status: 200 + headers: Headers + data: Document +} + +interface PutDocumentsTemplateDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putDocumentsTemplate = ( + params: PutDocumentsTemplateParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/documents/templates/${params.templateID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDocumentsTemplateParams { + templateID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDocumentsTemplateResult = + | DeleteDocumentsTemplateNoContentResult + | DeleteDocumentsTemplateDefaultResult + +interface DeleteDocumentsTemplateNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDocumentsTemplateDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDocumentsTemplate = ( + params: DeleteDocumentsTemplateParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/documents/templates/${params.templateID}`, + params, + options + ) as Promise + +export interface GetDocumentsTemplatesLabelsParams { + templateID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDocumentsTemplatesLabelsResult = + | GetDocumentsTemplatesLabelsOKResult + | GetDocumentsTemplatesLabelsDefaultResult + +interface GetDocumentsTemplatesLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetDocumentsTemplatesLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDocumentsTemplatesLabels = ( + params: GetDocumentsTemplatesLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/documents/templates/${params.templateID}/labels`, + params, + options + ) as Promise + +export interface PostDocumentsTemplatesLabelParams { + templateID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDocumentsTemplatesLabelResult = + | PostDocumentsTemplatesLabelCreatedResult + | PostDocumentsTemplatesLabelDefaultResult + +interface PostDocumentsTemplatesLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostDocumentsTemplatesLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDocumentsTemplatesLabel = ( + params: PostDocumentsTemplatesLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/documents/templates/${params.templateID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDocumentsTemplatesLabelParams { + templateID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDocumentsTemplatesLabelResult = + | DeleteDocumentsTemplatesLabelNoContentResult + | DeleteDocumentsTemplatesLabelNotFoundResult + | DeleteDocumentsTemplatesLabelDefaultResult + +interface DeleteDocumentsTemplatesLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDocumentsTemplatesLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteDocumentsTemplatesLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDocumentsTemplatesLabel = ( + params: DeleteDocumentsTemplatesLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/documents/templates/${params.templateID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetTelegrafsParams { + query?: { + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTelegrafsResult = GetTelegrafsOKResult | GetTelegrafsDefaultResult + +interface GetTelegrafsOKResult { + status: 200 + headers: Headers + data: Telegrafs +} + +interface GetTelegrafsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTelegrafs = ( + params: GetTelegrafsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/telegrafs', params, options) as Promise< + GetTelegrafsResult + > + +export interface PostTelegrafParams { + data: TelegrafRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTelegrafResult = PostTelegrafCreatedResult | PostTelegrafDefaultResult + +interface PostTelegrafCreatedResult { + status: 201 + headers: Headers + data: Telegraf +} + +interface PostTelegrafDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTelegraf = ( + params: PostTelegrafParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/telegrafs', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetTelegrafParams { + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + Accept?: string + } +} + +type GetTelegrafResult = GetTelegrafOKResult | GetTelegrafDefaultResult + +interface GetTelegrafOKResult { + status: 200 + headers: Headers + data: Telegraf +} + +interface GetTelegrafDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTelegraf = ( + params: GetTelegrafParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/telegrafs/${params.telegrafID}`, + params, + options + ) as Promise + +export interface PutTelegrafParams { + telegrafID: string + + data: TelegrafRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutTelegrafResult = PutTelegrafOKResult | PutTelegrafDefaultResult + +interface PutTelegrafOKResult { + status: 200 + headers: Headers + data: Telegraf +} + +interface PutTelegrafDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putTelegraf = ( + params: PutTelegrafParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/telegrafs/${params.telegrafID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTelegrafParams { + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTelegrafResult = + | DeleteTelegrafNoContentResult + | DeleteTelegrafDefaultResult + +interface DeleteTelegrafNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTelegrafDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTelegraf = ( + params: DeleteTelegrafParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/telegrafs/${params.telegrafID}`, + params, + options + ) as Promise + +export interface GetTelegrafsLabelsParams { + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTelegrafsLabelsResult = + | GetTelegrafsLabelsOKResult + | GetTelegrafsLabelsDefaultResult + +interface GetTelegrafsLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetTelegrafsLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTelegrafsLabels = ( + params: GetTelegrafsLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/telegrafs/${params.telegrafID}/labels`, + params, + options + ) as Promise + +export interface PostTelegrafsLabelParams { + telegrafID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTelegrafsLabelResult = + | PostTelegrafsLabelCreatedResult + | PostTelegrafsLabelDefaultResult + +interface PostTelegrafsLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostTelegrafsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTelegrafsLabel = ( + params: PostTelegrafsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/telegrafs/${params.telegrafID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTelegrafsLabelParams { + telegrafID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTelegrafsLabelResult = + | DeleteTelegrafsLabelNoContentResult + | DeleteTelegrafsLabelNotFoundResult + | DeleteTelegrafsLabelDefaultResult + +interface DeleteTelegrafsLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTelegrafsLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteTelegrafsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTelegrafsLabel = ( + params: DeleteTelegrafsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/telegrafs/${params.telegrafID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetTelegrafsMembersParams { + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTelegrafsMembersResult = + | GetTelegrafsMembersOKResult + | GetTelegrafsMembersDefaultResult + +interface GetTelegrafsMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetTelegrafsMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTelegrafsMembers = ( + params: GetTelegrafsMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/telegrafs/${params.telegrafID}/members`, + params, + options + ) as Promise + +export interface PostTelegrafsMemberParams { + telegrafID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTelegrafsMemberResult = + | PostTelegrafsMemberCreatedResult + | PostTelegrafsMemberDefaultResult + +interface PostTelegrafsMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostTelegrafsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTelegrafsMember = ( + params: PostTelegrafsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/telegrafs/${params.telegrafID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTelegrafsMemberParams { + userID: string + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTelegrafsMemberResult = + | DeleteTelegrafsMemberNoContentResult + | DeleteTelegrafsMemberDefaultResult + +interface DeleteTelegrafsMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTelegrafsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTelegrafsMember = ( + params: DeleteTelegrafsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/telegrafs/${params.telegrafID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetTelegrafsOwnersParams { + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTelegrafsOwnersResult = + | GetTelegrafsOwnersOKResult + | GetTelegrafsOwnersDefaultResult + +interface GetTelegrafsOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetTelegrafsOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTelegrafsOwners = ( + params: GetTelegrafsOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/telegrafs/${params.telegrafID}/owners`, + params, + options + ) as Promise + +export interface PostTelegrafsOwnerParams { + telegrafID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTelegrafsOwnerResult = + | PostTelegrafsOwnerCreatedResult + | PostTelegrafsOwnerDefaultResult + +interface PostTelegrafsOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostTelegrafsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTelegrafsOwner = ( + params: PostTelegrafsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/telegrafs/${params.telegrafID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTelegrafsOwnerParams { + userID: string + telegrafID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTelegrafsOwnerResult = + | DeleteTelegrafsOwnerNoContentResult + | DeleteTelegrafsOwnerDefaultResult + +interface DeleteTelegrafsOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTelegrafsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTelegrafsOwner = ( + params: DeleteTelegrafsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/telegrafs/${params.telegrafID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetScrapersParams { + query?: { + name?: string + id?: any + orgID?: string + org?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetScrapersResult = GetScrapersOKResult + +interface GetScrapersOKResult { + status: 200 + headers: Headers + data: ScraperTargetResponses +} + +export const getScrapers = ( + params: GetScrapersParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/scrapers', params, options) as Promise< + GetScrapersResult + > + +export interface PostScraperParams { + data: ScraperTargetRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostScraperResult = PostScraperCreatedResult | PostScraperDefaultResult + +interface PostScraperCreatedResult { + status: 201 + headers: Headers + data: ScraperTargetResponse +} + +interface PostScraperDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postScraper = ( + params: PostScraperParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/scrapers', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetScraperParams { + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetScraperResult = GetScraperOKResult | GetScraperDefaultResult + +interface GetScraperOKResult { + status: 200 + headers: Headers + data: ScraperTargetResponse +} + +interface GetScraperDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getScraper = ( + params: GetScraperParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/scrapers/${params.scraperTargetID}`, + params, + options + ) as Promise + +export interface PatchScraperParams { + scraperTargetID: string + + data: ScraperTargetRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchScraperResult = PatchScraperOKResult | PatchScraperDefaultResult + +interface PatchScraperOKResult { + status: 200 + headers: Headers + data: ScraperTargetResponse +} + +interface PatchScraperDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchScraper = ( + params: PatchScraperParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/scrapers/${params.scraperTargetID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteScraperParams { + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteScraperResult = + | DeleteScraperNoContentResult + | DeleteScraperDefaultResult + +interface DeleteScraperNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteScraperDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteScraper = ( + params: DeleteScraperParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/scrapers/${params.scraperTargetID}`, + params, + options + ) as Promise + +export interface GetScrapersLabelsParams { + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetScrapersLabelsResult = + | GetScrapersLabelsOKResult + | GetScrapersLabelsDefaultResult + +interface GetScrapersLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetScrapersLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getScrapersLabels = ( + params: GetScrapersLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/scrapers/${params.scraperTargetID}/labels`, + params, + options + ) as Promise + +export interface PostScrapersLabelParams { + scraperTargetID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostScrapersLabelResult = + | PostScrapersLabelCreatedResult + | PostScrapersLabelDefaultResult + +interface PostScrapersLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostScrapersLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postScrapersLabel = ( + params: PostScrapersLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/scrapers/${params.scraperTargetID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PatchScrapersLabelParams { + scraperTargetID: string + labelID: string + + data: Label + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchScrapersLabelResult = + | PatchScrapersLabelOKResult + | PatchScrapersLabelNotFoundResult + | PatchScrapersLabelDefaultResult + +interface PatchScrapersLabelOKResult { + status: 200 + headers: Headers + data: any +} + +interface PatchScrapersLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchScrapersLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchScrapersLabel = ( + params: PatchScrapersLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/scrapers/${params.scraperTargetID}/labels/${params.labelID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteScrapersLabelParams { + scraperTargetID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteScrapersLabelResult = + | DeleteScrapersLabelNoContentResult + | DeleteScrapersLabelNotFoundResult + | DeleteScrapersLabelDefaultResult + +interface DeleteScrapersLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteScrapersLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteScrapersLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteScrapersLabel = ( + params: DeleteScrapersLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/scrapers/${params.scraperTargetID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetScrapersMembersParams { + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetScrapersMembersResult = + | GetScrapersMembersOKResult + | GetScrapersMembersDefaultResult + +interface GetScrapersMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetScrapersMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getScrapersMembers = ( + params: GetScrapersMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/scrapers/${params.scraperTargetID}/members`, + params, + options + ) as Promise + +export interface PostScrapersMemberParams { + scraperTargetID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostScrapersMemberResult = + | PostScrapersMemberCreatedResult + | PostScrapersMemberDefaultResult + +interface PostScrapersMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostScrapersMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postScrapersMember = ( + params: PostScrapersMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/scrapers/${params.scraperTargetID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteScrapersMemberParams { + userID: string + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteScrapersMemberResult = + | DeleteScrapersMemberNoContentResult + | DeleteScrapersMemberDefaultResult + +interface DeleteScrapersMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteScrapersMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteScrapersMember = ( + params: DeleteScrapersMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/scrapers/${params.scraperTargetID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetScrapersOwnersParams { + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetScrapersOwnersResult = + | GetScrapersOwnersOKResult + | GetScrapersOwnersDefaultResult + +interface GetScrapersOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetScrapersOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getScrapersOwners = ( + params: GetScrapersOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/scrapers/${params.scraperTargetID}/owners`, + params, + options + ) as Promise + +export interface PostScrapersOwnerParams { + scraperTargetID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostScrapersOwnerResult = + | PostScrapersOwnerCreatedResult + | PostScrapersOwnerDefaultResult + +interface PostScrapersOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostScrapersOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postScrapersOwner = ( + params: PostScrapersOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/scrapers/${params.scraperTargetID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteScrapersOwnerParams { + userID: string + scraperTargetID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteScrapersOwnerResult = + | DeleteScrapersOwnerNoContentResult + | DeleteScrapersOwnerDefaultResult + +interface DeleteScrapersOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteScrapersOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteScrapersOwner = ( + params: DeleteScrapersOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/scrapers/${params.scraperTargetID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetVariablesParams { + query?: { + org?: string + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetVariablesResult = + | GetVariablesOKResult + | GetVariablesBadRequestResult + | GetVariablesDefaultResult + +interface GetVariablesOKResult { + status: 200 + headers: Headers + data: Variables +} + +interface GetVariablesBadRequestResult { + status: 400 + headers: Headers + data: Error +} + +interface GetVariablesDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getVariables = ( + params: GetVariablesParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/variables', params, options) as Promise< + GetVariablesResult + > + +export interface PostVariableParams { + data: Variable + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostVariableResult = PostVariableCreatedResult | PostVariableDefaultResult + +interface PostVariableCreatedResult { + status: 201 + headers: Headers + data: Variable +} + +interface PostVariableDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postVariable = ( + params: PostVariableParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/variables', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetVariableParams { + variableID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetVariableResult = + | GetVariableOKResult + | GetVariableNotFoundResult + | GetVariableDefaultResult + +interface GetVariableOKResult { + status: 200 + headers: Headers + data: Variable +} + +interface GetVariableNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface GetVariableDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getVariable = ( + params: GetVariableParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/variables/${params.variableID}`, + params, + options + ) as Promise + +export interface PutVariableParams { + variableID: string + + data: Variable + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutVariableResult = PutVariableOKResult | PutVariableDefaultResult + +interface PutVariableOKResult { + status: 200 + headers: Headers + data: Variable +} + +interface PutVariableDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putVariable = ( + params: PutVariableParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/variables/${params.variableID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PatchVariableParams { + variableID: string + + data: Variable + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchVariableResult = PatchVariableOKResult | PatchVariableDefaultResult + +interface PatchVariableOKResult { + status: 200 + headers: Headers + data: Variable +} + +interface PatchVariableDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchVariable = ( + params: PatchVariableParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/variables/${params.variableID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteVariableParams { + variableID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteVariableResult = + | DeleteVariableNoContentResult + | DeleteVariableDefaultResult + +interface DeleteVariableNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteVariableDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteVariable = ( + params: DeleteVariableParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/variables/${params.variableID}`, + params, + options + ) as Promise + +export interface GetVariablesLabelsParams { + variableID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetVariablesLabelsResult = + | GetVariablesLabelsOKResult + | GetVariablesLabelsDefaultResult + +interface GetVariablesLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetVariablesLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getVariablesLabels = ( + params: GetVariablesLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/variables/${params.variableID}/labels`, + params, + options + ) as Promise + +export interface PostVariablesLabelParams { + variableID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostVariablesLabelResult = + | PostVariablesLabelCreatedResult + | PostVariablesLabelDefaultResult + +interface PostVariablesLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostVariablesLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postVariablesLabel = ( + params: PostVariablesLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/variables/${params.variableID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteVariablesLabelParams { + variableID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteVariablesLabelResult = + | DeleteVariablesLabelNoContentResult + | DeleteVariablesLabelNotFoundResult + | DeleteVariablesLabelDefaultResult + +interface DeleteVariablesLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteVariablesLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteVariablesLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteVariablesLabel = ( + params: DeleteVariablesLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/variables/${params.variableID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface PostWriteParams { + data: string + + query: { + org: string + bucket: string + precision?: any + } + + headers?: { + 'Zap-Trace-Span'?: string + 'Content-Encoding'?: string + 'Content-Type'?: string + 'Content-Length'?: number + Accept?: string + } +} + +type PostWriteResult = + | PostWriteNoContentResult + | PostWriteBadRequestResult + | PostWriteUnauthorizedResult + | PostWriteForbiddenResult + | PostWritePayloadTooLargeResult + | PostWriteTooManyRequestsResult + | PostWriteServiceUnavailableResult + | PostWriteDefaultResult + +interface PostWriteNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PostWriteBadRequestResult { + status: 400 + headers: Headers + data: LineProtocolError +} + +interface PostWriteUnauthorizedResult { + status: 401 + headers: Headers + data: Error +} + +interface PostWriteForbiddenResult { + status: 403 + headers: Headers + data: Error +} + +interface PostWritePayloadTooLargeResult { + status: 413 + headers: Headers + data: LineProtocolLengthError +} + +interface PostWriteTooManyRequestsResult { + status: 429 + headers: Headers + data: any +} + +interface PostWriteServiceUnavailableResult { + status: 503 + headers: Headers + data: any +} + +interface PostWriteDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postWrite = ( + params: PostWriteParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/write', + {...params, headers: {...params.headers, 'Content-Type': 'text/plain'}}, + options + ) as Promise + +export interface GetReadyParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetReadyResult = GetReadyOKResult | GetReadyDefaultResult + +interface GetReadyOKResult { + status: 200 + headers: Headers + data: Ready +} + +interface GetReadyDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getReady = ( + params: GetReadyParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/ready', params, options) as Promise + +export interface GetHealthParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetHealthResult = + | GetHealthOKResult + | GetHealthServiceUnavailableResult + | GetHealthDefaultResult + +interface GetHealthOKResult { + status: 200 + headers: Headers + data: HealthCheck +} + +interface GetHealthServiceUnavailableResult { + status: 503 + headers: Headers + data: HealthCheck +} + +interface GetHealthDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getHealth = ( + params: GetHealthParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/health', params, options) as Promise + +export interface GetSourcesParams { + query?: { + org?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetSourcesResult = GetSourcesOKResult | GetSourcesDefaultResult + +interface GetSourcesOKResult { + status: 200 + headers: Headers + data: Sources +} + +interface GetSourcesDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getSources = ( + params: GetSourcesParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/sources', params, options) as Promise< + GetSourcesResult + > + +export interface PostSourceParams { + data: Source + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostSourceResult = PostSourceCreatedResult | PostSourceDefaultResult + +interface PostSourceCreatedResult { + status: 201 + headers: Headers + data: Source +} + +interface PostSourceDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postSource = ( + params: PostSourceParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/sources', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetSourceParams { + sourceID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetSourceResult = + | GetSourceOKResult + | GetSourceNotFoundResult + | GetSourceDefaultResult + +interface GetSourceOKResult { + status: 200 + headers: Headers + data: Source +} + +interface GetSourceNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface GetSourceDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getSource = ( + params: GetSourceParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/sources/${params.sourceID}`, + params, + options + ) as Promise + +export interface PatchSourceParams { + sourceID: string + + data: Source + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchSourceResult = + | PatchSourceOKResult + | PatchSourceNotFoundResult + | PatchSourceDefaultResult + +interface PatchSourceOKResult { + status: 200 + headers: Headers + data: Source +} + +interface PatchSourceNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchSourceDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchSource = ( + params: PatchSourceParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/sources/${params.sourceID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteSourceParams { + sourceID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteSourceResult = + | DeleteSourceNoContentResult + | DeleteSourceNotFoundResult + | DeleteSourceDefaultResult + +interface DeleteSourceNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteSourceNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteSourceDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteSource = ( + params: DeleteSourceParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/sources/${params.sourceID}`, + params, + options + ) as Promise + +export interface GetSourcesHealthParams { + sourceID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetSourcesHealthResult = + | GetSourcesHealthOKResult + | GetSourcesHealthServiceUnavailableResult + | GetSourcesHealthDefaultResult + +interface GetSourcesHealthOKResult { + status: 200 + headers: Headers + data: HealthCheck +} + +interface GetSourcesHealthServiceUnavailableResult { + status: 503 + headers: Headers + data: HealthCheck +} + +interface GetSourcesHealthDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getSourcesHealth = ( + params: GetSourcesHealthParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/sources/${params.sourceID}/health`, + params, + options + ) as Promise + +export interface GetSourcesBucketsParams { + sourceID: string + + query?: { + org?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetSourcesBucketsResult = + | GetSourcesBucketsOKResult + | GetSourcesBucketsNotFoundResult + | GetSourcesBucketsDefaultResult + +interface GetSourcesBucketsOKResult { + status: 200 + headers: Headers + data: Buckets +} + +interface GetSourcesBucketsNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface GetSourcesBucketsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getSourcesBuckets = ( + params: GetSourcesBucketsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/sources/${params.sourceID}/buckets`, + params, + options + ) as Promise + +export interface GetLabelsParams { + query?: { + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetLabelsResult = GetLabelsOKResult | GetLabelsDefaultResult + +interface GetLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getLabels = ( + params: GetLabelsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/labels', params, options) as Promise + +export interface PostLabelParams { + data: LabelCreateRequest +} + +type PostLabelResult = PostLabelCreatedResult | PostLabelDefaultResult + +interface PostLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postLabel = ( + params: PostLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/labels', + {...params, headers: {'Content-Type': 'application/json'}}, + options + ) as Promise + +export interface GetLabelParams { + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetLabelResult = GetLabelOKResult | GetLabelDefaultResult + +interface GetLabelOKResult { + status: 200 + headers: Headers + data: LabelResponse +} + +interface GetLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getLabel = ( + params: GetLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface PatchLabelParams { + labelID: string + + data: LabelUpdate + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchLabelResult = + | PatchLabelOKResult + | PatchLabelNotFoundResult + | PatchLabelDefaultResult + +interface PatchLabelOKResult { + status: 200 + headers: Headers + data: LabelResponse +} + +interface PatchLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchLabel = ( + params: PatchLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/labels/${params.labelID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteLabelParams { + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteLabelResult = + | DeleteLabelNoContentResult + | DeleteLabelNotFoundResult + | DeleteLabelDefaultResult + +interface DeleteLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteLabel = ( + params: DeleteLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetDashboardsParams { + query?: { + owner?: string + sortBy?: string + id?: any + orgID?: string + org?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsResult = GetDashboardsOKResult | GetDashboardsDefaultResult + +interface GetDashboardsOKResult { + status: 200 + headers: Headers + data: Dashboards +} + +interface GetDashboardsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboards = ( + params: GetDashboardsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/dashboards', params, options) as Promise< + GetDashboardsResult + > + +export interface PostDashboardParams { + data: CreateDashboardRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDashboardResult = + | PostDashboardCreatedResult + | PostDashboardDefaultResult + +interface PostDashboardCreatedResult { + status: 201 + headers: Headers + data: Dashboard +} + +interface PostDashboardDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDashboard = ( + params: PostDashboardParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/dashboards', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetDashboardParams { + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardResult = + | GetDashboardOKResult + | GetDashboardNotFoundResult + | GetDashboardDefaultResult + +interface GetDashboardOKResult { + status: 200 + headers: Headers + data: Dashboard +} + +interface GetDashboardNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface GetDashboardDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboard = ( + params: GetDashboardParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}`, + params, + options + ) as Promise + +export interface PatchDashboardParams { + dashboardID: string + + data: Dashboard + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchDashboardResult = + | PatchDashboardOKResult + | PatchDashboardNotFoundResult + | PatchDashboardDefaultResult + +interface PatchDashboardOKResult { + status: 200 + headers: Headers + data: Dashboard +} + +interface PatchDashboardNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchDashboardDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchDashboard = ( + params: PatchDashboardParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/dashboards/${params.dashboardID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDashboardParams { + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDashboardResult = + | DeleteDashboardNoContentResult + | DeleteDashboardNotFoundResult + | DeleteDashboardDefaultResult + +interface DeleteDashboardNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDashboardNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteDashboardDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDashboard = ( + params: DeleteDashboardParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/dashboards/${params.dashboardID}`, + params, + options + ) as Promise + +export interface PostDashboardsCellParams { + dashboardID: string + + data: CreateCell + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDashboardsCellResult = + | PostDashboardsCellCreatedResult + | PostDashboardsCellNotFoundResult + | PostDashboardsCellDefaultResult + +interface PostDashboardsCellCreatedResult { + status: 201 + headers: Headers + data: Cell +} + +interface PostDashboardsCellNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PostDashboardsCellDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDashboardsCell = ( + params: PostDashboardsCellParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/dashboards/${params.dashboardID}/cells`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PutDashboardsCellsParams { + dashboardID: string + + data: Cells + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutDashboardsCellsResult = + | PutDashboardsCellsOKResult + | PutDashboardsCellsNotFoundResult + | PutDashboardsCellsDefaultResult + +interface PutDashboardsCellsOKResult { + status: 200 + headers: Headers + data: Dashboard +} + +interface PutDashboardsCellsNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PutDashboardsCellsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putDashboardsCells = ( + params: PutDashboardsCellsParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/dashboards/${params.dashboardID}/cells`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PatchDashboardsCellParams { + dashboardID: string + cellID: string + + data: CellUpdate + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchDashboardsCellResult = + | PatchDashboardsCellOKResult + | PatchDashboardsCellNotFoundResult + | PatchDashboardsCellDefaultResult + +interface PatchDashboardsCellOKResult { + status: 200 + headers: Headers + data: Cell +} + +interface PatchDashboardsCellNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchDashboardsCellDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchDashboardsCell = ( + params: PatchDashboardsCellParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/dashboards/${params.dashboardID}/cells/${params.cellID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDashboardsCellParams { + dashboardID: string + cellID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDashboardsCellResult = + | DeleteDashboardsCellNoContentResult + | DeleteDashboardsCellNotFoundResult + | DeleteDashboardsCellDefaultResult + +interface DeleteDashboardsCellNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDashboardsCellNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteDashboardsCellDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDashboardsCell = ( + params: DeleteDashboardsCellParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/dashboards/${params.dashboardID}/cells/${params.cellID}`, + params, + options + ) as Promise + +export interface GetDashboardsCellsViewParams { + dashboardID: string + cellID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsCellsViewResult = + | GetDashboardsCellsViewOKResult + | GetDashboardsCellsViewNotFoundResult + | GetDashboardsCellsViewDefaultResult + +interface GetDashboardsCellsViewOKResult { + status: 200 + headers: Headers + data: View +} + +interface GetDashboardsCellsViewNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface GetDashboardsCellsViewDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboardsCellsView = ( + params: GetDashboardsCellsViewParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}/cells/${params.cellID}/view`, + params, + options + ) as Promise + +export interface PatchDashboardsCellsViewParams { + dashboardID: string + cellID: string + + data: View + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchDashboardsCellsViewResult = + | PatchDashboardsCellsViewOKResult + | PatchDashboardsCellsViewNotFoundResult + | PatchDashboardsCellsViewDefaultResult + +interface PatchDashboardsCellsViewOKResult { + status: 200 + headers: Headers + data: View +} + +interface PatchDashboardsCellsViewNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchDashboardsCellsViewDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchDashboardsCellsView = ( + params: PatchDashboardsCellsViewParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/dashboards/${params.dashboardID}/cells/${params.cellID}/view`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetDashboardsLabelsParams { + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsLabelsResult = + | GetDashboardsLabelsOKResult + | GetDashboardsLabelsDefaultResult + +interface GetDashboardsLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetDashboardsLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboardsLabels = ( + params: GetDashboardsLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}/labels`, + params, + options + ) as Promise + +export interface PostDashboardsLabelParams { + dashboardID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDashboardsLabelResult = + | PostDashboardsLabelCreatedResult + | PostDashboardsLabelDefaultResult + +interface PostDashboardsLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostDashboardsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDashboardsLabel = ( + params: PostDashboardsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/dashboards/${params.dashboardID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDashboardsLabelParams { + dashboardID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDashboardsLabelResult = + | DeleteDashboardsLabelNoContentResult + | DeleteDashboardsLabelNotFoundResult + | DeleteDashboardsLabelDefaultResult + +interface DeleteDashboardsLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDashboardsLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteDashboardsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDashboardsLabel = ( + params: DeleteDashboardsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/dashboards/${params.dashboardID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetDashboardsMembersParams { + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsMembersResult = + | GetDashboardsMembersOKResult + | GetDashboardsMembersDefaultResult + +interface GetDashboardsMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetDashboardsMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboardsMembers = ( + params: GetDashboardsMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}/members`, + params, + options + ) as Promise + +export interface PostDashboardsMemberParams { + dashboardID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDashboardsMemberResult = + | PostDashboardsMemberCreatedResult + | PostDashboardsMemberDefaultResult + +interface PostDashboardsMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostDashboardsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDashboardsMember = ( + params: PostDashboardsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/dashboards/${params.dashboardID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDashboardsMemberParams { + userID: string + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDashboardsMemberResult = + | DeleteDashboardsMemberNoContentResult + | DeleteDashboardsMemberDefaultResult + +interface DeleteDashboardsMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDashboardsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDashboardsMember = ( + params: DeleteDashboardsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/dashboards/${params.dashboardID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetDashboardsOwnersParams { + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsOwnersResult = + | GetDashboardsOwnersOKResult + | GetDashboardsOwnersDefaultResult + +interface GetDashboardsOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetDashboardsOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboardsOwners = ( + params: GetDashboardsOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}/owners`, + params, + options + ) as Promise + +export interface PostDashboardsOwnerParams { + dashboardID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostDashboardsOwnerResult = + | PostDashboardsOwnerCreatedResult + | PostDashboardsOwnerDefaultResult + +interface PostDashboardsOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostDashboardsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postDashboardsOwner = ( + params: PostDashboardsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/dashboards/${params.dashboardID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteDashboardsOwnerParams { + userID: string + dashboardID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteDashboardsOwnerResult = + | DeleteDashboardsOwnerNoContentResult + | DeleteDashboardsOwnerDefaultResult + +interface DeleteDashboardsOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteDashboardsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteDashboardsOwner = ( + params: DeleteDashboardsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/dashboards/${params.dashboardID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetDashboardsLogsParams { + dashboardID: string + + query?: { + offset?: number + limit?: number + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetDashboardsLogsResult = + | GetDashboardsLogsOKResult + | GetDashboardsLogsDefaultResult + +interface GetDashboardsLogsOKResult { + status: 200 + headers: Headers + data: OperationLogs +} + +interface GetDashboardsLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getDashboardsLogs = ( + params: GetDashboardsLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/dashboards/${params.dashboardID}/logs`, + params, + options + ) as Promise + +export interface PostQueryAstParams { + data?: LanguageRequest + + headers?: { + 'Zap-Trace-Span'?: string + 'Content-Type'?: string + } +} + +type PostQueryAstResult = PostQueryAstOKResult | PostQueryAstDefaultResult + +interface PostQueryAstOKResult { + status: 200 + headers: Headers + data: ASTResponse +} + +interface PostQueryAstDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postQueryAst = ( + params: PostQueryAstParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/query/ast', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetQuerySuggestionsParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetQuerySuggestionsResult = + | GetQuerySuggestionsOKResult + | GetQuerySuggestionsDefaultResult + +interface GetQuerySuggestionsOKResult { + status: 200 + headers: Headers + data: FluxSuggestions +} + +interface GetQuerySuggestionsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getQuerySuggestions = ( + params: GetQuerySuggestionsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/query/suggestions', params, options) as Promise< + GetQuerySuggestionsResult + > + +export interface GetQuerySuggestionParams { + name: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetQuerySuggestionResult = + | GetQuerySuggestionOKResult + | GetQuerySuggestionDefaultResult + +interface GetQuerySuggestionOKResult { + status: 200 + headers: Headers + data: FluxSuggestions +} + +interface GetQuerySuggestionDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getQuerySuggestion = ( + params: GetQuerySuggestionParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/query/suggestions/${params.name}`, + params, + options + ) as Promise + +export interface GetAuthorizationsParams { + query?: { + userID?: string + user?: string + orgID?: string + org?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetAuthorizationsResult = + | GetAuthorizationsOKResult + | GetAuthorizationsDefaultResult + +interface GetAuthorizationsOKResult { + status: 200 + headers: Headers + data: Authorizations +} + +interface GetAuthorizationsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getAuthorizations = ( + params: GetAuthorizationsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/authorizations', params, options) as Promise< + GetAuthorizationsResult + > + +export interface PostAuthorizationParams { + data: Authorization + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostAuthorizationResult = + | PostAuthorizationCreatedResult + | PostAuthorizationBadRequestResult + | PostAuthorizationDefaultResult + +interface PostAuthorizationCreatedResult { + status: 201 + headers: Headers + data: Authorization +} + +interface PostAuthorizationBadRequestResult { + status: 400 + headers: Headers + data: Error +} + +interface PostAuthorizationDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postAuthorization = ( + params: PostAuthorizationParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/authorizations', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetAuthorizationParams { + authID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetAuthorizationResult = + | GetAuthorizationOKResult + | GetAuthorizationDefaultResult + +interface GetAuthorizationOKResult { + status: 200 + headers: Headers + data: Authorization +} + +interface GetAuthorizationDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getAuthorization = ( + params: GetAuthorizationParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/authorizations/${params.authID}`, + params, + options + ) as Promise + +export interface PatchAuthorizationParams { + authID: string + + data: AuthorizationUpdateRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchAuthorizationResult = + | PatchAuthorizationOKResult + | PatchAuthorizationDefaultResult + +interface PatchAuthorizationOKResult { + status: 200 + headers: Headers + data: Authorization +} + +interface PatchAuthorizationDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchAuthorization = ( + params: PatchAuthorizationParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/authorizations/${params.authID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteAuthorizationParams { + authID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteAuthorizationResult = + | DeleteAuthorizationNoContentResult + | DeleteAuthorizationDefaultResult + +interface DeleteAuthorizationNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteAuthorizationDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteAuthorization = ( + params: DeleteAuthorizationParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/authorizations/${params.authID}`, + params, + options + ) as Promise + +export interface PostQueryAnalyzeParams { + data?: Query + + headers?: { + 'Zap-Trace-Span'?: string + 'Content-Type'?: string + } +} + +type PostQueryAnalyzeResult = + | PostQueryAnalyzeOKResult + | PostQueryAnalyzeDefaultResult + +interface PostQueryAnalyzeOKResult { + status: 200 + headers: Headers + data: AnalyzeQueryResponse +} + +interface PostQueryAnalyzeDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postQueryAnalyze = ( + params: PostQueryAnalyzeParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/query/analyze', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PostQueryParams { + data?: Query + + query?: { + org?: string + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + 'Accept-Encoding'?: string + 'Content-Type'?: string + } +} + +type PostQueryResult = + | PostQueryOKResult + | PostQueryBadRequestResult + | PostQueryDefaultResult + +interface PostQueryOKResult { + status: 200 + headers: Headers + data: string +} + +interface PostQueryBadRequestResult { + status: 400 + headers: Headers + data: string +} + +interface PostQueryDefaultResult { + status: 500 + headers: Headers + data: string +} + +export const postQuery = ( + params: PostQueryParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/query', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetBucketsParams { + query?: { + offset?: number + limit?: number + org?: string + orgID?: string + name?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketsResult = GetBucketsOKResult | GetBucketsDefaultResult + +interface GetBucketsOKResult { + status: 200 + headers: Headers + data: Buckets +} + +interface GetBucketsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBuckets = ( + params: GetBucketsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/buckets', params, options) as Promise< + GetBucketsResult + > + +export interface PostBucketParams { + data: Bucket + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostBucketResult = PostBucketCreatedResult | PostBucketDefaultResult + +interface PostBucketCreatedResult { + status: 201 + headers: Headers + data: Bucket +} + +interface PostBucketDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postBucket = ( + params: PostBucketParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/buckets', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetBucketParams { + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketResult = GetBucketOKResult | GetBucketDefaultResult + +interface GetBucketOKResult { + status: 200 + headers: Headers + data: Bucket +} + +interface GetBucketDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBucket = ( + params: GetBucketParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/buckets/${params.bucketID}`, + params, + options + ) as Promise + +export interface PatchBucketParams { + bucketID: string + + data: Bucket + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchBucketResult = PatchBucketOKResult | PatchBucketDefaultResult + +interface PatchBucketOKResult { + status: 200 + headers: Headers + data: Bucket +} + +interface PatchBucketDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchBucket = ( + params: PatchBucketParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/buckets/${params.bucketID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteBucketParams { + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteBucketResult = + | DeleteBucketNoContentResult + | DeleteBucketNotFoundResult + | DeleteBucketDefaultResult + +interface DeleteBucketNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteBucketNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteBucketDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteBucket = ( + params: DeleteBucketParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/buckets/${params.bucketID}`, + params, + options + ) as Promise + +export interface GetBucketsLabelsParams { + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketsLabelsResult = + | GetBucketsLabelsOKResult + | GetBucketsLabelsDefaultResult + +interface GetBucketsLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetBucketsLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBucketsLabels = ( + params: GetBucketsLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/buckets/${params.bucketID}/labels`, + params, + options + ) as Promise + +export interface PostBucketsLabelParams { + bucketID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostBucketsLabelResult = + | PostBucketsLabelCreatedResult + | PostBucketsLabelDefaultResult + +interface PostBucketsLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostBucketsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postBucketsLabel = ( + params: PostBucketsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/buckets/${params.bucketID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteBucketsLabelParams { + bucketID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteBucketsLabelResult = + | DeleteBucketsLabelNoContentResult + | DeleteBucketsLabelNotFoundResult + | DeleteBucketsLabelDefaultResult + +interface DeleteBucketsLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteBucketsLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteBucketsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteBucketsLabel = ( + params: DeleteBucketsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/buckets/${params.bucketID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetBucketsMembersParams { + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketsMembersResult = + | GetBucketsMembersOKResult + | GetBucketsMembersDefaultResult + +interface GetBucketsMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetBucketsMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBucketsMembers = ( + params: GetBucketsMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/buckets/${params.bucketID}/members`, + params, + options + ) as Promise + +export interface PostBucketsMemberParams { + bucketID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostBucketsMemberResult = + | PostBucketsMemberCreatedResult + | PostBucketsMemberDefaultResult + +interface PostBucketsMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostBucketsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postBucketsMember = ( + params: PostBucketsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/buckets/${params.bucketID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteBucketsMemberParams { + userID: string + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteBucketsMemberResult = + | DeleteBucketsMemberNoContentResult + | DeleteBucketsMemberDefaultResult + +interface DeleteBucketsMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteBucketsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteBucketsMember = ( + params: DeleteBucketsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/buckets/${params.bucketID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetBucketsOwnersParams { + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketsOwnersResult = + | GetBucketsOwnersOKResult + | GetBucketsOwnersDefaultResult + +interface GetBucketsOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetBucketsOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBucketsOwners = ( + params: GetBucketsOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/buckets/${params.bucketID}/owners`, + params, + options + ) as Promise + +export interface PostBucketsOwnerParams { + bucketID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostBucketsOwnerResult = + | PostBucketsOwnerCreatedResult + | PostBucketsOwnerDefaultResult + +interface PostBucketsOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostBucketsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postBucketsOwner = ( + params: PostBucketsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/buckets/${params.bucketID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteBucketsOwnerParams { + userID: string + bucketID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteBucketsOwnerResult = + | DeleteBucketsOwnerNoContentResult + | DeleteBucketsOwnerDefaultResult + +interface DeleteBucketsOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteBucketsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteBucketsOwner = ( + params: DeleteBucketsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/buckets/${params.bucketID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetBucketsLogsParams { + bucketID: string + + query?: { + offset?: number + limit?: number + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetBucketsLogsResult = GetBucketsLogsOKResult | GetBucketsLogsDefaultResult + +interface GetBucketsLogsOKResult { + status: 200 + headers: Headers + data: OperationLogs +} + +interface GetBucketsLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getBucketsLogs = ( + params: GetBucketsLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/buckets/${params.bucketID}/logs`, + params, + options + ) as Promise + +export interface GetOrgsParams { + query?: { + org?: string + orgID?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsResult = GetOrgsOKResult | GetOrgsDefaultResult + +interface GetOrgsOKResult { + status: 200 + headers: Headers + data: Organizations +} + +interface GetOrgsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgs = ( + params: GetOrgsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/orgs', params, options) as Promise + +export interface PostOrgParams { + data: Organization + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostOrgResult = PostOrgCreatedResult | PostOrgDefaultResult + +interface PostOrgCreatedResult { + status: 201 + headers: Headers + data: Organization +} + +interface PostOrgDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postOrg = ( + params: PostOrgParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/orgs', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetOrgParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgResult = GetOrgOKResult | GetOrgDefaultResult + +interface GetOrgOKResult { + status: 200 + headers: Headers + data: Organization +} + +interface GetOrgDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrg = ( + params: GetOrgParams, + options: RequestOptions = {} +): Promise => + request('GET', `/api/v2/orgs/${params.orgID}`, params, options) as Promise< + GetOrgResult + > + +export interface PatchOrgParams { + orgID: string + + data: Organization + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchOrgResult = PatchOrgOKResult | PatchOrgDefaultResult + +interface PatchOrgOKResult { + status: 200 + headers: Headers + data: Organization +} + +interface PatchOrgDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchOrg = ( + params: PatchOrgParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/orgs/${params.orgID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteOrgParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteOrgResult = + | DeleteOrgNoContentResult + | DeleteOrgNotFoundResult + | DeleteOrgDefaultResult + +interface DeleteOrgNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteOrgNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteOrgDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteOrg = ( + params: DeleteOrgParams, + options: RequestOptions = {} +): Promise => + request('DELETE', `/api/v2/orgs/${params.orgID}`, params, options) as Promise< + DeleteOrgResult + > + +export interface GetOrgsLabelsParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsLabelsResult = GetOrgsLabelsOKResult | GetOrgsLabelsDefaultResult + +interface GetOrgsLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetOrgsLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgsLabels = ( + params: GetOrgsLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/orgs/${params.orgID}/labels`, + params, + options + ) as Promise + +export interface PostOrgsLabelParams { + orgID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostOrgsLabelResult = + | PostOrgsLabelCreatedResult + | PostOrgsLabelDefaultResult + +interface PostOrgsLabelCreatedResult { + status: 201 + headers: Headers + data: LabelResponse +} + +interface PostOrgsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postOrgsLabel = ( + params: PostOrgsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/orgs/${params.orgID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteOrgsLabelParams { + orgID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteOrgsLabelResult = + | DeleteOrgsLabelNoContentResult + | DeleteOrgsLabelNotFoundResult + | DeleteOrgsLabelDefaultResult + +interface DeleteOrgsLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteOrgsLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteOrgsLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteOrgsLabel = ( + params: DeleteOrgsLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/orgs/${params.orgID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetOrgsSecretsParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsSecretsResult = GetOrgsSecretsOKResult | GetOrgsSecretsDefaultResult + +interface GetOrgsSecretsOKResult { + status: 200 + headers: Headers + data: SecretKeysResponse +} + +interface GetOrgsSecretsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgsSecrets = ( + params: GetOrgsSecretsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/orgs/${params.orgID}/secrets`, + params, + options + ) as Promise + +export interface PatchOrgsSecretsParams { + orgID: string + + data: Secrets + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchOrgsSecretsResult = + | PatchOrgsSecretsNoContentResult + | PatchOrgsSecretsDefaultResult + +interface PatchOrgsSecretsNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PatchOrgsSecretsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchOrgsSecrets = ( + params: PatchOrgsSecretsParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/orgs/${params.orgID}/secrets`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PostOrgsSecretsDeleteParams { + orgID: string + + data: SecretKeys + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostOrgsSecretsDeleteResult = + | PostOrgsSecretsDeleteNoContentResult + | PostOrgsSecretsDeleteDefaultResult + +interface PostOrgsSecretsDeleteNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PostOrgsSecretsDeleteDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postOrgsSecretsDelete = ( + params: PostOrgsSecretsDeleteParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/orgs/${params.orgID}/secrets/delete`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetOrgsMembersParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsMembersResult = GetOrgsMembersOKResult | GetOrgsMembersDefaultResult + +interface GetOrgsMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetOrgsMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgsMembers = ( + params: GetOrgsMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/orgs/${params.orgID}/members`, + params, + options + ) as Promise + +export interface PostOrgsMemberParams { + orgID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostOrgsMemberResult = + | PostOrgsMemberCreatedResult + | PostOrgsMemberDefaultResult + +interface PostOrgsMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostOrgsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postOrgsMember = ( + params: PostOrgsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/orgs/${params.orgID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteOrgsMemberParams { + userID: string + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteOrgsMemberResult = + | DeleteOrgsMemberNoContentResult + | DeleteOrgsMemberDefaultResult + +interface DeleteOrgsMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteOrgsMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteOrgsMember = ( + params: DeleteOrgsMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/orgs/${params.orgID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetOrgsOwnersParams { + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsOwnersResult = GetOrgsOwnersOKResult | GetOrgsOwnersDefaultResult + +interface GetOrgsOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetOrgsOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgsOwners = ( + params: GetOrgsOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/orgs/${params.orgID}/owners`, + params, + options + ) as Promise + +export interface PostOrgsOwnerParams { + orgID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostOrgsOwnerResult = + | PostOrgsOwnerCreatedResult + | PostOrgsOwnerDefaultResult + +interface PostOrgsOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostOrgsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postOrgsOwner = ( + params: PostOrgsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/orgs/${params.orgID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteOrgsOwnerParams { + userID: string + orgID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteOrgsOwnerResult = + | DeleteOrgsOwnerNoContentResult + | DeleteOrgsOwnerDefaultResult + +interface DeleteOrgsOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteOrgsOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteOrgsOwner = ( + params: DeleteOrgsOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/orgs/${params.orgID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetOrgsLogsParams { + orgID: string + + query?: { + offset?: number + limit?: number + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetOrgsLogsResult = GetOrgsLogsOKResult | GetOrgsLogsDefaultResult + +interface GetOrgsLogsOKResult { + status: 200 + headers: Headers + data: OperationLogs +} + +interface GetOrgsLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getOrgsLogs = ( + params: GetOrgsLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/orgs/${params.orgID}/logs`, + params, + options + ) as Promise + +export interface GetTasksParams { + query?: { + after?: string + user?: string + org?: string + orgID?: string + limit?: number + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksResult = GetTasksOKResult | GetTasksDefaultResult + +interface GetTasksOKResult { + status: 200 + headers: Headers + data: Tasks +} + +interface GetTasksDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasks = ( + params: GetTasksParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/tasks', params, options) as Promise + +export interface PostTaskParams { + data: TaskCreateRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTaskResult = PostTaskCreatedResult | PostTaskDefaultResult + +interface PostTaskCreatedResult { + status: 201 + headers: Headers + data: Task +} + +interface PostTaskDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTask = ( + params: PostTaskParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/tasks', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetTaskParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTaskResult = GetTaskOKResult | GetTaskDefaultResult + +interface GetTaskOKResult { + status: 200 + headers: Headers + data: Task +} + +interface GetTaskDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTask = ( + params: GetTaskParams, + options: RequestOptions = {} +): Promise => + request('GET', `/api/v2/tasks/${params.taskID}`, params, options) as Promise< + GetTaskResult + > + +export interface PatchTaskParams { + taskID: string + + data: TaskUpdateRequest + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchTaskResult = PatchTaskOKResult | PatchTaskDefaultResult + +interface PatchTaskOKResult { + status: 200 + headers: Headers + data: Task +} + +interface PatchTaskDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchTask = ( + params: PatchTaskParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/tasks/${params.taskID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTaskParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTaskResult = DeleteTaskNoContentResult | DeleteTaskDefaultResult + +interface DeleteTaskNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTaskDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTask = ( + params: DeleteTaskParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/tasks/${params.taskID}`, + params, + options + ) as Promise + +export interface GetTasksRunsParams { + taskID: string + + query?: { + after?: string + limit?: number + afterTime?: string + beforeTime?: string + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksRunsResult = GetTasksRunsOKResult | GetTasksRunsDefaultResult + +interface GetTasksRunsOKResult { + status: 200 + headers: Headers + data: Runs +} + +interface GetTasksRunsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksRuns = ( + params: GetTasksRunsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/runs`, + params, + options + ) as Promise + +export interface PostTasksRunParams { + taskID: string + + data?: RunManually + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTasksRunResult = PostTasksRunCreatedResult | PostTasksRunDefaultResult + +interface PostTasksRunCreatedResult { + status: 201 + headers: Headers + data: Run +} + +interface PostTasksRunDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTasksRun = ( + params: PostTasksRunParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/tasks/${params.taskID}/runs`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetTasksRunParams { + taskID: string + runID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksRunResult = GetTasksRunOKResult | GetTasksRunDefaultResult + +interface GetTasksRunOKResult { + status: 200 + headers: Headers + data: Run +} + +interface GetTasksRunDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksRun = ( + params: GetTasksRunParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/runs/${params.runID}`, + params, + options + ) as Promise + +export interface DeleteTasksRunParams { + taskID: string + runID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTasksRunResult = + | DeleteTasksRunNoContentResult + | DeleteTasksRunDefaultResult + +interface DeleteTasksRunNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTasksRunDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTasksRun = ( + params: DeleteTasksRunParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/tasks/${params.taskID}/runs/${params.runID}`, + params, + options + ) as Promise + +export interface PostTasksRunsRetryParams { + taskID: string + runID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTasksRunsRetryResult = + | PostTasksRunsRetryOKResult + | PostTasksRunsRetryDefaultResult + +interface PostTasksRunsRetryOKResult { + status: 200 + headers: Headers + data: Run +} + +interface PostTasksRunsRetryDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTasksRunsRetry = ( + params: PostTasksRunsRetryParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/tasks/${params.taskID}/runs/${params.runID}/retry`, + params, + options + ) as Promise + +export interface GetTasksLogsParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksLogsResult = GetTasksLogsOKResult | GetTasksLogsDefaultResult + +interface GetTasksLogsOKResult { + status: 200 + headers: Headers + data: Logs +} + +interface GetTasksLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksLogs = ( + params: GetTasksLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/logs`, + params, + options + ) as Promise + +export interface GetTasksRunsLogsParams { + taskID: string + runID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksRunsLogsResult = + | GetTasksRunsLogsOKResult + | GetTasksRunsLogsDefaultResult + +interface GetTasksRunsLogsOKResult { + status: 200 + headers: Headers + data: Logs +} + +interface GetTasksRunsLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksRunsLogs = ( + params: GetTasksRunsLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/runs/${params.runID}/logs`, + params, + options + ) as Promise + +export interface GetTasksLabelsParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksLabelsResult = GetTasksLabelsOKResult | GetTasksLabelsDefaultResult + +interface GetTasksLabelsOKResult { + status: 200 + headers: Headers + data: LabelsResponse +} + +interface GetTasksLabelsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksLabels = ( + params: GetTasksLabelsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/labels`, + params, + options + ) as Promise + +export interface PostTasksLabelParams { + taskID: string + + data: LabelMapping + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTasksLabelResult = PostTasksLabelOKResult | PostTasksLabelDefaultResult + +interface PostTasksLabelOKResult { + status: 200 + headers: Headers + data: LabelResponse +} + +interface PostTasksLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTasksLabel = ( + params: PostTasksLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/tasks/${params.taskID}/labels`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTasksLabelParams { + taskID: string + labelID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTasksLabelResult = + | DeleteTasksLabelNoContentResult + | DeleteTasksLabelNotFoundResult + | DeleteTasksLabelDefaultResult + +interface DeleteTasksLabelNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTasksLabelNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteTasksLabelDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTasksLabel = ( + params: DeleteTasksLabelParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/tasks/${params.taskID}/labels/${params.labelID}`, + params, + options + ) as Promise + +export interface GetMeParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetMeResult = GetMeOKResult | GetMeDefaultResult + +interface GetMeOKResult { + status: 200 + headers: Headers + data: User +} + +interface GetMeDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getMe = ( + params: GetMeParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/me', params, options) as Promise + +export interface PutMePasswordParams { + data: PasswordResetBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutMePasswordResult = + | PutMePasswordNoContentResult + | PutMePasswordDefaultResult + +interface PutMePasswordNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PutMePasswordDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putMePassword = ( + params: PutMePasswordParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + '/api/v2/me/password', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetTasksMembersParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksMembersResult = + | GetTasksMembersOKResult + | GetTasksMembersDefaultResult + +interface GetTasksMembersOKResult { + status: 200 + headers: Headers + data: ResourceMembers +} + +interface GetTasksMembersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksMembers = ( + params: GetTasksMembersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/members`, + params, + options + ) as Promise + +export interface PostTasksMemberParams { + taskID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTasksMemberResult = + | PostTasksMemberCreatedResult + | PostTasksMemberDefaultResult + +interface PostTasksMemberCreatedResult { + status: 201 + headers: Headers + data: ResourceMember +} + +interface PostTasksMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTasksMember = ( + params: PostTasksMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/tasks/${params.taskID}/members`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTasksMemberParams { + userID: string + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTasksMemberResult = + | DeleteTasksMemberNoContentResult + | DeleteTasksMemberDefaultResult + +interface DeleteTasksMemberNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTasksMemberDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTasksMember = ( + params: DeleteTasksMemberParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/tasks/${params.taskID}/members/${params.userID}`, + params, + options + ) as Promise + +export interface GetTasksOwnersParams { + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetTasksOwnersResult = GetTasksOwnersOKResult | GetTasksOwnersDefaultResult + +interface GetTasksOwnersOKResult { + status: 200 + headers: Headers + data: ResourceOwners +} + +interface GetTasksOwnersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getTasksOwners = ( + params: GetTasksOwnersParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/tasks/${params.taskID}/owners`, + params, + options + ) as Promise + +export interface PostTasksOwnerParams { + taskID: string + + data: AddResourceMemberRequestBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostTasksOwnerResult = + | PostTasksOwnerCreatedResult + | PostTasksOwnerDefaultResult + +interface PostTasksOwnerCreatedResult { + status: 201 + headers: Headers + data: ResourceOwner +} + +interface PostTasksOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postTasksOwner = ( + params: PostTasksOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + `/api/v2/tasks/${params.taskID}/owners`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteTasksOwnerParams { + userID: string + taskID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteTasksOwnerResult = + | DeleteTasksOwnerNoContentResult + | DeleteTasksOwnerDefaultResult + +interface DeleteTasksOwnerNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteTasksOwnerDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteTasksOwner = ( + params: DeleteTasksOwnerParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/tasks/${params.taskID}/owners/${params.userID}`, + params, + options + ) as Promise + +export interface GetUsersParams { + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetUsersResult = GetUsersOKResult | GetUsersDefaultResult + +interface GetUsersOKResult { + status: 200 + headers: Headers + data: Users +} + +interface GetUsersDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getUsers = ( + params: GetUsersParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/users', params, options) as Promise + +export interface PostUserParams { + data: User + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PostUserResult = PostUserCreatedResult | PostUserDefaultResult + +interface PostUserCreatedResult { + status: 201 + headers: Headers + data: User +} + +interface PostUserDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postUser = ( + params: PostUserParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/users', + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetUserParams { + userID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetUserResult = GetUserOKResult | GetUserDefaultResult + +interface GetUserOKResult { + status: 200 + headers: Headers + data: User +} + +interface GetUserDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getUser = ( + params: GetUserParams, + options: RequestOptions = {} +): Promise => + request('GET', `/api/v2/users/${params.userID}`, params, options) as Promise< + GetUserResult + > + +export interface PatchUserParams { + userID: string + + data: User + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchUserResult = PatchUserOKResult | PatchUserDefaultResult + +interface PatchUserOKResult { + status: 200 + headers: Headers + data: User +} + +interface PatchUserDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchUser = ( + params: PatchUserParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/users/${params.userID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteUserParams { + userID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteUserResult = DeleteUserNoContentResult | DeleteUserDefaultResult + +interface DeleteUserNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteUserDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteUser = ( + params: DeleteUserParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/users/${params.userID}`, + params, + options + ) as Promise + +export interface PutUsersPasswordParams { + userID: string + + data: PasswordResetBody + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutUsersPasswordResult = + | PutUsersPasswordNoContentResult + | PutUsersPasswordDefaultResult + +interface PutUsersPasswordNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface PutUsersPasswordDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putUsersPassword = ( + params: PutUsersPasswordParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/users/${params.userID}/password`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface GetUsersLogsParams { + userID: string + + query?: { + offset?: number + limit?: number + } + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetUsersLogsResult = GetUsersLogsOKResult | GetUsersLogsDefaultResult + +interface GetUsersLogsOKResult { + status: 200 + headers: Headers + data: OperationLogs +} + +interface GetUsersLogsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getUsersLogs = ( + params: GetUsersLogsParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/users/${params.userID}/logs`, + params, + options + ) as Promise + +export interface GetChecksParams { + query: { + offset?: number + limit?: number + orgID: string + } +} + +type GetChecksResult = GetChecksOKResult | GetChecksDefaultResult + +interface GetChecksOKResult { + status: 200 + headers: Headers + data: Checks +} + +interface GetChecksDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getChecks = ( + params: GetChecksParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/checks', params, options) as Promise + +export interface PostCheckParams { + data: Check +} + +type PostCheckResult = PostCheckCreatedResult | PostCheckDefaultResult + +interface PostCheckCreatedResult { + status: 201 + headers: Headers + data: Check +} + +interface PostCheckDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postCheck = ( + params: PostCheckParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/checks', + {...params, headers: {'Content-Type': 'application/json'}}, + options + ) as Promise + +export interface GetCheckParams { + checkID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetCheckResult = GetCheckOKResult | GetCheckDefaultResult + +interface GetCheckOKResult { + status: 200 + headers: Headers + data: Check +} + +interface GetCheckDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getCheck = ( + params: GetCheckParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/checks/${params.checkID}`, + params, + options + ) as Promise + +export interface PatchCheckParams { + checkID: string + + data: Check + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchCheckResult = + | PatchCheckOKResult + | PatchCheckNotFoundResult + | PatchCheckDefaultResult + +interface PatchCheckOKResult { + status: 200 + headers: Headers + data: Check +} + +interface PatchCheckNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchCheckDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchCheck = ( + params: PatchCheckParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/checks/${params.checkID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteCheckParams { + checkID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteCheckResult = + | DeleteCheckNoContentResult + | DeleteCheckNotFoundResult + | DeleteCheckDefaultResult + +interface DeleteCheckNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteCheckNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteCheckDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteCheck = ( + params: DeleteCheckParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/checks/${params.checkID}`, + params, + options + ) as Promise + +export interface GetNotificationRulesParams { + query: { + offset?: number + limit?: number + orgID: string + checkID?: string + } +} + +type GetNotificationRulesResult = + | GetNotificationRulesOKResult + | GetNotificationRulesDefaultResult + +interface GetNotificationRulesOKResult { + status: 200 + headers: Headers + data: NotificationRules +} + +interface GetNotificationRulesDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getNotificationRules = ( + params: GetNotificationRulesParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/notificationRules', params, options) as Promise< + GetNotificationRulesResult + > + +export interface PostNotificationRuleParams { + data: NotificationRule +} + +type PostNotificationRuleResult = + | PostNotificationRuleCreatedResult + | PostNotificationRuleDefaultResult + +interface PostNotificationRuleCreatedResult { + status: 201 + headers: Headers + data: NotificationRule +} + +interface PostNotificationRuleDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postNotificationRule = ( + params: PostNotificationRuleParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/notificationRules', + {...params, headers: {'Content-Type': 'application/json'}}, + options + ) as Promise + +export interface GetNotificationRuleParams { + ruleID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetNotificationRuleResult = + | GetNotificationRuleOKResult + | GetNotificationRuleDefaultResult + +interface GetNotificationRuleOKResult { + status: 200 + headers: Headers + data: NotificationRule +} + +interface GetNotificationRuleDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getNotificationRule = ( + params: GetNotificationRuleParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/notificationRules/${params.ruleID}`, + params, + options + ) as Promise + +export interface PutNotificationRuleParams { + ruleID: string + + data: NotificationRule + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PutNotificationRuleResult = + | PutNotificationRuleOKResult + | PutNotificationRuleNotFoundResult + | PutNotificationRuleDefaultResult + +interface PutNotificationRuleOKResult { + status: 200 + headers: Headers + data: NotificationRule +} + +interface PutNotificationRuleNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PutNotificationRuleDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const putNotificationRule = ( + params: PutNotificationRuleParams, + options: RequestOptions = {} +): Promise => + request( + 'PUT', + `/api/v2/notificationRules/${params.ruleID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface PatchNotificationRuleParams { + ruleID: string + + data: NotificationRuleUpdate + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchNotificationRuleResult = + | PatchNotificationRuleOKResult + | PatchNotificationRuleNotFoundResult + | PatchNotificationRuleDefaultResult + +interface PatchNotificationRuleOKResult { + status: 200 + headers: Headers + data: NotificationRule +} + +interface PatchNotificationRuleNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchNotificationRuleDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchNotificationRule = ( + params: PatchNotificationRuleParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/notificationRules/${params.ruleID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteNotificationRuleParams { + ruleID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteNotificationRuleResult = + | DeleteNotificationRuleNoContentResult + | DeleteNotificationRuleNotFoundResult + | DeleteNotificationRuleDefaultResult + +interface DeleteNotificationRuleNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteNotificationRuleNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteNotificationRuleDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteNotificationRule = ( + params: DeleteNotificationRuleParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/notificationRules/${params.ruleID}`, + params, + options + ) as Promise + +export interface GetNotificationEndpointsParams { + query: { + offset?: number + limit?: number + orgID: string + } +} + +type GetNotificationEndpointsResult = + | GetNotificationEndpointsOKResult + | GetNotificationEndpointsDefaultResult + +interface GetNotificationEndpointsOKResult { + status: 200 + headers: Headers + data: NotificationEndpoints +} + +interface GetNotificationEndpointsDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getNotificationEndpoints = ( + params: GetNotificationEndpointsParams, + options: RequestOptions = {} +): Promise => + request('GET', '/api/v2/notificationEndpoints', params, options) as Promise< + GetNotificationEndpointsResult + > + +export interface PostNotificationEndpointParams { + data: NotificationEndpoint +} + +type PostNotificationEndpointResult = + | PostNotificationEndpointCreatedResult + | PostNotificationEndpointDefaultResult + +interface PostNotificationEndpointCreatedResult { + status: 201 + headers: Headers + data: NotificationRule +} + +interface PostNotificationEndpointDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const postNotificationEndpoint = ( + params: PostNotificationEndpointParams, + options: RequestOptions = {} +): Promise => + request( + 'POST', + '/api/v2/notificationEndpoints', + {...params, headers: {'Content-Type': 'application/json'}}, + options + ) as Promise + +export interface GetNotificationEndpointParams { + endpointID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type GetNotificationEndpointResult = + | GetNotificationEndpointOKResult + | GetNotificationEndpointDefaultResult + +interface GetNotificationEndpointOKResult { + status: 200 + headers: Headers + data: NotificationEndpoint +} + +interface GetNotificationEndpointDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const getNotificationEndpoint = ( + params: GetNotificationEndpointParams, + options: RequestOptions = {} +): Promise => + request( + 'GET', + `/api/v2/notificationEndpoints/${params.endpointID}`, + params, + options + ) as Promise + +export interface PatchNotificationEndpointParams { + endpointID: string + + data: NotificationEndpoint + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type PatchNotificationEndpointResult = + | PatchNotificationEndpointOKResult + | PatchNotificationEndpointNotFoundResult + | PatchNotificationEndpointDefaultResult + +interface PatchNotificationEndpointOKResult { + status: 200 + headers: Headers + data: NotificationEndpoint +} + +interface PatchNotificationEndpointNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface PatchNotificationEndpointDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const patchNotificationEndpoint = ( + params: PatchNotificationEndpointParams, + options: RequestOptions = {} +): Promise => + request( + 'PATCH', + `/api/v2/notificationEndpoints/${params.endpointID}`, + { + ...params, + headers: {...params.headers, 'Content-Type': 'application/json'}, + }, + options + ) as Promise + +export interface DeleteNotificationEndpointParams { + endpointID: string + + headers?: { + 'Zap-Trace-Span'?: string + } +} + +type DeleteNotificationEndpointResult = + | DeleteNotificationEndpointNoContentResult + | DeleteNotificationEndpointNotFoundResult + | DeleteNotificationEndpointDefaultResult + +interface DeleteNotificationEndpointNoContentResult { + status: 204 + headers: Headers + data: any +} + +interface DeleteNotificationEndpointNotFoundResult { + status: 404 + headers: Headers + data: Error +} + +interface DeleteNotificationEndpointDefaultResult { + status: 500 + headers: Headers + data: Error +} + +export const deleteNotificationEndpoint = ( + params: DeleteNotificationEndpointParams, + options: RequestOptions = {} +): Promise => + request( + 'DELETE', + `/api/v2/notificationEndpoints/${params.endpointID}`, + params, + options + ) as Promise diff --git a/ui/src/dashboards/actions/notes.ts b/ui/src/dashboards/actions/notes.ts index beac56bd7d0..6b8fbff2274 100644 --- a/ui/src/dashboards/actions/notes.ts +++ b/ui/src/dashboards/actions/notes.ts @@ -10,8 +10,7 @@ import {createView} from 'src/shared/utils/view' import {getView} from 'src/dashboards/selectors' // Types -import {GetState} from 'src/types' -import {NoteEditorMode, MarkdownView, ViewType} from 'src/types/dashboards' +import {GetState, MarkdownViewProperties, NoteEditorMode} from 'src/types' import {NoteEditorState} from 'src/dashboards/reducers/notes' import {Dispatch} from 'redux-thunk' @@ -72,7 +71,7 @@ export const createNoteCell = (dashboardID: string) => async ( } const {note} = getState().noteEditor - const view = createView(ViewType.Markdown) + const view = createView('markdown') view.properties.note = note diff --git a/ui/src/dashboards/apis/index.ts b/ui/src/dashboards/apis/index.ts index 6c93dd373ea..17c9ffeac8f 100644 --- a/ui/src/dashboards/apis/index.ts +++ b/ui/src/dashboards/apis/index.ts @@ -1,14 +1,14 @@ // Libraries import _ from 'lodash' -// Types -import {Cell, NewCell, Dashboard, View} from 'src/types' +// APIs +import * as api from 'src/client' -import {Cell as CellAPI, CreateDashboardRequest} from '@influxdata/influx' -import {client} from 'src/utils/api' +// Types +import {Cell, NewCell, Dashboard, View, CreateDashboardRequest} from 'src/types' export const addDashboardIDToCells = ( - cells: CellAPI[], + cells: Cell[], dashboardID: string ): Cell[] => { return cells.map(c => { @@ -16,48 +16,76 @@ export const addDashboardIDToCells = ( }) } -// TODO(desa): what to do about getting dashboards from another v2 source export const getDashboards = async (orgID: string): Promise => { - const dashboards = await client.dashboards.getAll(orgID) + const resp = await api.getDashboards({query: {orgID}}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - return dashboards.map(d => ({ + return resp.data.dashboards.map(d => ({ ...d, - cells: addDashboardIDToCells(d.cells, d.id), + cells: addDashboardIDToCells(d.cells as Cell[], d.id), })) } export const getDashboard = async (id: string): Promise => { - const dashboard = await client.dashboards.get(id) + const resp = await api.getDashboard({dashboardID: id}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + const dashboard = resp.data return { ...dashboard, - cells: addDashboardIDToCells(dashboard.cells, dashboard.id), + cells: addDashboardIDToCells(dashboard.cells as Cell[], dashboard.id), } } export const createDashboard = async ( props: CreateDashboardRequest ): Promise => { - const dashboard = await client.dashboards.create(props) + const resp = await api.postDashboard({data: props}) + + if (resp.status !== 201) { + throw new Error(resp.data.message) + } + + const dashboard = resp.data return { ...dashboard, - cells: addDashboardIDToCells(dashboard.cells, dashboard.id), + cells: addDashboardIDToCells(dashboard.cells as Cell[], dashboard.id), } } export const deleteDashboard = async (dashboard: Dashboard): Promise => { - await client.dashboards.delete(dashboard.id) + const resp = await api.deleteDashboard({dashboardID: dashboard.id}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } } export const updateDashboard = async ( dashboard: Dashboard ): Promise => { - const updated = await client.dashboards.update(dashboard.id, dashboard) + const resp = await api.patchDashboard({ + dashboardID: dashboard.id, + data: dashboard, + }) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + const updated = resp.data return { ...updated, - cells: addDashboardIDToCells(updated.cells, updated.id), + cells: addDashboardIDToCells(updated.cells as Cell[], updated.id), } } @@ -65,7 +93,13 @@ export const addCell = async ( dashboardID: string, cell: NewCell ): Promise => { - const result = await client.dashboards.createCell(dashboardID, cell) + const resp = await api.postDashboardsCell({dashboardID, data: cell}) + + if (resp.status !== 201) { + throw new Error(resp.data.message) + } + + const result = resp.data const cellWithID = {...result, dashboardID} @@ -76,25 +110,39 @@ export const updateCells = async ( id: string, cells: Cell[] ): Promise => { - const result = await client.dashboards.updateAllCells(id, cells) + const resp = await api.putDashboardsCells({dashboardID: id, data: cells}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } + + const result = resp.data.cells - return addDashboardIDToCells(result, id) + return addDashboardIDToCells(result as Cell[], id) } export const deleteCell = async ( dashboardID: string, cell: Cell ): Promise => { - await client.dashboards.deleteCell(dashboardID, cell.id) + const resp = await api.deleteDashboardsCell({dashboardID, cellID: cell.id}) + + if (resp.status !== 204) { + throw new Error(resp.data.message) + } } export const getView = async ( dashboardID: string, cellID: string ): Promise => { - const data = await client.dashboards.getView(dashboardID, cellID) + const resp = await api.getDashboardsCellsView({dashboardID, cellID}) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - const view: View = {...data, dashboardID, cellID} + const view: View = {...resp.data, dashboardID, cellID} return view } @@ -104,9 +152,17 @@ export const updateView = async ( cellID: string, view: Partial ): Promise => { - const data = await client.dashboards.updateView(dashboardID, cellID, view) + const resp = await api.patchDashboardsCellsView({ + dashboardID, + cellID, + data: view as View, + }) + + if (resp.status !== 200) { + throw new Error(resp.data.message) + } - const viewWithIDs: View = {...data, dashboardID, cellID} + const viewWithIDs: View = {...resp.data, dashboardID, cellID} return viewWithIDs } diff --git a/ui/src/dashboards/components/NewVEO.tsx b/ui/src/dashboards/components/NewVEO.tsx index 7fc18269c54..4f2c4386de2 100644 --- a/ui/src/dashboards/components/NewVEO.tsx +++ b/ui/src/dashboards/components/NewVEO.tsx @@ -20,7 +20,7 @@ import {createView} from 'src/shared/utils/view' import {TimeMachineEnum} from 'src/timeMachine/constants' // Types -import {AppState, ViewType, XYView, RemoteDataState, View} from 'src/types' +import {AppState, XYViewProperties, RemoteDataState, View} from 'src/types' interface DispatchProps { onSetActiveTimeMachine: typeof setActiveTimeMachine @@ -45,7 +45,7 @@ const NewViewVEO: FunctionComponent = ({ view, }) => { useEffect(() => { - const view = createView(ViewType.XY) + const view = createView('xy') onSetActiveTimeMachine(TimeMachineEnum.VEO, {view}) }, []) diff --git a/ui/src/dashboards/components/dashboard_index/DashboardCard.tsx b/ui/src/dashboards/components/dashboard_index/DashboardCard.tsx index 60dea2c7e74..6f60e688a14 100644 --- a/ui/src/dashboards/components/dashboard_index/DashboardCard.tsx +++ b/ui/src/dashboards/components/dashboard_index/DashboardCard.tsx @@ -19,8 +19,7 @@ import {createLabel as createLabelAsync} from 'src/labels/actions' import {viewableLabels} from 'src/labels/selectors' // Types -import {ILabel} from '@influxdata/influx' -import {AppState, Dashboard} from 'src/types' +import {AppState, Dashboard, Label} from 'src/types' // Constants import {DEFAULT_DASHBOARD_NAME} from 'src/dashboards/constants' @@ -35,7 +34,7 @@ interface PassedProps { } interface StateProps { - labels: ILabel[] + labels: Label[] } interface DispatchProps { @@ -76,7 +75,7 @@ class DashboardCard extends PureComponent { } labels={ { onUpdateDashboard(dashboard) } - private handleAddLabel = (label: ILabel): void => { + private handleAddLabel = (label: Label): void => { const {dashboard, onAddDashboardLabels} = this.props - onAddDashboardLabels(dashboard.id, [label]) + onAddDashboardLabels(dashboard.id, [label as any]) } - private handleRemoveLabel = (label: ILabel): void => { + private handleRemoveLabel = (label: Label): void => { const {dashboard, onRemoveDashboardLabels} = this.props - onRemoveDashboardLabels(dashboard.id, [label]) + onRemoveDashboardLabels(dashboard.id, [label as any]) } - private handleCreateLabel = async (label: ILabel): Promise => { + private handleCreateLabel = async (label: Label): Promise => { try { await this.props.onCreateLabel(label.name, label.properties) diff --git a/ui/src/dashboards/constants/cellEditor.ts b/ui/src/dashboards/constants/cellEditor.ts index a29f699612a..0003aa284fe 100644 --- a/ui/src/dashboards/constants/cellEditor.ts +++ b/ui/src/dashboards/constants/cellEditor.ts @@ -1,8 +1,8 @@ -import {Scale} from 'src/types' +import {AxisScale, Base} from 'src/types' export const AXES_SCALE_OPTIONS = { - LINEAR: Scale.Linear, - LOG: Scale.Log, - BASE_2: '2', - BASE_10: '10', + LINEAR: 'linear' as AxisScale, + LOG: 'log' as AxisScale, + BASE_2: '2' as Base, + BASE_10: '10' as Base, } diff --git a/ui/src/dashboards/resources.ts b/ui/src/dashboards/resources.ts index 1e70e23fbe5..d0655e9a244 100644 --- a/ui/src/dashboards/resources.ts +++ b/ui/src/dashboards/resources.ts @@ -3,7 +3,6 @@ import { Cell, Color, Dashboard, - TableOptions, FieldOption, DecimalPlaces, Service, @@ -12,7 +11,7 @@ import { SourceLinks, TimeRange, QueryConfig, - Scale, + TableOptions, } from 'src/types' export const dashboard: Dashboard = { @@ -133,7 +132,7 @@ export const axes: Axes = { prefix: '', suffix: '', base: '10', - scale: Scale.Linear, + scale: 'linear', }, y: { bounds: ['', ''], @@ -141,7 +140,7 @@ export const axes: Axes = { prefix: '', suffix: '', base: '10', - scale: Scale.Linear, + scale: 'linear', }, } diff --git a/ui/src/dataLoaders/components/BucketsDropdown.tsx b/ui/src/dataLoaders/components/BucketsDropdown.tsx index 2468f5491d3..4fea5d4294b 100644 --- a/ui/src/dataLoaders/components/BucketsDropdown.tsx +++ b/ui/src/dataLoaders/components/BucketsDropdown.tsx @@ -5,7 +5,7 @@ import React, {PureComponent} from 'react' import {Dropdown, ComponentStatus} from '@influxdata/clockface' // Types -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' interface Props { selectedBucketID: string diff --git a/ui/src/dataLoaders/components/collectorsWizard/CollectorsStepSwitcher.tsx b/ui/src/dataLoaders/components/collectorsWizard/CollectorsStepSwitcher.tsx index ab299f160a1..7f9625b7941 100644 --- a/ui/src/dataLoaders/components/collectorsWizard/CollectorsStepSwitcher.tsx +++ b/ui/src/dataLoaders/components/collectorsWizard/CollectorsStepSwitcher.tsx @@ -11,7 +11,7 @@ import {ErrorHandling} from 'src/shared/decorators/errors' // Types import {CollectorsStep} from 'src/types/dataLoaders' import {CollectorsStepProps} from 'src/dataLoaders/components/collectorsWizard/CollectorsWizard' -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' interface Props { stepProps: CollectorsStepProps diff --git a/ui/src/dataLoaders/components/collectorsWizard/CollectorsWizard.tsx b/ui/src/dataLoaders/components/collectorsWizard/CollectorsWizard.tsx index 727e748703f..a2c7b49e97c 100644 --- a/ui/src/dataLoaders/components/collectorsWizard/CollectorsWizard.tsx +++ b/ui/src/dataLoaders/components/collectorsWizard/CollectorsWizard.tsx @@ -28,8 +28,7 @@ import { // Types import {Links} from 'src/types/links' import {Substep, TelegrafPlugin} from 'src/types/dataLoaders' -import {AppState} from 'src/types' -import {Bucket} from '@influxdata/influx' +import {AppState, Bucket} from 'src/types' export interface CollectorsStepProps { currentStepIndex: number diff --git a/ui/src/dataLoaders/components/collectorsWizard/select/SelectCollectorsStep.tsx b/ui/src/dataLoaders/components/collectorsWizard/select/SelectCollectorsStep.tsx index 04113e3e8ac..32de8e4b703 100644 --- a/ui/src/dataLoaders/components/collectorsWizard/select/SelectCollectorsStep.tsx +++ b/ui/src/dataLoaders/components/collectorsWizard/select/SelectCollectorsStep.tsx @@ -18,7 +18,7 @@ import { import {setBucketInfo} from 'src/dataLoaders/actions/steps' // Types -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' import {ComponentStatus} from '@influxdata/clockface' import {CollectorsStepProps} from 'src/dataLoaders/components/collectorsWizard/CollectorsWizard' import {TelegrafPlugin, BundleName} from 'src/types/dataLoaders' diff --git a/ui/src/dataLoaders/components/collectorsWizard/select/StreamingSelector.tsx b/ui/src/dataLoaders/components/collectorsWizard/select/StreamingSelector.tsx index bc701890648..20565256fa2 100644 --- a/ui/src/dataLoaders/components/collectorsWizard/select/StreamingSelector.tsx +++ b/ui/src/dataLoaders/components/collectorsWizard/select/StreamingSelector.tsx @@ -18,7 +18,7 @@ import BucketDropdown from 'src/dataLoaders/components/BucketsDropdown' // Types import {TelegrafPlugin, BundleName} from 'src/types/dataLoaders' -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' import {IconFont, Columns, ComponentSize} from '@influxdata/clockface' export interface Props { diff --git a/ui/src/dataLoaders/components/lineProtocolWizard/LineProtocolWizard.tsx b/ui/src/dataLoaders/components/lineProtocolWizard/LineProtocolWizard.tsx index ad15f597588..f3576dbda2e 100644 --- a/ui/src/dataLoaders/components/lineProtocolWizard/LineProtocolWizard.tsx +++ b/ui/src/dataLoaders/components/lineProtocolWizard/LineProtocolWizard.tsx @@ -23,7 +23,7 @@ import {clearDataLoaders} from 'src/dataLoaders/actions/dataLoaders' // Types import {AppState} from 'src/types' -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' export interface LineProtocolStepProps { currentStepIndex: number diff --git a/ui/src/dataLoaders/components/lineProtocolWizard/verify/LineProtocolStepSwitcher.tsx b/ui/src/dataLoaders/components/lineProtocolWizard/verify/LineProtocolStepSwitcher.tsx index 43cd6746503..28797282fb1 100644 --- a/ui/src/dataLoaders/components/lineProtocolWizard/verify/LineProtocolStepSwitcher.tsx +++ b/ui/src/dataLoaders/components/lineProtocolWizard/verify/LineProtocolStepSwitcher.tsx @@ -10,7 +10,7 @@ import LineProtocolVerifyStep from 'src/dataLoaders/components/lineProtocolWizar // Types import {LineProtocolStep} from 'src/types' import {LineProtocolStepProps} from 'src/dataLoaders/components/lineProtocolWizard/LineProtocolWizard' -import {Bucket} from '@influxdata/influx' +import {Bucket} from 'src/types' interface Props { stepProps: LineProtocolStepProps diff --git a/ui/src/labels/actions/index.ts b/ui/src/labels/actions/index.ts index 7fd56ef160b..e775038a61b 100644 --- a/ui/src/labels/actions/index.ts +++ b/ui/src/labels/actions/index.ts @@ -3,7 +3,7 @@ import {client} from 'src/utils/api' // Types import {RemoteDataState} from 'src/types' -import {ILabel} from '@influxdata/influx' +import {ILabel, ILabelProperties} from '@influxdata/influx' import {LabelProperties} from 'src/types/labels' import {Dispatch} from 'redux-thunk' @@ -99,7 +99,7 @@ export const createLabel = ( const createdLabel = await client.labels.create({ orgID: org.id, name, - properties, + properties: properties as ILabelProperties, }) dispatch(addLabel(createdLabel)) diff --git a/ui/src/labels/components/LabelCard.tsx b/ui/src/labels/components/LabelCard.tsx index 7b9152f998c..1702f73a174 100644 --- a/ui/src/labels/components/LabelCard.tsx +++ b/ui/src/labels/components/LabelCard.tsx @@ -2,17 +2,21 @@ import React, {PureComponent} from 'react' // Components -import {ComponentSize, Label, ResourceCard} from '@influxdata/clockface' +import { + ComponentSize, + Label as LabelComponent, + ResourceCard, +} from '@influxdata/clockface' // Types -import {ILabel} from '@influxdata/influx' +import {Label} from 'src/types' // Decorators import {ErrorHandling} from 'src/shared/decorators/errors' import LabelContextMenu from './LabelContextMenu' interface Props { - label: ILabel + label: Label onClick: (labelID: string) => void onDelete: (labelID: string) => void } @@ -28,7 +32,7 @@ export default class LabelCard extends PureComponent { testID="label-card" contextMenu={} name={ -