Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api: adds CRUD operations for scans and scanLabels #58

Merged
merged 8 commits into from
Dec 26, 2024
Merged

Conversation

ashwiniag
Copy link
Member

@ashwiniag ashwiniag commented Dec 25, 2024

Introduces

As follows

ScanLabels

Action Method Endpoint Description
Create POST /scans/{scan_id}/labels Add a new label to a scan.
Read (List) GET /scans/{scan_id}/labels List all labels for a specific scan
Read (Detail) GET /scans/{scan_id}/labels?key={key}&key=(key2} Get a specific label by key.
Read (Detail) GET /scans/{scan_id}/labels/{key} Get a specific label by key.
Update PUT /scans/{scan_id}/labels/{key} Update a specific label by key.
Delete DELETE /scans/{scan_id}/labels/{key} Delete a specific label by key.

cURL

curl -X POST \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
-d '{
  "key": "env",
  "value": "prod"
}' \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels

curl -X GET \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels

curl -X GET \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels/team

curl -X GET \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels\?key\=team\&key\=lts_version | jq '.'

curl -X PUT \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
-d '{
  "key": "env",
  "value": "updated_value"
}' \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels

curl -X PUT \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
-d '{
  "labels": [
    {"key": "lts_version", "value": "v1.0"},
    {"key": "team", "value": "gokakashi"}
  ]
}' \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels

curl -X DELETE \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/df37e432-44cf-46cb-b89d-5b503d59b84f/labels/lts_version

Scans

Action Method Endpoint Description
Create POST /scans Create a new scan.
Read (List) GET /scans List all scans.
Read (Detail) GET /scans/{id} Get details of a specific scan.
Update PUT /scans/{id} Update a scan by ID.

cURL

curl -X POST \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
-d '{
  "policy_id": "5cd8cad8-2547-402a-9f22-1f0109d49be8",
  "image": "acme/image:v1.0",
  "check": {
    "condition": "sev.critical > 0",
    "notify": ["linear", "jira"]
  },
  "status": "scan_pending",
  "report": "http://reports.server.com/scan/123"
}' \
http://localhost:8000/api/v1/scans
curl -X GET \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans


curl -X GET \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/72f2f8b5-72c8-4df4-9980-40895efaa846

curl -X PUT \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
-d '{
  "status": "scan_in_progress"
}' \
http://localhost:8000/api/v1/scans/72f2f8b5-72c8-4df4-9980-40895efaa846
curl -X DELETE \
-H "Authorization: Bearer letsdoit" \
-H "Content-Type: application/json" \
http://localhost:8000/api/v1/scans/72f2f8b5-72c8-4df4-9980-40895efaa846

@ashwiniag ashwiniag merged commit 362e442 into main Dec 26, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant