Skip to content

Latest commit

 

History

History
308 lines (226 loc) · 8.34 KB

SnippetApi.md

File metadata and controls

308 lines (226 loc) · 8.34 KB

Fastly.SnippetApi

const apiInstance = new Fastly.SnippetApi();

Methods

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

createSnippet({ service_id, version_id, [name, ][type, ][content, ][priority, ][dynamic] })

Create a snippet for a particular service and version.

Example

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);
  });

Options

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"]

Return type

SnippetResponsePost

deleteSnippet

deleteSnippet({ service_id, version_id, snippet_name })

Delete a specific snippet for a particular service and version.

Example

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);
  });

Options

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.

Return type

InlineResponse200

getSnippet

getSnippet({ service_id, version_id, snippet_name })

Get a single snippet for a particular service and version.

Example

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);
  });

Options

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.

Return type

SnippetResponse

getSnippetDynamic

getSnippetDynamic({ service_id, snippet_id })

Get a single dynamic snippet for a particular service.

Example

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);
  });

Options

Name Type Description Notes
service_id String Alphanumeric string identifying the service.
snippet_id String Alphanumeric string identifying a VCL Snippet.

Return type

SnippetResponse

listSnippets

listSnippets({ service_id, version_id })

List all snippets for a particular service and version.

Example

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);
  });

Options

Name Type Description Notes
service_id String Alphanumeric string identifying the service.
version_id Number Integer identifying a service version.

Return type

[SnippetResponse]

updateSnippet

updateSnippet({ service_id, version_id, snippet_name })

Update a specific snippet for a particular service and version.

Example

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);
  });

Options

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.

Return type

SnippetResponse

updateSnippetDynamic

updateSnippetDynamic({ service_id, snippet_id, [name, ][type, ][content, ][priority, ][dynamic] })

Update a dynamic snippet for a particular service.

Example

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);
  });

Options

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"]

Return type

SnippetResponse

[Back to top] [Back to API list] [Back to README]