diff --git a/.redocly.yaml b/.redocly.yaml index 2403cc1275..c8e29f87e3 100644 --- a/.redocly.yaml +++ b/.redocly.yaml @@ -15,18 +15,46 @@ apis: remove-x-internal: on admin-internal: root: "./docs/api/admin.yaml" + admin-capella: + root: "./docs/api/admin-capella.yaml" + decorators: + filter-out: + property: x-capella + value: false + remove-x-internal: on public: root: "./docs/api/public.yaml" decorators: remove-x-internal: on public-internal: root: "./docs/api/public.yaml" + public-capella: + root: "./docs/api/public.yaml" + decorators: + filter-out: + property: x-capella + value: false + info-override: + description: "App Services manages access and synchronization between Couchbase Lite and Couchbase Capella" + plugin/replace-description-capella: on + plugin/replace-server-capella: + serverUrl: 'https://{hostname}:4984' + remove-x-internal: on metric: root: "./docs/api/metric.yaml" decorators: remove-x-internal: on metric-internal: root: "./docs/api/metric.yaml" + metric-capella: + root: "./docs/api/metric-capella.yaml" + decorators: + filter-out: + property: x-capella + value: false + plugin/excise-rbac-capella: on + plugin/replace-description-capella: on + remove-x-internal: on diagnostic: root: "./docs/api/diagnostic.yaml" decorators: @@ -34,6 +62,9 @@ apis: diagnostic-internal: root: "./docs/api/diagnostic.yaml" +plugins: + - './docs/api/plugins/plugin.js' + extends: - minimal rules: diff --git a/docs/api/admin-capella.yaml b/docs/api/admin-capella.yaml new file mode 100644 index 0000000000..8042a4f19b --- /dev/null +++ b/docs/api/admin-capella.yaml @@ -0,0 +1,42 @@ +# Copyright 2022-Present Couchbase, Inc. +# +# Use of this software is governed by the Business Source License included +# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +# in that file, in accordance with the Business Source License, use of this +# software will be governed by the Apache License, Version 2.0, included in +# the file licenses/APL2.txt. + +openapi: 3.0.3 +info: + title: App Services Admin API + description: 'App Services manages access and synchronization between Couchbase Lite and Couchbase Capella' + version: 3.3.0 + license: + name: Business Source License 1.1 (BSL) + url: 'https://github.com/couchbase/sync_gateway/blob/master/LICENSE' +servers: + - url: 'https://{hostname}:4985' + description: Admin API + variables: + hostname: + description: The hostname to use + default: localhost +paths: + '/{db}/_session': + $ref: './paths/admin/db-_session.yaml' + '/{db}/_session/{sessionid}': + $ref: './paths/admin/db-_session-sessionid.yaml' + '/{db}/_user/{name}': + $ref: './paths/admin/db-_user-name.yaml' + '/{db}/_user/{name}/_session': + $ref: './paths/admin/db-_user-name-_session.yaml' + '/{db}/_user/{name}/_session/{sessionid}': + $ref: './paths/admin/db-_user-name-_session-sessionid.yaml' + '/{db}/_role/': + $ref: './paths/admin/db-_role-.yaml' + '/{db}/_role/{name}': + $ref: './paths/admin/db-_role-name.yaml' + +externalDocs: + description: Manage App Services for Mobile and Edge | Couchbase Docs + url: 'https://docs.couchbase.com/cloud/app-services/index.html' diff --git a/docs/api/metric-capella.yaml b/docs/api/metric-capella.yaml new file mode 100644 index 0000000000..286ff63913 --- /dev/null +++ b/docs/api/metric-capella.yaml @@ -0,0 +1,32 @@ +# Copyright 2022-Present Couchbase, Inc. +# +# Use of this software is governed by the Business Source License included +# in the file licenses/BSL-Couchbase.txt. As of the Change Date specified +# in that file, in accordance with the Business Source License, use of this +# software will be governed by the Apache License, Version 2.0, included in +# the file licenses/APL2.txt. + +openapi: 3.0.3 +info: + title: App Services Metrics API + description: 'App Services manages access and synchronization between Couchbase Lite and Couchbase Capella' + version: 3.3.0 + license: + name: Business Source License 1.1 (BSL) + url: 'https://github.com/couchbase/sync_gateway/blob/master/LICENSE' +servers: + - url: 'https://{hostname}:4988' + description: Metrics API + variables: + hostname: + description: The hostname to use + default: localhost +paths: + /metrics: + $ref: ./paths/metric/metrics.yaml +tags: + - name: Prometheus + description: Endpoints for use with Prometheus +externalDocs: + description: Manage App Services for Mobile and Edge | Couchbase Docs + url: 'https://docs.couchbase.com/cloud/app-services/index.html' diff --git a/docs/api/plugins/decorators/excise-rbac-capella.js b/docs/api/plugins/decorators/excise-rbac-capella.js new file mode 100644 index 0000000000..afe1feef3e --- /dev/null +++ b/docs/api/plugins/decorators/excise-rbac-capella.js @@ -0,0 +1,33 @@ +/** + * Copyright 2024-Present Couchbase, Inc. + * + * Use of this software is governed by the Business Source License included + * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified + * in that file, in accordance with the Business Source License, use of this + * software will be governed by the Apache License, Version 2.0, included in + * the file licenses/APL2.txt. + */ + +/** + * Removes the RBAC roles from capella API docs. This expects the RBAC information to be at the end of the documentation string. This is not a robust way of doing this. + * @module ExciseRBACCapella + */ + +module.exports = ExciseRBACCapella; + +const re = new RegExp("Required Sync Gateway RBAC roles"); + +/** @type {import('@redocly/cli').OasDecorator} */ +function ExciseRBACCapella() { + return { + Operation: { + leave(Operation) { + // remove all text after first regex match + idx = Operation.description.search(re); + if (idx > 0) { + Operation.description = Operation.description.substr(0, idx); + } + }, + }, + }; +} diff --git a/docs/api/plugins/decorators/replace-description-capella.js b/docs/api/plugins/decorators/replace-description-capella.js new file mode 100644 index 0000000000..252d3947fb --- /dev/null +++ b/docs/api/plugins/decorators/replace-description-capella.js @@ -0,0 +1,30 @@ +/** + * Copyright 2024-Present Couchbase, Inc. + * + * Use of this software is governed by the Business Source License included + * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified + * in that file, in accordance with the Business Source License, use of this + * software will be governed by the Apache License, Version 2.0, included in + * the file licenses/APL2.txt. + */ + +/** + * Does a string replacement on all operations (GET,PUT,POST,etc) to replace Sync Gateway with App Services. + * @module ReplaceDescriptionCapella + */ + +module.exports = ReplaceDescriptionCapella; + +/** @type {import('@redocly/cli').OasDecorator} */ +function ReplaceDescriptionCapella() { + return { + Operation: { + leave(Operation) { + Operation.description = Operation.description.replace( + "Sync Gateway", + "App Services", + ); + }, + }, + }; +} diff --git a/docs/api/plugins/decorators/replace-server-capella.js b/docs/api/plugins/decorators/replace-server-capella.js new file mode 100644 index 0000000000..6bd4808a38 --- /dev/null +++ b/docs/api/plugins/decorators/replace-server-capella.js @@ -0,0 +1,24 @@ +/** + * Copyright 2024-Present Couchbase, Inc. + * + * Use of this software is governed by the Business Source License included + * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified + * in that file, in accordance with the Business Source License, use of this + * software will be governed by the Apache License, Version 2.0, included in + * the file licenses/APL2.txt. + */ + +module.exports = ReplaceServersCapella; + +/** @type {import('@redocly/cli').OasDecorator} */ +function ReplaceServersCapella({ serverUrl }) { + return { + Server: { + leave(Server) { + if (serverUrl) { + Server.url = serverUrl; + } + }, + }, + }; +} diff --git a/docs/api/plugins/plugin.js b/docs/api/plugins/plugin.js new file mode 100644 index 0000000000..e2c875af07 --- /dev/null +++ b/docs/api/plugins/plugin.js @@ -0,0 +1,24 @@ +/** + * Copyright 2024-Present Couchbase, Inc. + * + * Use of this software is governed by the Business Source License included + * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified + * in that file, in accordance with the Business Source License, use of this + * software will be governed by the Apache License, Version 2.0, included in + * the file licenses/APL2.txt. + */ + +const ExciseRBACCapella = require("./decorators/excise-rbac-capella.js"); +const ReplaceDescriptionCapella = require("./decorators/replace-description-capella.js"); +const ReplaceServerCapella = require("./decorators/replace-server-capella.js"); + +module.exports = { + decorators: { + oas3: { + "excise-rbac-capella": ExciseRBACCapella, + "replace-description-capella": ReplaceDescriptionCapella, + "replace-server-capella": ReplaceServerCapella, + }, + }, + id: "plugin", +}; diff --git a/docs/api/public.yaml b/docs/api/public.yaml index 34ca2117b5..faba4520bb 100644 --- a/docs/api/public.yaml +++ b/docs/api/public.yaml @@ -50,8 +50,10 @@ paths: $ref: './paths/public/keyspace-_changes.yaml' '/{db}/_design/{ddoc}': $ref: './paths/public/db-_design-ddoc.yaml' + x-capella: false '/{db}/_design/{ddoc}/_view/{view}': $ref: './paths/public/db-_design-ddoc-_view-view.yaml' + x-capella: false '/{db}/_ensure_full_commit': $ref: './paths/public/db-_ensure_full_commit.yaml' '/{keyspace}/_revs_diff': @@ -101,8 +103,10 @@ tags: description: Create and manage document attachments - name: Replication description: Create and manage inter-Sync Gateway replications + x-capella: false - name: Unsupported description: Endpoints that are not supported by Sync Gateway + x-capella: false externalDocs: description: Sync Gateway Quickstart | Couchbase Docs url: 'https://docs.couchbase.com/sync-gateway/current/index.html' diff --git a/docs/api/replace-servers-capella.js b/docs/api/replace-servers-capella.js new file mode 100644 index 0000000000..7bbadb9f1d --- /dev/null +++ b/docs/api/replace-servers-capella.js @@ -0,0 +1,24 @@ +/** + * Copyright 2024-Present Couchbase, Inc. + * + * Use of this software is governed by the Business Source License included + * in the file licenses/BSL-Couchbase.txt. As of the Change Date specified + * in that file, in accordance with the Business Source License, use of this + * software will be governed by the Apache License, Version 2.0, included in + * the file licenses/APL2.txt. + */ + +module.exports = ReplaceServersCapella; + +/** @type {import('@redocly/cli').OasDecorator} */ + +function ReplaceServersCapella({ serverUrl }) { + return { + Server: { + leave(Server) { + Server.url = serverUrl; + delete Server.protocol; + }, + }, + }; +}