Resource files API

download spec authorize

Resource files API

Manage files containing executable code or definitions used by API policies to enable custom behavior and extensibility.

Resource files are executable code or other types of assets (for example XSLT) that are used by API proxies at runtime. Resource files can be stored at one of three levels:

  • API proxy: Available to any policies in an API proxy.
  • Environment: Available to any policies in any API proxy deployed in the environment.
  • Organization: Available to any API proxy deployed in any environment in an organization.

Resource files are resolved by name. Apigee Edge resolves resource files from most specific (API proxy) to the most general (organization). This enables you to store generic code that provides utility processing at the organization level. This provides for greater maintainability, since generic code is not repeated across multiple API proxies. A good example of code that might be scoped to the organization is a library to do Base64 encoding.

For more information, see Manage resources.

Resource Types

URIs are relative to https://api.enterprise.apigee.com/v1, unless otherwise noted.

ResourceFile

For more information, see ResourceFile.
MethodEndpointDescription
get/organizations/{org_name}/apis/{api_name}/revisions/{revision_number}/resourcefiles

Lists resource files in an API proxy revision. For more information, see Manage resources.

post/organizations/{org_name}/apis/{api_name}/revisions/{revision_number}/resourcefiles

Imports and creates a resource file for an API proxy revision.

Note: Currently, you cannot import a resource file using the Try this API panel.

You can import the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call imports a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/apis/helloworld/revisions/1/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/apis/helloworld/revisions/1/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.

delete/organizations/{org_name}/apis/{api_name}/revisions/{revision_number}/resourcefiles/{resource_type}/{resource_name}

Deletes a resource file from an API proxy revision. For more information, see Manage resources.

put/organizations/{org_name}/apis/{api_name}/revisions/{revision_number}/resourcefiles/{resource_type}/{resource_name}

Updates a resource file in an API proxy revision.

Note: Currently, you cannot update a resource file using the Try this API panel.

You can update the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call updates a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/apis/helloworld/revisions/1/resourcefiles/jsc/pathSetter.js \
  -X PUT \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/apis/helloworld/revisions/1/resourcefiles/jsc/pathSetter.js \
  -X PUT \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.

get/organizations/{org_name}/environments/{env_name}/resourcefiles

Lists resource files in an environment. For more information, see Manage resources.

post/organizations/{org_name}/environments/{env_name}/resourcefiles

Imports and creates a resource file for an environment.

Note: Currently, you cannot import a resource file using the Try this API panel.

You can import the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call imports a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/environments/test/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/environments/test/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.

delete/organizations/{org_name}/environments/{env_name}/resourcefiles/{resource_type}/{resource_name}

Deletes a resource file from an environment. For more information, see Manage resources.

put/organizations/{org_name}/environments/{env_name}/resourcefiles/{resource_type}/{resource_name}

Updates a resource file in an environment.

Note: Currently, you cannot update a resource file using the Try this API panel.

You can update the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call updates a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/environments/test/resourcefiles/jsc/pathSetter.js \
  -X PUT \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/environments/test/resourcefiles?name=pathSetter.js&type=jsc \
  -X PUT \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.

get/organizations/{org_name}/resourcefiles

Lists resource files in an organization. For more information, see Manage resources.

post/organizations/{org_name}/resourcefiles

Imports and creates a resource file for an organization.

Note: Currently, you cannot import a resource file using the Try this API panel.

You can import the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call imports a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles?name=pathSetter.js&type=jsc \
  -X POST \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.

delete/organizations/{org_name}/resourcefiles/{resource_type}/{resource_name}

Deletes a resource file from an organization. For more information, see Manage resources.

put/organizations/{org_name}/resourcefiles/{resource_type}/{resource_name}

Updates a resource file in an organization.

Note: Currently, you cannot update a resource file using the Try this API panel.

You can update the resource file by passing the contents in the request body or by uploading it from a file on your local machine.

For example, the following curl call updates a resource file by passing its contents in the request body. In this case, set the Content-type to application/octet-stream.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles/jsc/pathSetter.js \
  -X PUT \
  -H "Content-type: application/octet-stream" \
  -d 'request.headers["RequestPath"] = context.getVariable("proxy.basepath");' \
  -u email:password

The following curl call shows how to upload the resources as a file from your local machine. In this case, set the Content-type to multipart/form-data. It's important to use -F for the binary upload in curl in order for the environment- or organization-scoped JavaScript files to be accessible by the JavaScript policy.

curl https://api.enterprise.apigee.com/v1/organizations/myorg/resourcefiles/jsc/pathSetter.js \
  -X PUT \
  -H "Content-type:multipart/form-data" \
  -F file=@pathSetter.js \
  -u email:password

For more information, see Manage resources.