Skip to content

Commit

Permalink
Merge pull request #202 from seqeralabs/api-overview
Browse files Browse the repository at this point in the history
Improve API overview
  • Loading branch information
llewellyn-sl authored Sep 18, 2024
2 parents 3e90ed9 + 39fa8b9 commit 571821a
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 77 deletions.
Binary file not shown.
53 changes: 35 additions & 18 deletions platform_versioned_docs/version-23.4/api/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,68 @@ date: "15 Mar 2024"
tags: [api]
---

The Seqera Platform public API provides endpoints to manage Nextflow workflows programmatically, allowing organizations to incorporate Seqera seamlessly into their existing processes.
import MDXComponents from "@theme-original/MDXComponents";
import Button from "@site/src/components/Button";

:::note
As of version 23.4, the Seqera API is live on `https://api.cloud.seqera.io`. The legacy API `https://api.tower.nf` remains fully operational, so existing API integrations will continue to perform as expected. Deprecation of the legacy API will be communicated well in advance to avoid any breaking changes to your integrations.
The Seqera Platform services API is a programmatic interface for all operations available in the Platform web UI. This allows organizations to integrate Platform seamlessly into existing processes.

### API reference

The Platform API reference is an interactive list of all API endpoints and includes request and response payload examples to test requests in the browser.

:::info
The API requires authentication with a Platform access token to perform requests.

<Button label="Create an access token" link="https://cloud.seqera.io/tokens" />
:::

The API can be accessed from `https://api.cloud.seqera.io`. All API endpoints use HTTPS, and all request and response payloads use [JSON](https://www.json.org/) encoding. All timestamps use the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date-time standard format: `YYYY-MM-DDTHH:MM:SSZ`.
<Button label="Platform OpenAPI reference" link="https://cloud.seqera.io/openapi/index.html" />

### OpenAPI
The API and its interactive reference is built on the OpenAPI standard. Download the current OpenAPI schema file here:

The Seqera API uses the OpenAPI standard. The current OpenAPI schema can be found [here](https://cloud.seqera.io/openapi/seqera-api-latest.yml).
<Button label="Download Platform OpenAPI schema" link="https://cloud.seqera.io/openapi/seqera-api-latest.yml" />

:::tip
For more information on the OpenAPI standard, see [OpenAPI](https://swagger.io/specification/).
:::

### Endpoints
### Encoding and formatting standards

See [Seqera Platform services API](https://cloud.seqera.io/openapi/index.html) for a detailed list of all endpoints. This page includes request and response payload examples, and the ability to test each endpoint interactively.
- The API can be accessed from `https://api.cloud.seqera.io`.
- All API endpoints use HTTPS, and all request and response payloads use [JSON](https://www.json.org/) encoding.
- All timestamps use the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date-time standard format: `YYYY-MM-DDTHH:MM:SSZ`.

:::note
From version 23.4, the Platform API is live on `https://api.cloud.seqera.io`. The legacy API `https://api.tower.nf` remains fully operational, so existing API integrations will continue to perform as expected. Deprecation of the legacy API will be communicated well in advance to avoid any breaking changes to your integrations.
:::

### Programmatic API

You can use tools such as [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate a programmatic API for a particular language (e.g., Python) based on the OpenAPI schema. However, we do not guarantee that any OpenAPI client generators will work with Seqera API.
Both the [Platform CLI](../cli/overview.mdx) and [seqerakit](https://github.com/seqeralabs/seqera-kit) are built on the Platform API and provide a programmatic automation layer for operations in Platform.

You can also use tools such as [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate your own programmatic API for a particular language (such as Python) based on the OpenAPI schema. However, we do not guarantee that any OpenAPI client generators will work with the Platform API.

### Authentication

The API requires an authentication token to be specified in each API request using the
[Bearer](https://swagger.io/docs/specification/authentication/bearer-authentication) HTTP header.

Your personal authorization token can be found in the user menu under [**Your tokens**](https://cloud.seqera.io/tokens).

To create a new access token, provide token name and select **Create**.
Once created, use your access token to authenticate requests to the API via cURL, Postman, or within your code.

The token is only displayed once. Store your token in a safe place.
<Button label="Create an access token" link="https://cloud.seqera.io/tokens" />

Once created, use the token to authenticate requests to the API via cURL, Postman, or within your code.
:::note
The token is only displayed once when it is created. Store your token in a safe place.
:::

### cURL example

```bash
curl -H "Authorization: Bearer eyJ...YTk0" https://api.cloud.seqera.io/workflow
```

:::tip
Your token must be included in every API call. See [Bearer token authentication](https://swagger.io/docs/specification/authentication/bearer-authentication) for more information.
:::info
Your access token must be included in every API call.
:::

### Parameters
Expand All @@ -68,7 +85,7 @@ curl -H "Authorization: Bearer QH..E5M="
### Client errors
Two typical standard errors, i.e., not `200` or `204` status responses, are returned by the API.
Two typical standard errors (i.e., response statuses other than `200` or `204`) are returned by the API.
#### Bad Request
Expand All @@ -82,7 +99,7 @@ The request payload is not properly defined or the query parameters are invalid.
#### Forbidden
Your access token is invalid or expired. This response may also imply that the entry point you are trying to access is not available. Check your request syntax for typos, and confirm that your access token is valid.
Your access token is invalid or expired. This response may also imply that the endpoint you are trying to access is not available. Check your request syntax for typos, and confirm that your access token is valid.
```bash
Status: 403 Forbidden
Expand Down
Binary file not shown.
53 changes: 35 additions & 18 deletions platform_versioned_docs/version-24.1/api/overview.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,68 @@ date: "15 Mar 2024"
tags: [api]
---

The Seqera Platform public API provides endpoints to manage Nextflow workflows programmatically, allowing organizations to incorporate Seqera seamlessly into their existing processes.
import MDXComponents from "@theme-original/MDXComponents";
import Button from "@site/src/components/Button";

:::note
As of version 23.4, the Seqera API is live on `https://api.cloud.seqera.io`. The legacy API `https://api.tower.nf` remains fully operational, so existing API integrations will continue to perform as expected. Deprecation of the legacy API will be communicated well in advance to avoid any breaking changes to your integrations.
The Seqera Platform services API is a programmatic interface for all operations available in the Platform web UI. This allows organizations to integrate Platform seamlessly into existing processes.

### API reference

The Platform API reference is an interactive list of all API endpoints and includes request and response payload examples to test requests in the browser.

:::info
The API requires authentication with a Platform access token to perform requests.

<Button label="Create an access token" link="https://cloud.seqera.io/tokens" />
:::

The API can be accessed from `https://api.cloud.seqera.io`. All API endpoints use HTTPS, and all request and response payloads use [JSON](https://www.json.org/) encoding. All timestamps use the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date-time standard format: `YYYY-MM-DDTHH:MM:SSZ`.
<Button label="Platform OpenAPI reference" link="https://cloud.seqera.io/openapi/index.html" />

### OpenAPI
The API and its interactive reference is built on the OpenAPI standard. Download the current OpenAPI schema file here:

The Seqera API uses the OpenAPI standard. The current OpenAPI schema can be found [here](https://cloud.seqera.io/openapi/seqera-api-latest.yml).
<Button label="Download Platform OpenAPI schema" link="https://cloud.seqera.io/openapi/seqera-api-latest.yml" />

:::tip
For more information on the OpenAPI standard, see [OpenAPI](https://swagger.io/specification/).
:::

### Endpoints
### Encoding and formatting standards

See [Seqera Platform services API](https://cloud.seqera.io/openapi/index.html) for a detailed list of all endpoints. This page includes request and response payload examples, and the ability to test each endpoint interactively.
- The API can be accessed from `https://api.cloud.seqera.io`.
- All API endpoints use HTTPS, and all request and response payloads use [JSON](https://www.json.org/) encoding.
- All timestamps use the [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) date-time standard format: `YYYY-MM-DDTHH:MM:SSZ`.

:::note
From version 23.4, the Platform API is live on `https://api.cloud.seqera.io`. The legacy API `https://api.tower.nf` remains fully operational, so existing API integrations will continue to perform as expected. Deprecation of the legacy API will be communicated well in advance to avoid any breaking changes to your integrations.
:::

### Programmatic API

You can use tools such as [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate a programmatic API for a particular language (e.g., Python) based on the OpenAPI schema. However, we do not guarantee that any OpenAPI client generators will work with Seqera API.
Both the [Platform CLI](../cli/overview.mdx) and [seqerakit](https://github.com/seqeralabs/seqera-kit) are built on the Platform API and provide a programmatic automation layer for operations in Platform.

You can also use tools such as [openapi-python-client](https://github.com/openapi-generators/openapi-python-client) to generate your own programmatic API for a particular language (such as Python) based on the OpenAPI schema. However, we do not guarantee that any OpenAPI client generators will work with the Platform API.

### Authentication

The API requires an authentication token to be specified in each API request using the
[Bearer](https://swagger.io/docs/specification/authentication/bearer-authentication) HTTP header.

Your personal authorization token can be found in the user menu under [**Your tokens**](https://cloud.seqera.io/tokens).

To create a new access token, provide token name and select **Create**.
Once created, use your access token to authenticate requests to the API via cURL, Postman, or within your code.

The token is only displayed once. Store your token in a safe place.
<Button label="Create an access token" link="https://cloud.seqera.io/tokens" />

Once created, use the token to authenticate requests to the API via cURL, Postman, or within your code.
:::note
The token is only displayed once when it is created. Store your token in a safe place.
:::

### cURL example

```bash
curl -H "Authorization: Bearer eyJ...YTk0" https://api.cloud.seqera.io/workflow
```

:::tip
Your token must be included in every API call. See [Bearer token authentication](https://swagger.io/docs/specification/authentication/bearer-authentication) for more information.
:::info
Your access token must be included in every API call.
:::

### Parameters
Expand All @@ -68,7 +85,7 @@ curl -H "Authorization: Bearer QH..E5M="
### Client errors
Two typical standard errors, i.e., not `200` or `204` status responses, are returned by the API.
Two typical standard errors (i.e., response statuses other than `200` or `204`) are returned by the API.
#### Bad Request
Expand All @@ -82,7 +99,7 @@ The request payload is not properly defined or the query parameters are invalid.
#### Forbidden
Your access token is invalid or expired. This response may also imply that the entry point you are trying to access is not available. Check your request syntax for typos, and confirm that your access token is valid.
Your access token is invalid or expired. This response may also imply that the endpoint you are trying to access is not available. Check your request syntax for typos, and confirm that your access token is valid.
```bash
Status: 403 Forbidden
Expand Down
116 changes: 76 additions & 40 deletions src/components/Button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,80 @@
import React from "react";
import clsx from "clsx";
import Link from "@docusaurus/Link";
import React, { ReactNode, CSSProperties } from 'react';
import clsx from 'clsx';
import Link from '@docusaurus/Link';

import styles from "./styles.module.css";
// Define the Button type to control the props that can be passed to the Button component.
type Button = {
// The size prop can be one of the following values: 'sm', 'lg', 'small', 'medium', 'large', or null.
// We'll convert 'small' to 'sm' and 'large' to 'lg' in the component. 'medium' will be considered null.
size?: 'sm' | 'lg' | 'small' | 'medium' | 'large' | null;
// The outline prop is a boolean that determines if the button should be an outline button.
outline?: boolean;
// The variant prop is a string that determines the color of the button.
// It can be one of the following values: 'primary', 'secondary', 'danger', 'warning', 'success', 'info', 'link', or any other string.
// The default value is 'primary'.
variant: 'primary' | 'secondary' | 'danger' | 'warning' | 'success' | 'info' | 'link' | string;
// The block prop is a boolean that determines if the button should be a block-level button.
block?: boolean;
// The disabled prop is a boolean that determines if the button should be disabled.
disabled?: boolean;
// The className prop is a string that allows you to add custom classes to the button.
className?: string;
// The style prop is an object that allows you to add custom styles to the button.
style?: CSSProperties;
// The link prop is a string that determines the URL the button should link to.
link: string;
// The label prop is a string that determines the text of the button.
label: string;
}

import Arrow from "./arrow.inline.svg";

type Props = {
to: string;
children: React.ReactNode;
cta?: boolean;
arrow?: boolean;
className?: string;
};

const Button: React.FC<Props> = ({ to, children, cta, className, arrow }) => {
const isExternal = to?.startsWith("http");

if (isExternal)
// Button component that accepts the specified props.
export default function Button ({
size = null,
outline = false,
variant = 'primary',
block = false,
disabled = false,
className,
style,
link,
label
}: Button) {
// Map the size prop values to corresponding CSS classes.
const sizeMap = {
sm: 'sm',
small: 'sm',
lg: 'lg',
large: 'lg',
medium: null,
};
const buttonSize = size ? sizeMap[size] : '';
const sizeClass = buttonSize ? `button--${buttonSize}` : '';
const outlineClass = outline ? 'button--outline' : '';
const variantClass = variant ? `button--${variant}` : '';
const blockClass = block ? 'button--block' : '';
const disabledClass = disabled ? 'disabled' : '';
// If the button is disabled, set the destination to null.
const destination = disabled ? null : link;
return (
<a
href={to}
target="_blank"
className={clsx(styles.button, className, { [styles.cta]: cta })}
rel="noopener noreferrer"
>
{children}
{arrow && <Arrow />}
</a>
<p>
<Link to={destination}>
<button
className={clsx(
'button',
sizeClass,
outlineClass,
variantClass,
blockClass,
disabledClass,
className
)}
style={style}
role='button'
aria-disabled={disabled}
>
{label}
</button>
</Link>
</p>
);

return (
<Link
to={to}
className={clsx(styles.button, className, { [styles.cta]: cta })}
>
{children}
{arrow && <Arrow />}
</Link>
);
};

export default Button;
}
44 changes: 44 additions & 0 deletions src/components/Button/index_old.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from "react";
import clsx from "clsx";
import Link from "@docusaurus/Link";

import styles from "./styles.module.css";

import Arrow from "./arrow.inline.svg";

type Props = {
to: string;
children: React.ReactNode;
cta?: boolean;
arrow?: boolean;
className?: string;
};

const Button: React.FC<Props> = ({ to, children, cta, className, arrow }) => {
const isExternal = to?.startsWith("http");

if (isExternal)
return (
<a
href={to}
target="_blank"
className={clsx(styles.button, className, { [styles.cta]: cta })}
rel="noopener noreferrer"
>
{children}
{arrow && <Arrow />}
</a>
);

return (
<Link
to={to}
className={clsx(styles.button, className, { [styles.cta]: cta })}
>
{children}
{arrow && <Arrow />}
</Link>
);
};

export default Button;
2 changes: 1 addition & 1 deletion src/components/Button/styles.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
border-radius: 99px;
transition: all 0.2s;
line-height: 1;
white-space: nowrap;
white-space: normal;
}
.button:hover {
text-decoration: none;
Expand Down
2 changes: 2 additions & 0 deletions src/theme/MDXComponents.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import React from "react";
// Import the original mapper
import MDXComponents from "@theme-original/MDXComponents";
import CodeBlock from "@theme-original/CodeBlock";
import Button from "@site/src/components/Button";

export default {
// Re-use the default mapping
...MDXComponents,
CodeBlock,
Button,
};

0 comments on commit 571821a

Please sign in to comment.