-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RHOAIENG-10311] Backend service endpoints for connection types #3048
[RHOAIENG-10311] Backend service endpoints for connection types #3048
Conversation
export const fetchConnectionType = (name: string): Promise<ConfigMapKind> => { | ||
const url = `/api/connection-types/${name}`; | ||
return axios | ||
.get(url) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; | ||
|
||
export const createConnectionType = (connectionType: ConfigMapKind): Promise<ResponseStatus> => { | ||
const url = `/api/connection-types`; | ||
return axios | ||
.post(url, connectionType) | ||
.then((response) => response.data) | ||
.catch((e) => { | ||
throw new Error(e.response.data.message); | ||
}); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do the conversion between types? Do you think it makes sense that in app we always work with the parsed object. I don't know of a time when we would need to use the raw config map.
export const fetchConnectionType = (name: string): Promise<ConfigMapKind> => { | |
const url = `/api/connection-types/${name}`; | |
return axios | |
.get(url) | |
.then((response) => response.data) | |
.catch((e) => { | |
throw new Error(e.response.data.message); | |
}); | |
}; | |
export const createConnectionType = (connectionType: ConfigMapKind): Promise<ResponseStatus> => { | |
const url = `/api/connection-types`; | |
return axios | |
.post(url, connectionType) | |
.then((response) => response.data) | |
.catch((e) => { | |
throw new Error(e.response.data.message); | |
}); | |
}; | |
export const fetchConnectionType = (name: string): Promise<ConnectionTypeConfigMapObj> => { | |
const url = `/api/connection-types/${name}`; | |
return axios | |
.get(url) | |
.then((response) => toConnectionTypeConfigMapObj(response.data)) | |
.catch((e) => { | |
throw new Error(e.response.data.message); | |
}); | |
}; | |
export const createConnectionType = (connectionType: ConnectionTypeConfigMap): Promise<ResponseStatus> => { | |
const url = `/api/connection-types`; | |
return axios | |
.post(url, toConnectionTypeConfigMap(connectionType)) | |
.then((response) => response.data) | |
.catch((e) => { | |
throw new Error(e.response.data.message); | |
}); | |
}; |
await coreV1Api.deleteNamespacedConfigMap(name, dashboardNamespace); | ||
return { success: true, error: '' }; | ||
} catch (e) { | ||
const error = `Unable to delete connection type: ${e.message}.`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use errorHandler
as we will eventually have stricter ts / eslint rules.
const error = `Unable to delete connection type: ${e.message}.`; | |
const error = `Unable to delete connection type: ${errorHandler(e)}.`; |
|
||
const isConnectionTypeConfigMap = (configMap: V1ConfigMap): boolean => { | ||
const labels = configMap.metadata.labels; | ||
return labels[ODH_DASHBOARD_KEY] === 'true' || labels[CONNECTION_TYPE_KEY] === 'true'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't labels be undefined? Also we need both labels to be present.
return labels[ODH_DASHBOARD_KEY] === 'true' || labels[CONNECTION_TYPE_KEY] === 'true'; | |
return labels?.[ODH_DASHBOARD_KEY] === 'true' && labels?.[CONNECTION_TYPE_KEY] === 'true'; |
f0e4116
to
df97e33
Compare
export const patchConnectionType = ( | ||
connectionType: ConnectionTypeConfigMapObj, | ||
): Promise<ResponseStatus> => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's omit this generic patch function and add a specific one that constructs a patch just for setting the enabled
annotation:
{
op: 'replace',
path: '/metadata/annotations/opendatahub.io~1enabled',
value: ...,
}
df97e33
to
f6d2eef
Compare
f6d2eef
to
9fafc98
Compare
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: christianvogt The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
RHOAIENG-10311
Description
Adds backend endpoints for ConnectionType objects.
Includes GET, POST, PUSH, PATH, DELETE.
Adds a frontend service to access these endpoints.
How Has This Been Tested?
This has been tested locally by adding temporary calls in the UI
Test Impact
Tests will need to be added when the UI accesses these new functions.
Request review criteria:
Self checklist (all need to be checked):