CasC bundle management on Operations Center HTTP API

2 minute readReference

The CasC bundle management on Operations Center HTTP API allows users to view the availability patterns and tokens for all CasC bundles on an Operations Center. It also allows users to assign a bundle to a controller and regenerate tokens.

Authentication and authorization

To access the CasC bundle management on Operations Center API you need an API authentication token and administrator access rights. See API authentication for more information.

Endpoints and methods

Table 1. Endpoints and methods
EndpointDescriptionParameters

GET ${JENKINS_URL}/casc-bundle/list

Lists all of the available CasC bundles on the Operations Center.

None.

POST ${JENKINS_URL}/casc-bundle/regenerate-token

Regenerates the token and returns the new bundle information when successful.

  • Name: bundleId

    • Parameter type: Query string parameter

    • Data type: string

    • Description: The name of the file that contains the CasC bundle. For example, casc-bundle-java.

POST ${JENKINS_URL}/casc-bundle/set-master-to-bundle

Assigns a new controller path and returns the new bundle information when successful.

If you use CloudBees CI 2.277.4.2 or later, no bundles are available to assign to the controller by default. You must first log in to Operations Center as a user with the Administer permission, navigate to the Configuration as Code bundles screen, define the Availability pattern, and then issue the request to assign a bundle to a controller.
  • Name: bundleId

    • Parameter type: Query string parameter

    • Data type: string

    • Description: The bundle id is the name of the file that contains the CasC bundle. For example, casc-bundle.

  • Name: masterPath

    • Parameter type: Query string parameter

    • Data type: string

    • Description: The controller path attribute is the relative path of the controller item in Operations Center. For example, folder1/controller1.

Request examples

Table 2. Request examples
EndpointRequest example

GET /casc-bundle/list

curl --user "admin:rG57xFa2eFrCeWjG4NKU5QMJeW9TzfSkym" -XGET "https://my-operation-center.com/cjoc/casc-bundle/list"

POST /casc-bundle/regenerate-token

curl --user "admin:rG57xFa2eFrCeWjG4NKU5QMJeW9TzfSkym" -XPOST "https://my-operation-center.com/cjoc/casc-bundle/regenerate-token?bundleId=casc-bundle-java"

POST /casc-bundle/set-master-to-bundle

curl --user "admin:rG57xFa2eFrCeWjG4NKU5QMJeW9TzfSkym" -XPOST "https://my-operation-center.com/cjoc/casc-bundle/set-master-to-bundle?bundleId=casc-bundle&masterPath=folder1/controller1"
In the request examples "admin" is the name of the user attempting to send the request and "https://my-operations-center.com/cjoc/" is the url for the Operations Center.

Response examples

GET /casc-bundle/listPOST /casc-bundle/regenerate-tokenPOST /casc-bundle/set-master-to-bundle
{
    "bundles":[
        {
            "linkFileContent":"url: \"https://my-operation-center.com/cjoc/config-bundle/casc-bundle-java\"\ntoken: \"048f49a4-3b37-4ccf-b536-0cc7a3b148d5\"\n",
            "regex":"folder1/.*",
            "name":"casc-bundle-java",
            "url":"https://my-operation-center.com/cjoc/config-bundle/casc-bundle-java",
            "token":"048f49a4-3b37-4ccf-b536-0cc7a3b148d5"
        }
    ]
}
{
    "linkFileContent":"url: \"https://my-operation-center.com/config-bundle/casc-bundle-java\"\ntoken: \"e33d986f-b11b-43c2-8d20-8109854241e0\"\n",
    "regex":"folder1/.*",
    "name":"casc-bundle-java",
    "url":"https://my-operation-center.com/config-bundle/casc-bundle-java",
    "token":"e33d986f-b11b-43c2-8d20-8109854241e0"
}
{
    "linkFileContent": "url: \"https://my-operation-center.com/config-bundle/casc-bundle-java\"\ntoken: \"4b0c02cc-6a7f-4bab-8d8f-38e98684994d\"\n",
    "regex":"folder1/.*",
    "name":"casc-bundle-java",
    "url":"https://my-operation-center.com/config-bundle/casc-bundle-java",
    "token":"4b0c02cc-6a7f-4bab-8d8f-38e98684994d"}
Response examples are formatted for better readability.

Response model

Table 3. Response model
ElementTypeDescription

bundles

array of objects

List of all bundles available on an Operations Center.

linkFileContent

string

Contains two entries in string format wrapped in quotes and separated by newline characters: url and token. The url is the the bundle URL where Operations Center exposes its content. The token is the access token for the bundle.

regex

string

The regex attribute is the full path to one or more controllers in Operations Center that can use the bundle. This must be a regular expression. It defines the bundles you can assign to a controller. For example, folder1/.*.

name

string

The name is the name of the file that contains the CasC bundle. Ex. casc-bundle-java.

url

string

The url is the bundle URL where Operations Center exposes its content.

token

string

The token is the access token for the bundle.

Status and error codes

Table 4. Status and error codes
CodeDescription

200

Success

403

Not authorized. Administrator permission required.

404

The provided master path, endpoint, or method cannot be found.

500

Server error.