const apiInstance = new Fastly.SnippetApi();
Note
All URIs are relative to https://api.fastly.com
Method | HTTP request | Description |
---|---|---|
createSnippet | POST /service/{service_id}/version/{version_id}/snippet | Create a snippet |
deleteSnippet | DELETE /service/{service_id}/version/{version_id}/snippet/{snippet_name} | Delete a snippet |
getSnippet | GET /service/{service_id}/version/{version_id}/snippet/{snippet_name} | Get a versioned snippet |
getSnippetDynamic | GET /service/{service_id}/snippet/{snippet_id} | Get a dynamic snippet |
listSnippets | GET /service/{service_id}/version/{version_id}/snippet | List snippets |
updateSnippet | PUT /service/{service_id}/version/{version_id}/snippet/{snippet_name} | Update a versioned snippet |
updateSnippetDynamic | PUT /service/{service_id}/snippet/{snippet_id} | Update a dynamic snippet |
createSnippet({ service_id, version_id, [name, ][type, ][content, ][priority, ][dynamic] })
Create a snippet for a particular service and version.
const options = {
service_id: "service_id_example", // required
version_id: 56, // required
name: "name_example",
type: "init",
content: "content_example",
priority: "'100'",
dynamic: "0",
};
apiInstance.createSnippet(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
version_id | Number | Integer identifying a service version. | |
name | String | The name for the snippet. | [optional] |
type | String | The location in generated VCL where the snippet should be placed. | [optional] [one of: "init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"] |
content | String | The VCL code that specifies exactly what the snippet does. | [optional] |
priority | String | Priority determines execution order. Lower numbers execute first. | [optional] [defaults to '100'] |
dynamic | String | Sets the snippet version. | [optional] [one of: "0", "1"] |
deleteSnippet({ service_id, version_id, snippet_name })
Delete a specific snippet for a particular service and version.
const options = {
service_id: "service_id_example", // required
version_id: 56, // required
snippet_name: "snippet_name_example", // required
};
apiInstance.deleteSnippet(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
version_id | Number | Integer identifying a service version. | |
snippet_name | String | The name for the snippet. |
getSnippet({ service_id, version_id, snippet_name })
Get a single snippet for a particular service and version.
const options = {
service_id: "service_id_example", // required
version_id: 56, // required
snippet_name: "snippet_name_example", // required
};
apiInstance.getSnippet(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
version_id | Number | Integer identifying a service version. | |
snippet_name | String | The name for the snippet. |
getSnippetDynamic({ service_id, snippet_id })
Get a single dynamic snippet for a particular service.
const options = {
service_id: "service_id_example", // required
snippet_id: "snippet_id_example", // required
};
apiInstance.getSnippetDynamic(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
snippet_id | String | Alphanumeric string identifying a VCL Snippet. |
listSnippets({ service_id, version_id })
List all snippets for a particular service and version.
const options = {
service_id: "service_id_example", // required
version_id: 56, // required
};
apiInstance.listSnippets(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
version_id | Number | Integer identifying a service version. |
updateSnippet({ service_id, version_id, snippet_name })
Update a specific snippet for a particular service and version.
const options = {
service_id: "service_id_example", // required
version_id: 56, // required
snippet_name: "snippet_name_example", // required
};
apiInstance.updateSnippet(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
version_id | Number | Integer identifying a service version. | |
snippet_name | String | The name for the snippet. |
updateSnippetDynamic({ service_id, snippet_id, [name, ][type, ][content, ][priority, ][dynamic] })
Update a dynamic snippet for a particular service.
const options = {
service_id: "service_id_example", // required
snippet_id: "snippet_id_example", // required
name: "name_example",
type: "init",
content: "content_example",
priority: "'100'",
dynamic: "0",
};
apiInstance.updateSnippetDynamic(options)
.then((data) => {
console.log(data, "API called successfully.");
})
.catch((error) => {
console.error(error);
});
Name | Type | Description | Notes |
---|---|---|---|
service_id | String | Alphanumeric string identifying the service. | |
snippet_id | String | Alphanumeric string identifying a VCL Snippet. | |
name | String | The name for the snippet. | [optional] |
type | String | The location in generated VCL where the snippet should be placed. | [optional] [one of: "init", "recv", "hash", "hit", "miss", "pass", "fetch", "error", "deliver", "log", "none"] |
content | String | The VCL code that specifies exactly what the snippet does. | [optional] |
priority | String | Priority determines execution order. Lower numbers execute first. | [optional] [defaults to '100'] |
dynamic | String | Sets the snippet version. | [optional] [one of: "0", "1"] |