Code Manager API

You can use the Code Manager API to deploy code and check the status of deployments on your primary server and compilers without direct shell access.

Forming Code Manager API requests

The Code Manager API accepts well-formed HTTPS requests and requires authentication.

Requests must include a URI path following the pattern:

https://<DNS>:8170/code-manager/v1/<ENDPOINT>

The variable path components derive from:

  • DNS: Your primary server's DNS name. You can use localhost, manually enter the DNS name, or use a puppet command (as explained in Using example commands).
  • ENDPOINT: One or more sections specifying the endpoint, either deploys, webhook, or deploys/status.
If your Code Manager service does not use port 8170, you need to change the port number in the path.

For example, you could use any of these paths to call the GET /v1/deploys/status endpoint:

https://$(puppet config print server):8170/code-manager/v1/deploys/status
https://localhost:8170/code-manager/v1/deploys/status
https://puppet.example.dns:8170/code-manager/v1/deploys/status

To form a complete curl command, you need to provide appropriate curl arguments, authentication, and you might need to supply the content type and/or additional parameters specific to the endpoint you are calling.

For general information about forming curl commands, authentication in commands, and Windows modifications, go to Using example commands.

Code Manager API authentication

Code Manager API requests require token-based authentication. For instructions on generating, configuring, revoking, and deleting authentication tokens in PE, go to Request an authentication token for deployments or Token-based authentication.

To provide tokens for deploys endpoints, you can use an X-authentication header with the puppet-access show command, such as:

auth_header="X-Authentication: $(puppet-access show)"
uri="https://$(puppet config print server):8170/code-manager/v1/deploys/status"

curl --insecure --header "$auth_header" "$uri"

Or you can use the actual token, such as:

auth_header="X-Authentication: <TOKEN>"
uri="https://$(puppet config print server):8170/code-manager/v1/deploys/status"

curl --insecure --header "$auth_header" "$uri"
Unlike the deploys endpoints, when calling the webhook endpoint, you must append the token as a query parameter. Tokens supplied in query parameters might appear in access logs.

Related information