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.
Access Tokens and Scope:
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.
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:
URL | METHOD | DESCRIPTION | Scope | Access | DATA | RESPONSE |
---|---|---|---|---|---|---|
| POST | Triggers a run operation on the pipeline which returns the status, a message and the run count for the new run. |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624" } | { "status": "executed", "message": "Run pipeline request submitted successfully for (5fd56d90979ee048ee660624)", "runCount": 2 } OR { "status": "failed", "message": "Pipeline 5fd56d90979ee048ee660624 is currently in a paused state. Will not start another job until this pending status is resolved." } |
| 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. |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624", "runCount": 3 } | { "status": "success", "message": "Pipeline: Blank Template's Run 3 was successful." } |
| POST | Resets the pipeline to the beginning, clearing out any current run data. |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624" } | "status": "success", "message": "The pipeline run status has been reset." } |
| 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. |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624" } | { "status": "success", "message": "The pipeline has been stopped." } |
| POST | Gets the pipeline data by ID |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624" } | Returns full JSON data object of pipeline. |
| 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. |
| Item RBAC | { "pipelineId":"5fd56d90979ee048ee660624", "runCount": 2, "type":"console output" //optional value } | Array of pipeline activity logs. |
| GET | Gets the list of all tools (with all JSON data) that they have access to. |
| Power User Role | n/a | Returns an array of tool objects in JSON format |
| POST | Gets a tool registry JSON object with ALL data about that tool by ID. |
| Item RBAC | { "toolId":"5fc7a12ebed9dd3a622f5d22" } | Returns the full tool object in JSON format. |
| 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. |
| Item RBAC | { "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 |
| GET | Gets the list of all pipelines (with all JSON data) the user token has access to |
| Power User Role | n/a | Returns an array of pipeline objects in JSON format |
| 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) |
| Power User Role | Optional Query Parameters:
| { "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 }, ] } |
| 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) |
| Power User Role | Optional Query Parameters:
| { "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 }, ] } |
| GET | Gets a list of all tasks. |
| Item RBAC | { "count": 286, "data": [... ] } | |
| POST | Gets a task by ID |
| Item RBAC | taskId | { "_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": [] } |
/api/v1/tasks/status | POST | Gets the status of a task’s last status and returns it as a string | API Access | Item RBAC | taskId | Returns task status as a string. |
/api/v1/logs/task | GET | Returns a task log | API Access Security Logs | Item RBAC | taskId Optional Query Parameters: runCount page count | { "count": 9, "data": [ ] } |