Merge pull request #2001 from influxdata/chore/misc-generated

Chore/misc generated
pull/10616/head
Brandon Farmer 2018-12-17 16:36:07 -08:00 committed by GitHub
commit eb81a9c48d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 343 additions and 290 deletions

View File

@ -1786,175 +1786,176 @@ paths:
schema:
$ref: "#/components/schemas/Error"
/query:
get:
tags:
- Query
summary: query influx with specified return formatting. The spec and query fields are mutually exclusive.
parameters:
- in: query
name: org
description: specifies the organization of the resource
required: true
schema:
type: string
- in: query
name: query
description: query script to execute.
required: true
schema:
type: string
- in: header
name: Authorization
description: the authorization header should be in the format of `Token <key>`
schema:
type: string
responses:
'200':
description: query results
get:
tags:
- Query
summary: query influx with specified return formatting. The spec and query fields are mutually exclusive.
parameters:
- in: query
name: org
description: specifies the organization of the resource
required: true
schema:
type: string
- in: query
name: query
description: query script to execute.
required: true
schema:
type: string
- in: header
name: Authorization
description: the authorization header should be in the format of `Token <key>`
schema:
type: string
responses:
'200':
description: query results
content:
text/csv:
schema:
type: string
example: >
result,table,_start,_stop,_time,region,host,_value
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
'400':
description: error processing query
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
default:
description: internal server error
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
post:
tags:
- Query
summary: query an influx
parameters:
- in: header
name: Accept
description: specifies the return content format. Each response content type will have its own dialect options.
schema:
type: string
description: return format of either CSV or Arrow buffers
default: text/csv
enum:
- text/csv
- application/vnd.influx.arrow
- in: header
name: Content-Type
schema:
type: string
enum:
- application/json
- in: header
name: Authorization
description: the authorization header should be in the format of `Token <key>`
schema:
type: string
- in: query
name: org
description: specifies the name of the organization executing the query.
schema:
type: string
requestBody:
description: flux query or specification to execute
content:
text/csv:
schema:
type: string
example: >
result,table,_start,_stop,_time,region,host,_value
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
'400':
description: error processing query
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
default:
description: internal server error
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
post:
tags:
- Query
summary: query an influx
parameters:
- in: header
name: Accept
description: specifies the return content format. Each response content type will have its own dialect options.
schema:
type: string
description: return format of either CSV or Arrow buffers
default: text/csv
enum:
- text/csv
- application/vnd.influx.arrow
- in: header
name: Content-Type
schema:
type: string
enum:
- application/json
- in: header
name: Authorization
description: the authorization header should be in the format of `Token <key>`
schema:
type: string
- in: query
name: org
description: specifies the name of the organization executing the query.
schema:
type: string
requestBody:
description: flux query or specification to execute
content:
application/json:
schema:
$ref: "#/components/schemas/Query"
responses:
'200':
description: query results
content:
text/csv:
schema:
type: string
example: >
result,table,_start,_stop,_time,region,host,_value
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
application/vnd.influx.arrow:
schema:
type: string
format: binary
'400':
description: error processing query
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
application/vnd.influx.arrow:
application/json:
schema:
$ref: "#/components/schemas/Query"
responses:
'200':
description: query results
content:
text/csv:
schema:
type: string
example: >
result,table,_start,_stop,_time,region,host,_value
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:00Z,east,A,15.43
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:20Z,east,B,59.25
mean,0,2018-05-08T20:50:00Z,2018-05-08T20:51:00Z,2018-05-08T20:50:40Z,east,C,52.62
application/vnd.influx.arrow:
schema:
type: string
format: binary
default:
description: internal server error
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
application/vnd.influx.arrow:
schema:
'400':
description: error processing query
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
format: binary
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
application/vnd.influx.arrow:
schema:
type: string
format: binary
default:
description: internal server error
headers:
X-Influx-Error:
description: error string describing the problem
schema:
type: string
X-Influx-Reference:
description: reference code unique to the error type
schema:
type: integer
content:
text/csv:
schema:
type: string
example: >
error,reference
Failed to parse query,897
application/vnd.influx.arrow:
schema:
type: string
format: binary
/buckets:
get:
x-generated: true
tags:
- Buckets
summary: List all buckets
@ -1979,6 +1980,7 @@ paths:
schema:
$ref: "#/components/schemas/Error"
post:
x-generated: true
tags:
- Buckets
summary: Create a bucket
@ -2011,6 +2013,7 @@ paths:
$ref: "#/components/schemas/Error"
'/buckets/{bucketID}':
get:
x-generated: true
tags:
- Buckets
summary: Retrieve a bucket
@ -2035,6 +2038,7 @@ paths:
schema:
$ref: "#/components/schemas/Error"
patch:
x-generated: true
tags:
- Buckets
summary: Update a bucket
@ -2239,6 +2243,7 @@ paths:
$ref: "#/components/schemas/Error"
/orgs:
get:
x-generated: true
tags:
- Organizations
summary: List all organizations
@ -2256,6 +2261,7 @@ paths:
schema:
$ref: "#/components/schemas/Error"
post:
x-generated: true
tags:
- Organizations
summary: Create an organization
@ -2281,6 +2287,7 @@ paths:
$ref: "#/components/schemas/Error"
'/orgs/{orgID}':
get:
x-generated: true
tags:
- Organizations
summary: Retrieve an organization
@ -2305,6 +2312,7 @@ paths:
schema:
$ref: "#/components/schemas/Error"
patch:
x-generated: true
tags:
- Organizations
summary: Update an organization
@ -2335,6 +2343,27 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/Error"
delete:
x-generated: true
tags:
- Organizations
summary: delete an organization
parameters:
- in: path
name: orgID
schema:
type: string
required: true
description: ID of organization to get
responses:
'200':
description: organization deleted
default:
description: unexpected error
content:
application/json:
schema:
$ref: "#/components/schemas/Error"
'/orgs/{orgID}/members':
get:
tags:

View File

@ -17,7 +17,6 @@ import {isOnboardingURL} from 'src/onboarding/utils'
// Types
import {Notification, NotificationFunc, RemoteDataState} from 'src/types'
import {Links} from 'src/types/v2/links'
interface State {
loading: RemoteDataState
@ -25,7 +24,6 @@ interface State {
}
interface Props {
links: Links
router: InjectedRouter
children: ReactElement<any>
notify: (message: Notification | NotificationFunc) => void
@ -43,7 +41,7 @@ export class Setup extends PureComponent<Props, State> {
}
public async componentDidMount() {
const {links, router} = this.props
const {router} = this.props
if (isOnboardingURL()) {
this.setState({
@ -52,7 +50,7 @@ export class Setup extends PureComponent<Props, State> {
return
}
const isSetupAllowed = await getSetupStatus(links.setup)
const isSetupAllowed = await getSetupStatus()
this.setState({
loading: RemoteDataState.Done,
})
@ -81,13 +79,11 @@ export class Setup extends PureComponent<Props, State> {
}
}
const mstp = ({links}) => ({links})
const mdtp = {
notify: notifyAction,
}
export default connect(
mstp,
null,
mdtp
)(Setup)

View File

@ -1,6 +1,5 @@
// Libraries
import React, {ReactElement, PureComponent} from 'react'
import {connect} from 'react-redux'
// APIs
import {trySources} from 'src/onboarding/apis'
@ -12,7 +11,6 @@ import Notifications from 'src/shared/components/notifications/Notifications'
// Types
import {RemoteDataState} from 'src/types'
import {Links} from 'src/types/v2/links'
interface State {
loading: RemoteDataState
@ -20,7 +18,6 @@ interface State {
}
interface Props {
links: Links
children: ReactElement<any>
}
@ -36,8 +33,7 @@ export class Signin extends PureComponent<Props, State> {
}
public async componentDidMount() {
const {links} = this.props
const isSourcesAllowed = await trySources(links.sources)
const isSourcesAllowed = await trySources()
const isUserSignedIn = isSourcesAllowed
this.setState({loading: RemoteDataState.Done, isUserSignedIn})
}
@ -73,8 +69,4 @@ export class Signin extends PureComponent<Props, State> {
}
}
const mstp = ({links}) => ({
links,
})
export default connect(mstp)(Signin)
export default Signin

View File

@ -8457,6 +8457,39 @@ export const OrganizationsApiAxiosParamCreator = function (configuration?: Confi
options: localVarRequestOptions,
};
},
/**
*
* @summary delete an organization
* @param {string} orgID ID of organization to get
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
orgsOrgIDDelete(orgID: string, options: any = {}): RequestArgs {
// verify required parameter 'orgID' is not null or undefined
if (orgID === null || orgID === undefined) {
throw new RequiredError('orgID','Required parameter orgID was null or undefined when calling orgsOrgIDDelete.');
}
const localVarPath = `/orgs/{orgID}`
.replace(`{${"orgID"}}`, encodeURIComponent(String(orgID)));
const localVarUrlObj = url.parse(localVarPath, true);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = Object.assign({ method: 'DELETE' }, baseOptions, options);
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
localVarUrlObj.query = Object.assign({}, localVarUrlObj.query, localVarQueryParameter, options.query);
// fix override query string Detail: https://stackoverflow.com/a/7517673/1077943
delete localVarUrlObj.search;
localVarRequestOptions.headers = Object.assign({}, localVarHeaderParameter, options.headers);
return {
url: url.format(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Retrieve an organization
@ -8818,6 +8851,20 @@ export const OrganizationsApiFp = function(configuration?: Configuration) {
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary delete an organization
* @param {string} orgID ID of organization to get
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
orgsOrgIDDelete(orgID: string, options?: any): (axios?: AxiosInstance, basePath?: string) => AxiosPromise<Response> {
const localVarAxiosArgs = OrganizationsApiAxiosParamCreator(configuration).orgsOrgIDDelete(orgID, options);
return (axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = Object.assign(localVarAxiosArgs.options, {url: basePath + localVarAxiosArgs.url})
return axios.request(axiosRequestArgs);
};
},
/**
*
* @summary Retrieve an organization
@ -8967,6 +9014,16 @@ export const OrganizationsApiFactory = function (configuration?: Configuration,
orgsGet(options?: any) {
return OrganizationsApiFp(configuration).orgsGet(options)(axios, basePath);
},
/**
*
* @summary delete an organization
* @param {string} orgID ID of organization to get
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
orgsOrgIDDelete(orgID: string, options?: any) {
return OrganizationsApiFp(configuration).orgsOrgIDDelete(orgID, options)(axios, basePath);
},
/**
*
* @summary Retrieve an organization
@ -9083,6 +9140,18 @@ export class OrganizationsApi extends BaseAPI {
return OrganizationsApiFp(this.configuration).orgsGet(options)(this.axios, this.basePath);
}
/**
*
* @summary delete an organization
* @param {string} orgID ID of organization to get
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof OrganizationsApi
*/
public orgsOrgIDDelete(orgID: string, options?: any) {
return OrganizationsApiFp(this.configuration).orgsOrgIDDelete(orgID, options)(this.axios, this.basePath);
}
/**
*
* @summary Retrieve an organization

View File

@ -1,11 +1,11 @@
// Utils
import AJAX from 'src/utils/ajax'
import {parseResponse} from 'src/shared/parsing/flux/response'
// Types
import {InfluxLanguage} from 'src/types/v2/dashboards'
import {FluxTable} from 'src/types'
import {SearchStatus} from 'src/types/logs'
import {queryAPI} from 'src/utils/api'
import {Query, Dialect} from 'src/api'
export interface QueryResponse {
tables: FluxTable[]
@ -13,26 +13,27 @@ export interface QueryResponse {
}
export const executeQueryAsync = async (
link: string,
query: string,
type: InfluxLanguage = InfluxLanguage.Flux
type: Query.TypeEnum = Query.TypeEnum.Influxql
): Promise<QueryResponse> => {
try {
const dialect = {
header: true,
annotations: ['datatype', 'group', 'default'],
annotations: [
Dialect.AnnotationsEnum.Datatype,
Dialect.AnnotationsEnum.Group,
Dialect.AnnotationsEnum.Default,
],
delimiter: ',',
}
const {data} = await AJAX({
method: 'POST',
url: link,
data: {
type,
query,
dialect,
},
})
const {data} = await queryAPI.queryPost(
'text/csv',
'application/json',
null,
null,
{type, query, dialect}
)
const tables = parseResponse(data)
const status = responseStatus(tables)

View File

@ -9,8 +9,7 @@ import {oneline} from 'src/logs/utils/helpers/formatting'
import {QueryConfig} from 'src/types'
import {Filter, LogQuery} from 'src/types/logs'
import {InfluxLanguage} from 'src/types/v2'
import {Source} from 'src/api'
import {Source, Query} from 'src/api'
describe('Logs.LogQuery', () => {
let config: QueryConfig
@ -57,7 +56,7 @@ describe('Logs.LogQuery', () => {
})
it('can build a flux query', () => {
const actual = buildLogQuery(InfluxLanguage.Flux, {
const actual = buildLogQuery(Query.TypeEnum.Flux, {
lower,
upper,
config,
@ -86,7 +85,7 @@ describe('Logs.LogQuery', () => {
it('can build an influxql query', () => {
filters = [{key: 'severity', operator: '==', value: 'notice', id: '1'}]
const actual = buildLogQuery(InfluxLanguage.InfluxQL, {
const actual = buildLogQuery(Query.TypeEnum.Influxql, {
lower,
upper,
config,

View File

@ -11,8 +11,7 @@ import {buildFluxQuery} from 'src/logs/utils/v2/queryBuilder'
import {buildInfluxQLQuery} from 'src/logs/utils/v1/queryBuilder'
// Types
import {Bucket} from 'src/api'
import {InfluxLanguage} from 'src/types/v2/dashboards'
import {Bucket, Query} from 'src/api'
import {QueryConfig} from 'src/types'
import {
LogSearchParams,
@ -91,13 +90,13 @@ export const buildTableQueryConfig = (bucket: Bucket): QueryConfig => {
}
export const buildLogQuery = (
type: InfluxLanguage,
type: Query.TypeEnum,
searchParams: LogSearchParams
): string => {
switch (type) {
case InfluxLanguage.InfluxQL:
case Query.TypeEnum.Influxql:
return `${buildInfluxQLQuery(searchParams)} ORDER BY time DESC`
case InfluxLanguage.Flux:
case Query.TypeEnum.Flux:
return buildFluxQuery(searchParams)
}
}
@ -107,14 +106,11 @@ export const getTableData = async (
logQuery: LogQuery
): Promise<TableData> => {
const {source, ...searchParams} = logQuery
const {
links: {query: queryLink},
} = source
// TODO: get type from source
const type = InfluxLanguage.Flux
const type = Query.TypeEnum.Flux
const query = buildLogQuery(type, searchParams)
const response = await executeQuery(queryLink, query, type)
const response = await executeQuery(query, type)
const {config} = searchParams
const columnNames: string[] = config.fields.map(f => f.alias)

View File

@ -1,21 +1,17 @@
// Libraries
import _ from 'lodash'
import {baseAPI} from 'src/utils/api'
import {baseAPI, setupAPI, sourcesAPI} from 'src/utils/api'
// Utils
import AJAX from 'src/utils/ajax'
import {telegrafsAPI, authorizationsAPI, writeAPI} from 'src/utils/api'
import {Telegraf, WritePrecision, TelegrafRequest} from 'src/api'
import {getDeep} from 'src/utils/wrappers'
export const getSetupStatus = async (url: string): Promise<boolean> => {
export const getSetupStatus = async (): Promise<boolean> => {
try {
const {data} = await AJAX({
method: 'GET',
url,
})
const {data} = await setupAPI.setupGet()
const {allowed} = data
return allowed
} catch (error) {
@ -49,15 +45,10 @@ export interface SetupParams {
}
export const setSetupParams = async (
url: string,
setupParams: SetupParams
): Promise<void> => {
try {
await AJAX({
method: 'POST',
url,
data: setupParams,
})
await setupAPI.setupPost(setupParams)
} catch (error) {
console.error("Can't set setup parameters", error)
throw error
@ -77,12 +68,9 @@ export const signin = async (params: {
}
}
export const trySources = async (url: string): Promise<boolean> => {
export const trySources = async (): Promise<boolean> => {
try {
await AJAX({
method: 'GET',
url,
})
await sourcesAPI.sourcesGet(null)
return true
} catch (error) {
console.error('Sign in has failed', error)

View File

@ -9,12 +9,19 @@ const telegrafsPost = jest.fn(() =>
Promise.resolve(createTelegrafConfigResponse)
)
const authorizationsGet = jest.fn(() => Promise.resolve(authResponse))
const setupPost = jest.fn(() => Promise.resolve())
const setupGet = jest.fn(() => Promise.resolve({data: {allowed: true}}))
export const telegrafsAPI = {
telegrafsGet,
telegrafsPost,
}
export const setupAPI = {
setupPost,
setupGet,
}
export const authorizationsAPI = {
authorizationsGet,
}

View File

@ -7,12 +7,13 @@ import {
getAuthorizationToken,
} from 'src/onboarding/apis'
import AJAX from 'src/utils/ajax'
import {telegrafConfig, token} from 'mocks/dummyData'
import {telegrafsAPI, authorizationsAPI} from 'src/onboarding/apis/mocks'
import {
telegrafsAPI,
authorizationsAPI,
setupAPI,
} from 'src/onboarding/apis/mocks'
jest.mock('src/utils/ajax', () => require('mocks/utils/ajax'))
jest.mock('src/utils/api', () => require('src/onboarding/apis/mocks'))
describe('Onboarding.Apis', () => {
@ -22,30 +23,21 @@ describe('Onboarding.Apis', () => {
describe('getSetupStatus', () => {
it('is called with the expected body', () => {
const url = '/api/v2/setup'
getSetupStatus(url)
expect(AJAX).toHaveBeenCalledWith({
method: 'GET',
url,
})
getSetupStatus()
expect(setupAPI.setupGet).toHaveBeenCalled()
})
})
describe('setSetupParams', () => {
it('is called with the expected body', () => {
const url = '/api/v2/setup'
const setupParams: SetupParams = {
username: 'moo',
password: 'pwoo',
bucket: 'boo',
org: 'ooo',
}
setSetupParams(url, setupParams)
expect(AJAX).toHaveBeenCalledWith({
method: 'POST',
url,
data: setupParams,
})
setSetupParams(setupParams)
expect(setupAPI.setupPost).toHaveBeenCalledWith(setupParams)
})
})

View File

@ -262,7 +262,6 @@ class AdminStep extends PureComponent<OnboardingStepProps, State> {
private handleNext = async () => {
const {
links,
onSetStepStatus,
currentStepIndex,
handleSetSetupParams,
@ -286,7 +285,7 @@ class AdminStep extends PureComponent<OnboardingStepProps, State> {
}
try {
await setSetupParams(links.setup, setupParams)
await setSetupParams(setupParams)
await signin({username, password})
notify(copy.SetupSuccess)
handleSetSetupParams(setupParams)

View File

@ -50,13 +50,13 @@ export const addOrg = (org: Organization): AddOrg => ({
export interface RemoveOrg {
type: ActionTypes.RemoveOrg
payload: {
link: string
org: Organization
}
}
export const removeOrg = (link: string): RemoveOrg => ({
export const removeOrg = (org: Organization): RemoveOrg => ({
type: ActionTypes.RemoveOrg,
payload: {link},
payload: {org},
})
export interface EditOrg {
@ -95,12 +95,12 @@ export const createOrg = (org: Organization) => async (
}
}
export const deleteOrg = (link: string) => async (
export const deleteOrg = (org: Organization) => async (
dispatch: Dispatch<RemoveOrg>
): Promise<void> => {
try {
await deleteOrgAPI(link)
dispatch(removeOrg(link))
await deleteOrgAPI(org)
dispatch(removeOrg(org))
} catch (e) {
console.error(e)
}

View File

@ -1,5 +1,4 @@
// Libraries
import AJAX from 'src/utils/ajax'
import _ from 'lodash'
import {orgsAPI, bucketsAPI, dashboardsAPI, taskAPI} from 'src/utils/api'
@ -27,12 +26,9 @@ export const createOrg = async (org: Organization): Promise<Organization> => {
}
}
export const deleteOrg = async (url: string): Promise<void> => {
export const deleteOrg = async (org: Organization): Promise<void> => {
try {
await AJAX({
url,
method: 'DELETE',
})
await orgsAPI.orgsOrgIDDelete(org.id)
} catch (error) {
console.error('Could not delete org', error)
throw error
@ -75,15 +71,11 @@ export const getBuckets = async (org: Organization): Promise<Bucket[]> => {
}
export const createBucket = async (
url: string,
bucket: Partial<Bucket>
org: Organization,
bucket: Bucket
): Promise<Bucket> => {
try {
const {data} = await AJAX({
method: 'POST',
url,
data: bucket,
})
const {data} = await bucketsAPI.bucketsPost(org.name, bucket)
return data
} catch (error) {
@ -94,11 +86,7 @@ export const createBucket = async (
export const updateBucket = async (bucket: Bucket): Promise<Bucket> => {
try {
const {data} = await AJAX({
url: bucket.links.self,
method: 'PATCH',
data: bucket,
})
const {data} = await bucketsAPI.bucketsBucketIDPatch(bucket.id, bucket)
return data
} catch (error) {

View File

@ -94,7 +94,6 @@ export default class Buckets extends PureComponent<Props, State> {
<OverlayTechnology visible={overlayState === OverlayState.Open}>
<CreateBucketOverlay
org={org}
link={org.links.buckets}
onCloseModal={this.handleCloseModal}
onCreateBucket={this.handleCreateBucket}
/>
@ -117,10 +116,10 @@ export default class Buckets extends PureComponent<Props, State> {
}
private handleCreateBucket = async (
link: string,
bucket: Partial<Bucket>
org: Organization,
bucket: Bucket
): Promise<void> => {
const b = await createBucket(link, bucket)
const b = await createBucket(org, bucket)
const buckets = this.prettyBuckets([b, ...this.props.buckets])
this.setState({buckets})
this.handleCloseModal()

View File

@ -14,10 +14,9 @@ import BucketOverlayForm from 'src/organizations/components/BucketOverlayForm'
import {Bucket, BucketRetentionRules, Organization} from 'src/api'
interface Props {
link: string
org: Organization
onCloseModal: () => void
onCreateBucket: (link: string, bucket: Partial<Bucket>) => Promise<void>
onCreateBucket: (org: Organization, bucket: Partial<Bucket>) => Promise<void>
}
interface State {
@ -106,7 +105,7 @@ export default class BucketOverlay extends PureComponent<Props, State> {
}
private handleCreateBucket = (): void => {
const {link, onCreateBucket, org} = this.props
const {onCreateBucket, org} = this.props
const organizationID = org.id
const organization = org.name
@ -116,7 +115,7 @@ export default class BucketOverlay extends PureComponent<Props, State> {
organization,
}
onCreateBucket(link, bucket)
onCreateBucket(org, bucket)
}
private handleChangeInput = (e: ChangeEvent<HTMLInputElement>) => {

View File

@ -5,11 +5,11 @@ import React, {Component} from 'react'
import {Button, ComponentColor, ComponentSize} from 'src/clockface'
// Types
import {Organization} from 'src/types/v2'
import {Organization} from 'src/api'
interface Props {
org: Organization
onDeleteOrg: (link: string) => void
onDeleteOrg: (org: Organization) => void
}
class DeleteOrgButton extends Component<Props> {
@ -26,7 +26,7 @@ class DeleteOrgButton extends Component<Props> {
private handleDeleteOrg = () => {
const {org, onDeleteOrg} = this.props
onDeleteOrg(org.links.self)
onDeleteOrg(org)
}
}

View File

@ -10,7 +10,7 @@ export default (state = defaultState, action: Actions): Organization[] => {
case ActionTypes.AddOrg:
return [...state, {...action.payload.org}]
case ActionTypes.RemoveOrg:
return state.filter(org => org.links.self !== action.payload.link)
return state.filter(org => org !== action.payload.org)
case ActionTypes.EditOrg:
const newState = state.map(o => {
const {org} = action.payload

View File

@ -1,14 +1,9 @@
import _ from 'lodash'
import AJAX from 'src/utils/ajax'
import {orgsAPI} from 'src/utils/api'
import {Organization} from 'src/types/v2'
import {Organization} from 'src/api'
export const getOrganizations = async (
url: string
): Promise<Organization[]> => {
const {data} = await AJAX({
url,
})
return _.get(data, 'orgs', [])
export const getOrganizations = async (): Promise<Organization[]> => {
const {data} = await orgsAPI.orgsGet()
return data.orgs
}

View File

@ -11,6 +11,8 @@ import {
DefaultApi,
BucketsApi,
OrganizationsApi,
QueryApi,
SetupApi,
} from 'src/api'
const basePath = '/api/v2'
@ -27,3 +29,5 @@ export const writeAPI = new WriteApi({basePath})
export const sourcesAPI = new SourcesApi({basePath})
export const bucketsAPI = new BucketsApi({basePath})
export const orgsAPI = new OrganizationsApi({basePath})
export const queryAPI = new QueryApi({basePath})
export const setupAPI = new SetupApi({basePath})