Skip to content

Commit

Permalink
Merge pull request #35 from vmware/update-iaas-swagger
Browse files Browse the repository at this point in the history
Update iaas swagger to 8.4
  • Loading branch information
Prativa20 committed May 26, 2021
2 parents 2c304b4 + 466ae11 commit 00402c2
Show file tree
Hide file tree
Showing 1,064 changed files with 44,522 additions and 12,474 deletions.
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
.PHONY: all swagger modified update update-blueprint update-catalog-deployment update-iaas update-content clean
SWAGGER_VERSION=0.25.0
SWAGGER_VERSION=0.27.0
SWAGGER_ENDPOINT ?= api.mgmt.cloud.vmware.com

all:
go build -o sdk-test
Expand All @@ -23,16 +24,16 @@ modified:
update: update-blueprint update-catalog-deployment update-iaas update-content

update-blueprint:
curl 'https://api.mgmt.cloud.vmware.com/blueprint/api/swagger/swagger-api-docs?group=2019-09-12' | python3 -mjson.tool > swagger/vra-blueprint.json
curl --insecure 'https://${SWAGGER_ENDPOINT}/blueprint/api/swagger/swagger-api-docs?group=2019-09-12' | python3 -mjson.tool > swagger/vra-blueprint.json

update-catalog-deployment:
curl 'https://api.mgmt.cloud.vmware.com/deployment/api/swagger/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-catalog-deployment.json
curl --insecure 'https://${SWAGGER_ENDPOINT}/deployment/api/swagger/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-catalog-deployment.json

update-iaas:
curl 'https://api.mgmt.cloud.vmware.com/iaas/api/swagger/swagger/v2/api-docs?group=iaas' | python3 -mjson.tool > swagger/vra-iaas.json
curl --insecure 'https://${SWAGGER_ENDPOINT}/iaas/api/swagger/swagger/v2/api-docs?group=iaas' | python3 -mjson.tool > swagger/vra-iaas.json

update-content:
curl 'https://api.mgmt.cloud.vmware.com/content/api/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-content.json
curl --insecure 'https://${SWAGGER_ENDPOINT}/content/api/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-content.json

clean:
rm swagger/vra-combined.json
99 changes: 50 additions & 49 deletions hack/fix_vra_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ def add_filter_params(swagger):
param_list.insert(0, filter_spec)


# To add a response code in the swagger, enable this method and add the apis
def add_204(swagger):
paths = [
('/iaas/api/block-devices/{id}', 'delete'),
('/iaas/api/machines/{id}/disks/{id1}', 'delete'),
]

Expand All @@ -64,12 +64,12 @@ def add_204(swagger):
responses['204'] = {"description": "No Content"}


# Enable this to list of paths, operations, and status code to update the response model
# add the apis that needs to be updated
def change_response_model(swagger):
# List of paths, operations, and status code to update the response model
paths = [
('/iaas/api/machines/{id}/disks', 'post', '200', '#/definitions/RequestTracker'),
('/iaas/api/machines/{id}/disks/{id1}', 'delete', '202', '#/definitions/RequestTracker'),
('/iaas/api/block-devices/{id}/snapshots/{id1}', 'get', '200', '#/definitions/DiskSnapshot'),
]

# Update the needed paths
Expand Down Expand Up @@ -142,12 +142,6 @@ def add_security(swagger):
for method in param_list:
if 'security' not in swagger['paths'][p][method]:
swagger['paths'][p][method]['security'] = bearer_security


def add_network_ip_range_return_code(swagger):
path = '/iaas/api/network-ip-ranges'
responses = swagger['paths'][path]['post']['responses']
responses['201'] = responses['202']


def add_blockdevice_persistent(swagger):
Expand Down Expand Up @@ -179,52 +173,71 @@ def add_blockdevice_delete_purge(swagger):
})


def add_blockdevice_resize(swagger):
bd = swagger['paths']['/iaas/api/block-devices/{id}']
if 'post' in bd:
return
bd['post'] = {
"summary": "Resize BlockDevice",
# This needs to be removed after the bug https://jira.eng.vmware.com/browse/VCOM-25699 is fixed
def get_blockdevices_add_dollar_filter(swagger):
bd = swagger['paths']['/iaas/api/block-devices']
bd['get'] = {
"summary": "Get BlockDevices",
"produces": [
"application/json",
"app/json"
],
"description": "Resize operation on block device.",
"operationId": "resizeBlockDevice",
"description": "Get all BlockDevices",
"operationId": "getBlockDevices",
"responses": {
"202": {
"200": {
"schema": {
"$ref": "#/definitions/RequestTracker"
"$ref": "#/definitions/BlockDeviceResult"
},
"description": "successful operation"
},
"204": {
"description": "No Content"
},
"403": {
"schema": {
"$ref": "#/definitions/ServiceErrorResponse"
},
"description": "Forbidden"
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The ID of the block device.",
"in": "query",
"name": "apiVersion",
"description": "The version of the API in yyyy-MM-dd format (UTC). For versioning information refer to /iaas/api/about",
"type": "string",
"required": True
"required": False
},
{
"in": "query",
"name": "capacityInGB",
"format": "int32",
"description": "Resize Capacity in GB",
"name": "$top",
"description": "Number of records you want to get.",
"type": "integer",
"required": True
"required": False
},
{
"in": "query",
"name": "apiVersion",
"description": "The version of the API in yyyy-MM-dd format (UTC). For versioning information please refer to /iaas/api/about",
"name": "$skip",
"description": "Number of records you want to skip.",
"type": "integer",
"required": False
},
{
"in": "query",
"name": "$count",
"description": "Flag which when specified shows the total number of records. If the collection has a filter it shows the number of records matching the filter.",
"type": "boolean",
"required": False
},
{
"in": "query",
"name": "$select",
"description": "Select a subset of properties to include in the response.",
"type": "string",
"required": False
},
{
"in": "query",
"name": "$filter",
"description": "Filter the results by a specified predicate expression. Operators: eq, ne, and, or.",
"type": "string",
"required": False
}
Expand Down Expand Up @@ -265,15 +278,6 @@ def add_400_bad_request(swagger):
}


def change_operationId_for_get_fabric_compute(swagger):
# Remove when VCOM-16823 is fixed.
path = '/iaas/api/fabric-computes/{id}'
fc = swagger['paths'][path]['get']
if fc['operationId'] == 'getFabricCompute':
return
fc['operationId'] = 'getFabricCompute'


def add_default_value_to_boolean_properties(swagger):
# Update following definition properties of type boolean with specified default value.
paths = [
Expand All @@ -293,7 +297,6 @@ def change_response_code(swagger):
# List of paths, operations, current status code, and new status code to update the response model
paths = [
('/iaas/api/block-devices/{id}/operations/snapshots', 'post', '200', '202'),
('/iaas/api/block-devices/{id}/snapshots/{id1}', 'delete', '200', '202'),
]

# Update the needed paths
Expand Down Expand Up @@ -327,20 +330,18 @@ if __name__ == "__main__":
swagger = json.loads(open(filename).read())

add_filter_params(swagger)
add_204(swagger)
change_response_model(swagger)

add_network_ip_range_return_code(swagger)
change_operationId_for_get_fabric_compute(swagger)
# add_204(swagger)
# change_response_model(swagger)

add_blockdevice_persistent(swagger)
add_blockdevice_delete_purge(swagger)
add_blockdevice_resize(swagger)
# This needs to be removed after the bug https://jira.eng.vmware.com/browse/VCOM-25699 is fixed
get_blockdevices_add_dollar_filter(swagger)
add_404_not_found(swagger)
add_400_bad_request(swagger)

add_default_value_to_boolean_properties(swagger)
change_response_code(swagger)
# change_response_code(swagger)

add_error_definition(swagger)

Expand Down
45 changes: 30 additions & 15 deletions pkg/client/about/about_client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 00402c2

Please sign in to comment.