Skip to content

Commit

Permalink
remove url prefix constants
Browse files Browse the repository at this point in the history
  • Loading branch information
pgayvallet committed Nov 2, 2020
1 parent 25d3680 commit 9a9779a
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 28 deletions.
2 changes: 0 additions & 2 deletions x-pack/plugins/saved_objects_tagging/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,3 @@
export const tagFeatureId = 'savedObjectsTagging';
export const tagSavedObjectTypeName = 'tag';
export const tagManagementSectionId = 'tags';
export const tagsApiPrefix = '/api/saved_objects_tagging';
export const tagsInternalApiPrefix = '/internal/saved_objects_tagging';
8 changes: 1 addition & 7 deletions x-pack/plugins/saved_objects_tagging/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
*/

export { TagsCapabilities, getTagsCapabilities } from './capabilities';
export {
tagFeatureId,
tagsInternalApiPrefix,
tagSavedObjectTypeName,
tagManagementSectionId,
tagsApiPrefix,
} from './constants';
export { tagFeatureId, tagSavedObjectTypeName, tagManagementSectionId } from './constants';
export { TagWithRelations, TagAttributes, Tag, ITagsClient, TagSavedObject } from './types';
export {
TagValidation,
Expand Down
13 changes: 6 additions & 7 deletions x-pack/plugins/saved_objects_tagging/public/tags/tags_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/

import { HttpSetup } from 'src/core/public';
import { tagsApiPrefix, tagsInternalApiPrefix } from '../../common/constants';
import { Tag, TagAttributes, ITagsClient, TagWithRelations } from '../../common/types';
import { ITagsChangeListener } from './tags_cache';

Expand Down Expand Up @@ -49,7 +48,7 @@ export class TagsClient implements ITagInternalClient {
// public APIs from ITagsClient

public async create(attributes: TagAttributes) {
const { tag } = await this.http.post<{ tag: Tag }>(`${tagsApiPrefix}/tags/create`, {
const { tag } = await this.http.post<{ tag: Tag }>('/api/saved_objects_tagging/tags/create', {
body: JSON.stringify(attributes),
});

Expand All @@ -63,7 +62,7 @@ export class TagsClient implements ITagInternalClient {
}

public async update(id: string, attributes: TagAttributes) {
const { tag } = await this.http.post<{ tag: Tag }>(`${tagsApiPrefix}/tags/${id}`, {
const { tag } = await this.http.post<{ tag: Tag }>(`/api/saved_objects_tagging/tags/${id}`, {
body: JSON.stringify(attributes),
});

Expand All @@ -78,12 +77,12 @@ export class TagsClient implements ITagInternalClient {
}

public async get(id: string) {
const { tag } = await this.http.get<{ tag: Tag }>(`${tagsApiPrefix}/tags/${id}`);
const { tag } = await this.http.get<{ tag: Tag }>(`/api/saved_objects_tagging/tags/${id}`);
return tag;
}

public async getAll() {
const { tags } = await this.http.get<{ tags: Tag[] }>(`${tagsApiPrefix}/tags`);
const { tags } = await this.http.get<{ tags: Tag[] }>('/api/saved_objects_tagging/tags');

trapErrors(() => {
if (this.changeListener) {
Expand All @@ -95,7 +94,7 @@ export class TagsClient implements ITagInternalClient {
}

public async delete(id: string) {
await this.http.delete<{}>(`${tagsApiPrefix}/tags/${id}`);
await this.http.delete<{}>(`/api/saved_objects_tagging/tags/${id}`);

trapErrors(() => {
if (this.changeListener) {
Expand All @@ -107,7 +106,7 @@ export class TagsClient implements ITagInternalClient {
// internal APIs from ITagInternalClient

public async find({ page, perPage, search }: FindTagsOptions) {
return await this.http.get<FindTagsResponse>(`${tagsInternalApiPrefix}/tags/_find`, {
return await this.http.get<FindTagsResponse>('/internal/saved_objects_tagging/tags/_find', {
query: {
page,
perPage,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

import { schema } from '@kbn/config-schema';
import { IRouter } from 'src/core/server';
import { tagsApiPrefix } from '../../common/constants';
import { TagValidationError } from '../tags';

export const registerCreateTagRoute = (router: IRouter) => {
router.post(
{
path: `${tagsApiPrefix}/tags/create`,
path: '/api/saved_objects_tagging/tags/create',
validate: {
body: schema.object({
name: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

import { schema } from '@kbn/config-schema';
import { IRouter } from 'src/core/server';
import { tagsApiPrefix } from '../../common/constants';

export const registerDeleteTagRoute = (router: IRouter) => {
router.delete(
{
path: `${tagsApiPrefix}/tags/{id}`,
path: '/api/saved_objects_tagging/tags/{id}',
validate: {
params: schema.object({
id: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
*/

import { IRouter } from 'src/core/server';
import { tagsApiPrefix } from '../../common/constants';

export const registerGetAllTagsRoute = (router: IRouter) => {
router.get(
{
path: `${tagsApiPrefix}/tags`,
path: '/api/saved_objects_tagging/tags',
validate: {},
},
router.handleLegacyErrors(async (ctx, req, res) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

import { schema } from '@kbn/config-schema';
import { IRouter } from 'src/core/server';
import { tagsApiPrefix } from '../../common/constants';

export const registerGetTagRoute = (router: IRouter) => {
router.get(
{
path: `${tagsApiPrefix}/tags/{id}`,
path: '/api/saved_objects_tagging/tags/{id}',
validate: {
params: schema.object({
id: schema.string(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@

import { schema } from '@kbn/config-schema';
import { IRouter } from 'src/core/server';
import { tagsInternalApiPrefix, tagSavedObjectTypeName } from '../../../common/constants';
import { tagSavedObjectTypeName } from '../../../common/constants';
import { TagAttributes } from '../../../common/types';
import { savedObjectToTag } from '../../tags';
import { addConnectionCount } from '../lib';

export const registerInternalFindTagsRoute = (router: IRouter) => {
router.get(
{
path: `${tagsInternalApiPrefix}/tags/_find`,
path: '/internal/saved_objects_tagging/tags/_find',
validate: {
query: schema.object({
perPage: schema.number({ min: 0, defaultValue: 20 }),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

import { schema } from '@kbn/config-schema';
import { IRouter } from 'src/core/server';
import { tagsApiPrefix } from '../../common/constants';
import { TagValidationError } from '../tags';

export const registerUpdateTagRoute = (router: IRouter) => {
router.post(
{
path: `${tagsApiPrefix}/tags/{id}`,
path: '/api/saved_objects_tagging/tags/{id}',
validate: {
params: schema.object({
id: schema.string(),
Expand Down

0 comments on commit 9a9779a

Please sign in to comment.