restapi

package
v0.15.0-beta Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 13 Imported by: 0

README

---
title: "REST API"
lang: "en-US"
draft: false
description: "Learn about how to set up a VDP REST API connector https://github.com/instill-ai/instill-core"
---

The REST API component is a data connector that allows users to make requests to external REST APIs.
It can carry out the following tasks:

- [Get](#get)
- [Post](#post)
- [Patch](#patch)
- [Put](#put)
- [Delete](#delete)
- [Head](#head)
- [Options](#options)

## Release Stage

`Alpha`

## Configuration

The component configuration is defined and maintained [here](https://github.com/instill-ai/component/blob/main/pkg/connector/restapi/v0/config/definition.json).

## Connection

| Field | Field ID | Type | Note |
| :--- | :--- | :--- | :--- |
| Authentication (required) | `authentication` | object | Authentication method to use for the REST API |

## Supported Tasks

### Get

Send a HTTP GET request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_GET` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `output_body_schema` | string | The request body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Post

Send a HTTP POST request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_POST` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `body` | any | The request body |
| Body | `output_body_schema` | string | The JSON schema of output body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Patch

Send a HTTP PATCH request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_PATCH` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `body` | any | The request body |
| Body | `output_body_schema` | string | The JSON schema of output body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Put

Send a HTTP PUT request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_PUT` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `body` | any | The request body |
| Body | `output_body_schema` | string | The JSON schema of output body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Delete

Send a HTTP DELETE request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_DELETE` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `body` | any | The request body |
| Body | `output_body_schema` | string | The JSON schema of output body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Head

Send a HTTP HEAD request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_HEAD` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `output_body_schema` | string | The request body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

### Options

Send a HTTP OPTIONS request.

| Input | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Task ID (required) | `task` | string | `TASK_OPTIONS` |
| Endpoint Url (required) | `endpoint_url` | string | The API endpoint url |
| Body | `body` | any | The request body |
| Body | `output_body_schema` | string | The JSON schema of output body |

| Output | ID | Type | Description |
| :--- | :--- | :--- | :--- |
| Status Code | `status_code` | integer | The HTTP status code of the response |
| Body | `body` | any | The body of the response |
| Header | `header` | object | The HTTP header of the response |

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(l *zap.Logger, u base.UsageHandler) *connector

Types

type TaskInput

type TaskInput struct {
	EndpointURL string      `json:"endpoint_url"`
	Body        interface{} `json:"body,omitempty"`
}

type TaskOutput

type TaskOutput struct {
	StatusCode int                 `json:"status_code"`
	Body       interface{}         `json:"body"`
	Header     map[string][]string `json:"header"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL