Skip to content
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

[#4144] Adapt Frontend with Schema Manager #4145

Merged
merged 3 commits into from
Feb 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions frontend/control-center/src/actions/streams/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ export const getTopicInfo = (topicName: string) => async (dispatch: Dispatch<any
// ------------------------- SCHEMAS -------------------------

export const getSchemas = () => async (dispatch: Dispatch<any>) => {
return getData('subjects').then(response => {
return getData('schemas.list').then(response => {
console.log(response);
dispatch(setTopicSchemasAction(response));
return Promise.resolve(true);
});
};

export const getSchemaVersions = (topicName: string) => async (dispatch: Dispatch<any>) => {
return getData(`subjects/${topicName}/versions`).then(response => {
return getData(`schemas.versions?topicName=${topicName}`).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
} else {
Expand All @@ -91,7 +92,7 @@ export const getSchemaInfo = (topicName: string, version?: string) => async (dis
if (version) {
v = version;
}
return getData(`subjects/${topicName}/versions/${v}`).then(response => {
return getData(`schemas.info?topicName=${topicName}&version=${v}`).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
} else {
Expand All @@ -105,7 +106,7 @@ export const setSchemaSchema = (topicName: string, schema: string) => async () =
const body = {
schema: JSON.stringify({...JSON.parse(schema)}),
};
return postData(`subjects/${topicName}/versions`, body).then(response => {
return postData(`schemas.update?topicName=${topicName}`, body).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
}
Expand All @@ -119,7 +120,7 @@ export const createSchema = (topicName: string, schema: string) => async () => {
const body = {
schema: JSON.stringify({...JSON.parse(schema)}),
};
return postData(`subjects/${topicName}/versions`, body)
return postData(`schemas.create?topicName=${topicName}`, body)
.then(response => {
if (response.id) return Promise.resolve(true);
if (response.message) return Promise.reject(response.message);
Expand All @@ -134,7 +135,7 @@ export const checkCompatibilityOfNewSchema = (topicName: string, schema: string,
const body = {
schema: JSON.stringify({...JSON.parse(schema)}),
};
return postData(`compatibility/subjects/${topicName}/versions/${version}`, body)
return postData(`schemas.compatibility?topicName=${topicName}&version=${version}`, body)
.then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
Expand All @@ -154,7 +155,7 @@ export const checkCompatibilityOfNewSchema = (topicName: string, schema: string,
};

export const deleteSchema = (topicName: string) => async () => {
return deleteData(`subjects/${topicName}`).then(response => {
return deleteData(`schemas.delete?topicName=${topicName}`).then(response => {
if (response.error_code && response.error_code.toString().includes('404') && !topicName.includes('-value')) {
return Promise.reject('404 Not Found');
}
Expand All @@ -163,11 +164,7 @@ export const deleteSchema = (topicName: string) => async () => {
};

export const getLastMessage = (topicName: string) => async (dispatch: Dispatch<any>) => {
const body = {
ksql: `PRINT '${topicName}' FROM BEGINNING LIMIT 1;`,
streamsProperties: {},
};
return postData('query', body).then(response => {
return getData(`schemas.lastMessage?topicName=${topicName}`).then(response => {
dispatch(setLastMessage(response));
return Promise.resolve(true);
});
Expand All @@ -193,11 +190,10 @@ async function postData(url: string, body: any) {
const response = await fetch(apiHostUrl + '/' + url, {
method: 'POST',
headers: {
'Content-Type': 'application/vnd.schemaregistry.v1+json',
'Content-Type': 'application/json',
},
body: JSON.stringify(body),
});

return response.json();
}

Expand Down
Loading