ShortURL: Add generate name prefix to create payload (#111854)
ShortURL: Add generate name suffix to create payload
This commit is contained in:
@@ -1,3 +1,27 @@
|
||||
import { generatedAPI } from './endpoints.gen';
|
||||
|
||||
export const shortURLAPIv1alpha1 = generatedAPI.enhanceEndpoints({});
|
||||
export const shortURLAPIv1alpha1 = generatedAPI.enhanceEndpoints({
|
||||
endpoints: {
|
||||
createShortUrl: (endpointDefinition) => {
|
||||
const originalQuery = endpointDefinition.query;
|
||||
if (!originalQuery) {
|
||||
return;
|
||||
}
|
||||
|
||||
endpointDefinition.query = (requestOptions) => {
|
||||
// Ensure metadata exists
|
||||
if (!requestOptions.shortUrl.metadata) {
|
||||
requestOptions.shortUrl.metadata = {};
|
||||
}
|
||||
|
||||
const metadata = requestOptions.shortUrl.metadata;
|
||||
if (!metadata.name && !metadata.generateName) {
|
||||
// GenerateName lets the apiserver create a new uid for the name
|
||||
// This wont be used, the backend will generate a random uid but cannot be blank or will fail.
|
||||
metadata.generateName = 's-';
|
||||
}
|
||||
return originalQuery(requestOptions);
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user