# EdgeFunction

> API reference for Edge Functions (extensions.apoxy.dev/v1alpha2)

**API Group:** `extensions.apoxy.dev/v1alpha2`

## Operations

### List Edge Functions

<APIEndpoint method="GET" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions" />

List EdgeFunction

**Response**

- `200`: OK

---

### Create Edge Function

<APIEndpoint method="POST" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions" />

create an EdgeFunction

**Request Body**

Spec fields (`EdgeFunctionSpec`):

| Field | Type | Description |
| --- | --- | --- |
| `revisionHistoryLimit` | integer (int32) | RevisionHistoryLimit is the number of old revisions to keep. Defaults to 10. |
| `template` | [EdgeFunctionRevisionSpec](#edgefunctionrevisionspec) | Template is the template of the function. **(required)** |

**Response**

- `200`: OK
- `201`: Created
- `202`: Accepted

---

### Delete All Edge Functions

<APIEndpoint method="DELETE" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions" />

Delete collection of EdgeFunction

**Response**

- `200`: OK

---

### Get Edge Function

<APIEndpoint method="GET" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions/{name}" />

Get the specified EdgeFunction

**Response**

- `200`: OK

---

### Replace Edge Function

<APIEndpoint method="PUT" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions/{name}" />

Replace the specified EdgeFunction

**Request Body**

Spec fields (`EdgeFunctionSpec`):

| Field | Type | Description |
| --- | --- | --- |
| `revisionHistoryLimit` | integer (int32) | RevisionHistoryLimit is the number of old revisions to keep. Defaults to 10. |
| `template` | [EdgeFunctionRevisionSpec](#edgefunctionrevisionspec) | Template is the template of the function. **(required)** |

**Response**

- `200`: OK
- `201`: Created

---

### Update Edge Function

<APIEndpoint method="PATCH" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions/{name}" />

Partially update the specified EdgeFunction

**Response**

- `200`: OK
- `201`: Created

---

### Delete Edge Function

<APIEndpoint method="DELETE" path="/apis/extensions.apoxy.dev/v1alpha2/edgefunctions/{name}" />

delete an EdgeFunction

**Response**

- `200`: OK
- `202`: Accepted

---

## Schema Reference

### EdgeFunctionRevisionSpec

| Field | Type | Description |
| --- | --- | --- |
| `code` | [EdgeFunctionCodeSource](#edgefunctioncodesource) | Code is the source of the function code/binary. **(required)** |
| `env` | [EnvVar](#envvar)[] | Env is a list of environment variables to set in the function runtime. These will be available via WASIp1 environ* routines as well as Apoxy Runtime SDK APIs. |
| `mode` | string | Mode is runtime mode of the function. **(required)** |
| `runtime` | [EdgeFunctionRuntime](#edgefunctionruntime) | Configuration for the function runtime. |

### EdgeFunctionCodeSource

| Field | Type | Description |
| --- | --- | --- |
| `goPluginSource` | [GoPluginSource](#gopluginsource) | GoSource specifies sources for the Go filter plugin. This option is only available for non-cloud (kubernets, unmanaged, etc) Proxy providers. |
| `jsSource` | [JavaScriptSource](#javascriptsource) | JsSource specifies sources for the JavaScript function runtime. If set/modified, a function will undergo a build step to compile the JavaScript source into a WebAssembly binary before it is deployed. |
| `wasmSource` | [WasmSource](#wasmsource) | WasmSource specifies sources for the WebAssembly function runtime. |

### GoPluginSource

| Field | Type | Description |
| --- | --- | --- |
| `oci` | [OCIImageRef](#ociimageref) | OCI is the OCI image reference to the Go plugin. |
| `pluginConfig` | string | PluginConfig is the configuration passed to the Go plugin as JSON-encoded structpb.Struct message. Plugin will receive it as anypb.Any message. |
| `url` | string | URL is the URL to the Go plugin .so |

### OCIImageRef

| Field | Type | Description |
| --- | --- | --- |
| `credentials` | [OCICredentials](#ocicredentials) | Credentials is the credentials for pulling the OCI image. Only one of Credentials or CredentialsRef may be specified. |
| `credentialsRef` | [OCICredentialsObjectReference](#ocicredentialsobjectreference) | CredentialsRef is the reference to the secret containing the credentials for pulling the OCI image. Only one of Credentials or CredentialsRef may be specified. |
| `repo` | string | Repo is the repository of the OCI image. **(required)** |
| `tag` | string | Tag is the tag of the OCI image. |

### OCICredentials

| Field | Type | Description |
| --- | --- | --- |
| `password` | string | Password is the password for the OCI registry. This field is write-only and is not returned in the response. |
| `passwordData` | string | PasswordData is the base64 encoded password for the OCI registry. |
| `username` | string | Username is the username for the OCI registry. |

### OCICredentialsObjectReference

| Field | Type | Description |
| --- | --- | --- |
| `group` | string | Group is the group of the target resource. **(required)** |
| `name` | string | Name is the name of the target resource. **(required)** |
| `namespace` | string | Namespace is the namespace of the target resource. **(required)** |

### JavaScriptSource

| Field | Type | Description |
| --- | --- | --- |
| `assets` | [JavaScriptAssetsSource](#javascriptassetssource) | Asset accepts a list of source files to be included in the function. Only one of Assets, Git, or Npm may be specified. |
| `entrypoint` | string | Entrypoint is the entrypoint path to the function. **(required)** |
| `git` | [JavaScriptGitSource](#javascriptgitsource) | Git is the git source for the function. Only one of Assets, Git, or Npm may be specified. |
| `npm` | [JavaScriptNpmSource](#javascriptnpmsource) | Npm is the npm source for the function. Only one of Assets, Git, or Npm may be specified. |

### JavaScriptAssetsSource

| Field | Type | Description |
| --- | --- | --- |
| `files` | [SourceFile](#sourcefile)[] |  **(required)** |

### JavaScriptGitSource

| Field | Type | Description |
| --- | --- | --- |
| `branch` | string | Branch is the git branch. |
| `commit` | string | Commit is the git commit. |
| `repository` | string | Repository is the git repository URL. **(required)** |

### JavaScriptNpmSource

| Field | Type | Description |
| --- | --- | --- |
| `package` | string | Package is the npm package name. **(required)** |
| `version` | string | Version is the npm package version. |

### WasmSource

| Field | Type | Description |
| --- | --- | --- |
| `url` | string | URL is the URL to the WebAssembly binary. **(required)** |

### EdgeFunctionRuntime

| Field | Type | Description |
| --- | --- | --- |
| `capabilities` | [RuntimeCapabilities](#runtimecapabilities) | Capabilities is the list of capabilities granted to the function. |
| `port` | integer (int32) | Port is the port the function listens on. Defaults to 8080. |
| `timeout` | [Duration](#duration) | Timeout is the maximum time the function is allowed to run. Defaults to 30 seconds but can be increased depending on your plan. |

### RuntimeCapabilities

| Field | Type | Description |
| --- | --- | --- |
| `fetchAPI` | boolean | FetchAPI is the capability to fetch data from the internet. Defaults to true. |
| `kv` | boolean | K/V is the capability to access the key/value store. Defaults to true. |
