diff --git a/modules/apis/confluence-v1/api.ts b/modules/apis/confluence-v1/api.ts new file mode 100644 index 0000000..c0284e3 --- /dev/null +++ b/modules/apis/confluence-v1/api.ts @@ -0,0 +1,28 @@ +/** + * Copyright 2024 Hasnae Rehioui + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import type { AxiosInstance } from 'axios'; + +import { contentApiV1, ContentApiV1 } from './content-api'; + +interface ConfluenceApiV1 { + contentApi: ContentApiV1; +} + +const confluenceApiV1 = (client: AxiosInstance): ConfluenceApiV1 => ({ + contentApi: contentApiV1(client) +}); + +export { confluenceApiV1 }; diff --git a/modules/apis/confluence-cloud/content-api.ts b/modules/apis/confluence-v1/content-api.ts similarity index 100% rename from modules/apis/confluence-cloud/content-api.ts rename to modules/apis/confluence-v1/content-api.ts diff --git a/modules/apis/confluence-cloud/index.ts b/modules/apis/confluence-v1/index.ts similarity index 96% rename from modules/apis/confluence-cloud/index.ts rename to modules/apis/confluence-v1/index.ts index e956988..6b39743 100644 --- a/modules/apis/confluence-cloud/index.ts +++ b/modules/apis/confluence-v1/index.ts @@ -14,3 +14,4 @@ * limitations under the License. */ export * from './types'; +export * from './api'; diff --git a/modules/apis/confluence-cloud/types.ts b/modules/apis/confluence-v1/types.ts similarity index 100% rename from modules/apis/confluence-cloud/types.ts rename to modules/apis/confluence-v1/types.ts diff --git a/modules/apis/index.ts b/modules/apis/index.ts index 62a6b48..bb67a5e 100644 --- a/modules/apis/index.ts +++ b/modules/apis/index.ts @@ -14,4 +14,4 @@ * limitations under the License. */ export * from './confluence'; -export * from './confluence-cloud'; +export * from './confluence-v1'; diff --git a/modules/cli/clients/confluence-v1.ts b/modules/cli/clients/confluence-v1.ts new file mode 100644 index 0000000..8966d36 --- /dev/null +++ b/modules/cli/clients/confluence-v1.ts @@ -0,0 +1,37 @@ +/** + * Copyright 2024 Hasnae Rehioui + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import axios from 'axios'; + +import { confluenceApiV1 } from '../../apis'; +import { environment } from '../conf'; + +const confluenceV1Client = () => { + const siteName = environment.CONFLUENCE_SITE_NAME; + const username = environment.CONFLUENCE_USERNAME; + const apiToken = environment.CONFLUENCE_API_TOKEN; + return confluenceApiV1( + axios.create({ + baseURL: `https://${siteName}`, + auth: { + username, + password: apiToken + } + }) + ); +}; + +const confluenceV1 = confluenceV1Client(); +export { confluenceV1 };