Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The following API’s are available for integration with end user scripts or automation tools. All API’s listed below require valid Opsera Access Tokens. Please note, GET requests for tools or pipelines are limited to a max of 1000 records.

...

Opsera Access Tokens have predefined scopes. These scopes limit where the the token can be used for more enhanced security. So the scope selected when the token is created must match the required scopes below for the API’s in order for access to be granted. If a 403: Forbidden message is returned, it either means that the token is using the wrong scope or the user who generated the token doesn’t have the permissions necessary to perform the given action on the object. The owner/creator of the token is used in determining access permissions in concert with the scope. For more information on scopes and access tokens, please review the Opsera Access Tokens documentation.Please Note: In addition to a valid token with the proper scope being used, the user who generated/owns the token MUST have the permissions to the object in order for the API to work. A user who does not have access to a given pipeline (even if their token is valid) will not be allowed to perform actions on that pipeline. A user must still be granted that access in the Opsera UI first

The user account used to generate the token is the one associated with the token. They are the owner of that token and as such any API call they use it against will validate their Roles and Access before allowing the action to proceed. A user MUST have the Power User role in order to access Opsera APIs OR be granted explicit access to an object. At this time, getting lists of data such as pipelines and tools requires a power user (or higher) role. But individual actions on specific pipelines or tools will evaluate the individual object’s RBAC access. Users can grant access to individual objects via the Opsera UI.

API Server:

When accessing the Opsera API, this is the URL to use:

https://app.opsera.io

Info

Your base URL may be different based on what platform you are using. Please consult with Opsera to identify your base API URL before proceeding.

URL

METHOD

DESCRIPTION

Scope

Access

DATA

RESPONSE

/api/v1/pipeline/run

POST

Triggers a run operation on the pipeline which returns the status, a message and the run count for the new run.

API Access

Pipeline Access

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624"
}
Code Block
{
    "status": "executed",
    "message": "Run pipeline request submitted successfully for (5fd56d90979ee048ee660624)",
    "runCount": 2
}

OR

Code Block
{
    "status": "failed",
    "message": "Pipeline 5fd56d90979ee048ee660624 is currently in a paused state.  Will not start another job until this pending status is resolved."
}

/api/v1/pipeline/status

POST

Gets the status of a pipeline based on the run count. So this can work against the current run or prior runs from a historical perspective.

API Access

Pipeline Access

Pipeline Logs (Read Only)

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624",
    "runCount": 3
}

Code Block
{
    "status": "success",
    "message": "Pipeline: Blank Template's Run 3 was successful."
}

/api/v1/pipeline/reset

POST

Resets the pipeline to the beginning, clearing out any current run data.

API Access

Pipeline Access

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624"
}

Code Block
    "status": "success",
    "message": "The pipeline run status has been reset."
}

/api/v1/pipeline/stop

POST

Stops a running pipeline. This action will post a stop operation to kafka for supported tools, but the pipeline job will finish it’s current operaiton and then shut down. This is not a hard stop operation.

API Access

Pipeline Access

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624"
}

Code Block
{
    "status": "success",
    "message": "The pipeline has been stopped."
}

/api/v1/pipeline/summary

POST

Gets the pipeline data by ID

API Access

Pipeline Access

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624"
}

Returns full JSON data object of pipeline.

/api/v1/pipeline/logs

POST

Gets pipeline activity logs. Optional runCount can be passed as integer. Data is limited to a max of 1000 records and is always sorted by most recent activity first.

The “type” property of the POST body is optional. If that exact string “console output” is passed, it will restrict the logs being returned to the console log activity for that given run.

API Access

Pipeline Access

Pipeline Logs (Read Only)

Item RBAC

Code Block
{
    "pipelineId":"5fd56d90979ee048ee660624",
    "runCount": 2,
    "type":"console output" //optional value
}

Array of pipeline activity logs.

/api/v1/registry/tools

GET

Gets the list of all tools (with all JSON data) that they have access to.

API Access

Tool Registry Access

Power User Role

n/a

Returns an array of tool objects in JSON format

/api/v1/registry/summary

POST

Gets a tool registry JSON object with ALL data about that tool by ID.

API Access

Tool Registry Access

Item RBAC

Code Block
{
    "toolId":"5fc7a12ebed9dd3a622f5d22"
}

Returns the full tool object in JSON format.

/api/v1/registry/update

POST

Passes a tool registry ID and then the data object properties of that tool in JSON that you wish to update. This can be as much or as little of the root JSON object as long as the data structure is preserved. It’s advised not to send the “_id” but it isn’t going to break things. Same with the createdAt or updatedAt. This allows for strategic updates of just the root properties of the pipeline data object or the whole thing.

API Access

Tool Registry Access

Item RBAC

Code Block
{
    "toolId":"5fd56d90979ee048ee660624",
    "tool": {
        "name":"Updated Tool Name Via CLI",
        "description": "Updating the description here through customer API.  Fingers crossed"
    }
}

Returns the updated tool object in JSON format

/api/v1/pipeline/pipelines

GET

Gets the list of all pipelines (with all JSON data) the user token has access to

API Access

Pipeline Access

Power User Role

n/a

Returns an array of pipeline objects in JSON format

/api/v1/logs/user/actions

GET

Gets the User Activity Logs for the system. This is a route limited to Site Admins and Power users and requires a token of either API scope or Security Logs scope.

If no date parameter is passed, the last 7 days of logs will be returned (up to a max of 1000 records)

API Access

Security Logs (Read Only)

Power User Role

Optional Query Parameters:

?date=YYYY-MM-DD

?type=<value from type field>

?count=<integer, number of records>

Code Block
{
    "count": 6,
    "data": [
        {
            "_id": "61042540e1d666c9ded178c4",
            "user_id": "5e1cbf251c26d68f7ce6361e",
            "user_email": "support@opsera.io",
            "type": "pipeline",
            "action": "update",
            "target_id": "5fbe589a0fae8b021e137534",
            "account": "org-opsera-dnd-acc0",
            "createdAt": "2021-07-30T16:13:52.109Z",
            "updatedAt": "2021-07-30T16:13:52.109Z",
            "__v": 0
        },
  ]
}

/api/v1/logs/user/tokens

GET

Gets the Personal Access Tokens' Activity Logs. This is a route limited to Site Admins and Power users and requires a token of either API scope or Security Logs scope.

If no date parameter is passed, the last 7 days will be returned.(up to a max of 1000 records)

API Access

Security Logs (Read Only)

Power User Role

Optional Query Parameters:

?date=YYYY-MM-DD

?scope=<value from scope field>

Code Block
{
    "count": 6,
    "data": [
        {
            "_id": "61057f3a1429a35336563240",
            "token_id": "61043b2bbcb6d95b55adc5fd",
            "scope": "api",
            "target": "/v1/logs/user/tokens",
            "user_id": "5e1cbf251c26d68f7ce6361e",
            "account": "org-opsera-dnd-acc0",
            "createdAt": "2021-07-31T16:50:02.242Z",
            "updatedAt": "2021-07-31T16:50:02.242Z",
            "__v": 0
        },
  ]
}

/api/v1/tasks

GET

Gets a list of all tasks.

API Access

Item RBAC

Code Block
{
  "count": 286,
  "data": [...
  ]
}

api/v1/tasks/summary

POST

Gets a task by ID

API Access

Item RBAC

Code Block
taskId
Code Block
{
    "_id": "6116cf8b62e1f0f2459de839",
    "tags": [],
    "name": "AAACCCTask",
    "description": "",
    "type": "sync-sfdc-repo",
    "tool_identifier": "bitbucket",
    "active": true,
    "configuration": {
        "type": "bitbucket",
        "jobType": "",
        "toolConfigId": "60e6b0ed1c1593ad863029fa",
        "autoScaleEnable": false,
        "toolJobName": "",
        "toolName": "QA Jenkins Master",
        "jobName": null,
        "agentLabels": "",
        "toolJobId": "",
        "projectId": "sfdx-repo",
        "buildType": "ant",
        "gitToolId": "60d56ba1a641241a34cd1505",
        "gitUrl": "https://GeorgeOpsera@bitbucket.org/rajeswarr1/sfdx-repo.git",
        "sshUrl": "git@bitbucket.org:rajeswarr1/sfdx-repo.git",
        "service": "bitbucket",
        "gitCredential": "BBcloud",
        "workspace": "rajeswarr1",
        "workspaceName": "rajeswarr1",
        "repository": "SFDX Repo",
        "branch": "sfdx-test_1232",
        "gitBranch": "sfdx-test_1232",
        "sourceBranch": "",
        "autoApprove": false,
        "defaultBranch": "sfdx-test_1232",
        "dependencyType": "",
        "sfdcToolId": "61166bfe270779640401d705",
        "sfdcToolName": "Sfdx Opsera",
        "accountUsername": "sundar@opsera.io",
        "isNewBranch": true,
        "upstreamBranch": "sfdx-rel-test",
        "includePackageXml": false,
        "packageXmlReferencePath": "",
        "reviewers": [],
        "reviewerNames": [],
        "sfdcDestToolId": "",
        "destAccountUsername": "",
        "sfdcUnitTestType": "",
        "workspaceDeleteFlag": false,
        "gitUserName": "GeorgeOpsera",
        "repoId": "sfdx-repo"
    },
    "status": "failure",
    "roles": [],
    "account": "org102-acc",
    "owner": "HariOwner Ldap",
    "createdAt": "2021-08-13T20:01:15.376Z",
    "updatedAt": "2021-11-08T06:21:57.182Z",
    "__v": 0,
    "owner_name": "HariOwner Ldap",
    "run_count": 4,
    "message": "[Git Merge Action]: Synch up successful",
    "jenkinsIds": []
}
Code Block
/api/v1/tasks/status

POST

Gets the status of a task’s last status and returns it as a string

Code Block
API Access

Item RBAC

Code Block
taskId

Returns task status as a string.

Code Block
/api/v1/logs/task

GET

Returns a task log

Code Block
API Access
Code Block
Security Logs

Item RBAC

Code Block
taskId

Optional Query Parameters:

Code Block
runCount

Code Block
languagenone
page

Code Block
count

Code Block
{
    "count": 9,
    "data": [
    ]
}