Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/spotinst/openapi into fea…
Browse files Browse the repository at this point in the history
…ture/SPOTSEC-4343/public-docs-secops-rest-api
  • Loading branch information
Avinash Bharti committed Dec 6, 2024
2 parents 93ed263 + 884abcf commit b22b9cd
Show file tree
Hide file tree
Showing 9 changed files with 236 additions and 2 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/pr-jira-validation.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: pr-jira-validation

on:
pull_request:
branches:
- master

# workflow_dispatch:
# inputs:
# branch_name:
# description: "Name of the branch to test !"
# required: true
# default: "DOC-2064-test-shimi-3"

jobs:
validate:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ github.token }}
steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Get source branch
id: get_source_branch
run: echo "branch=${{ github.event.pull_request.head.ref }}" >> $GITHUB_ENV
#run: echo "branch=${{ inputs.branch_name }}" >> $GITHUB_ENV
#

- name: Get branch creation event
id: get_branch_creation_event
run: |
echo "repo - ${{ github.repository }}"
BRANCH_CREATION_EVENT=$(gh api -H "Accept: application/vnd.github.v3+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.repository }}/activity | jq -c '[.[] | select(.activity_type == "branch_creation" and .ref == "refs/heads/${{ env.branch }}")] | .[0]')
echo "branch_creation_event - $BRANCH_CREATION_EVENT"
echo "branch_creation_event=$BRANCH_CREATION_EVENT" >> $GITHUB_ENV
- name: Validate branch creator
id: validate_branch_creator
run: |
ACTOR_LOGIN=$(echo '${{ env.branch_creation_event }}' | jq -r '.actor.login')
echo "ACTOR_LOGIN - $ACTOR_LOGIN"
if [ "$ACTOR_LOGIN" != "jira[bot]" ]; then
echo "Branch was not created by jira[bot]."
exit 1
fi
- name: Validate PR body for Jira ticket link
id: validate_pr_body
run: |
PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH)
echo "PR-body - $PR_BODY"
if ! echo "$PR_BODY" | grep -q -e "https://spotinst.atlassian.net/browse/DOC-" -e "https://spotinst.atlassian.net/browse/AUT-"; then
echo "PR body does not contain a valid Jira ticket link (DOC or AUT)."
exit 1
fi
- name: Extract Jira ticket ID
id: extract_jira_ticket
run: |
PR_BODY=$(jq -r '.pull_request.body' < $GITHUB_EVENT_PATH)
JIRA_TICKET=$(echo "$PR_BODY" | grep -o -e "DOC-[0-9]*" -e "AUT-[0-9]*" | head -n 1)
if [ -z "$JIRA_TICKET" ]; then
echo "No DOC or AUT Jira ticket found in the PR body."
exit 1
fi
echo "jira_ticket=$JIRA_TICKET" >> $GITHUB_ENV
- name: Verify Jira ticket status
id: verify_jira_ticket
env:
JIRA_USER: ${{ secrets.JIRA_USER }}
JIRA_API_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
run: |
JIRA_TICKET=${{ env.jira_ticket }}
JIRA_API_URL="https://spotinst.atlassian.net/rest/api/2/issue/$JIRA_TICKET"
JIRA_STATUS=$(curl -s -u $JIRA_USER:$JIRA_API_TOKEN $JIRA_API_URL | jq -r '.fields.status.name')
echo "JIRA_STATUS - $JIRA_STATUS"
if [ "$JIRA_STATUS" != "Approved for Publishing" ]; then
if [[ "$JIRA_TICKET" == *DOC* ]]; then
echo "Jira ticket $JIRA_TICKET is not in 'Approved for Publishing' status and it is from 'DOC' project."
exit 1
fi
fi
echo "All validations passed."
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
get:
summary: "Detailed Cost"
description:
Get detailed financial information on a specific Elastigroup
Get detailed financial information on a specific Elastigroup, for all lifecycles.
operationId: "elastigroupAwsDetailedCosts"
tags:
- "Elastigroup AWS"
Expand All @@ -23,6 +23,14 @@ get:
schema:
type: "string"
required: true
- in: "query"
name: "aggregationPeriod"
example: "daily"
description: >
Optional. The time period over which data is aggregated. Can only be "daily". For example, the figures in each data set are per day
schema:
type: "string"
required: false
- in: "query"
name: "accountId"
example: "act-123abc"
Expand Down
2 changes: 1 addition & 1 deletion api/services/elastigroup/aws/paths/elastigroup-costs.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
get:
summary: "Get Costs per Elastigroup"
description:
Get financial information on a specific Elastigroup
Get financial information on a specific Elastigroup, return only Spot costs.
operationId: "awsCostsPerElastigroup"
tags:
- "Elastigroup AWS"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
in: query
name: clusterIdentifier
schema:
type: string
required: true
example: dev-cluster
description: >
Identifier of cluster.
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
post:
summary: "Acknowledge Rightsizing Rollbacks"
description: |
Acknowledge rightsizing rollbacks For ocean cluster.
operationId: "AcknowledgeRightsizingRollbacks"
tags:
- "Ocean Automatic Rightsizing"
parameters:
- $ref: "../parameters/oceanId.yaml"
- $ref: "../parameters/clusterIdentifier.yaml"
- $ref: "../../../../commons/parameters/accountId.yaml"
requestBody:
required: true
content:
application/json:
schema:
allOf:
- $ref: "../schemas/oceanRightsizingRollbacksAcknowledgeRequest.yaml"
responses:
200:
description: Ocean Rightsizing Acknowledge Rollbacks Response
content:
application/json:
schema:
allOf:
- $ref: "../../../../commons/schemas/responseWrapper.yaml"
400:
description: "Bad Request"
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
get:
summary: "List Ocean Rightsizing Rollbacks"
description: List the rightsizing rollback for ocean cluster.
operationId: "oceanRightsizingRollbackList"
tags:
- "Ocean Automatic Rightsizing"
parameters:
- $ref: "../parameters/oceanId.yaml"
- $ref: "../../../../commons/parameters/accountId.yaml"

responses:
200:
$ref: "../responses/oceanRightsizingRollbacksResponse.yaml"
400:
description: "Bad Request"
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
description: Ocean Rightsizing Rollbacks Response
content:
application/json:
schema:
allOf:
- $ref: "../../../../commons/schemas/responseItemWrapper.yaml"
- type: object
properties:
request:
type: object
properties:
url:
example: "/ocean/{oceanId}/rightSizing/rollbacks"
method:
example: "GET"
response:
type: object
properties:
items:
type: array
items:
type: object
properties:
clusterIdentifier:
type: string
description: The cluster identifier
example: test-k8s
namespace:
type: string
description: The namespace of the workload
example: kube-system
resourceType:
type: string
description: The type of the resource
example: deployment
resourceName:
type: string
description: The name of the resource
example: resource-name
rollbackType:
type: string
description: The type of the rollback
example: OUT_OF_MEMORY
rollbackTime:
type: string
format: date-time
description: The time of the rollback
example: 2024-11-01T10:50:29.000+0000
cpuAtRollback:
type: number
description: The cpu at the time of the rollback
example: 0.23
cpuAfterRollback:
type: number
description: The cpu after the rollback
example: 0.33
memoryAtRollback:
type: number
description: The memory at the time of the rollback
example: 128
memoryAfterRollback:
type: number
description: The memory after the rollback
example: 185
kind:
example: "mcs:ocean:rightsizing:rollback"
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
type: object
properties:
acknowledgeRollbacks:
type: array
items:
type: object
properties:
namespace:
type: string
description: The namespace of the workload
example: kube-system
resourceType:
type: string
description: The type of the resource
example: deployment
resourceName:
type: string
description: The name of the resource
example: resource-name
5 changes: 5 additions & 0 deletions api/spot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -929,6 +929,10 @@ paths:
$ref: services/ocean/rightsizing/paths/oceanRightsizingRuleDetachment.yaml
/ocean/{oceanId}/rightSizing/recommendations:
$ref: services/ocean/rightsizing/paths/oceanRightsizingRecommendations.yaml
/ocean/{oceanId}/rightSizing/rollbacks:
$ref: services/ocean/rightsizing/paths/oceanRightsizingRollbacks.yaml
/ocean/{oceanId}/rightSizing/rollbacks/acknowledge:
$ref: services/ocean/rightsizing/paths/oceanRightsizingAcknowledgeRollbacks.yaml
/security/v1/compliances:
$ref: services/security/v1/paths/compliances.yaml
/security/v1/compliances/count:
Expand All @@ -945,3 +949,4 @@ paths:
$ref: services/security/v1/paths/rules.yaml
/security/v1/misconfigurations/rules/count:
$ref: services/security/v1/paths/rules_count.yaml

0 comments on commit b22b9cd

Please sign in to comment.