Skip to content

Commit

Permalink
Update APIs to vRA 8.6.2 (#44)
Browse files Browse the repository at this point in the history
* Update swagger files to vRA v8.6.2
* Upgrade go-swagger to v0.29.0
* Upgrade golang dependencies
* Add CMX Service API swagger
* Remove security parameters from blueprint and iaas swagger files
  • Loading branch information
frodenas authored Jan 25, 2022
1 parent ca028d0 commit f8f241c
Show file tree
Hide file tree
Showing 1,505 changed files with 155,254 additions and 94,474 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ swagger/vra-iaas-fixed.json
swagger/vra-catalog-deployment-fixed.json
swagger/vra-pipeline-fixed.json
swagger/vra-project-fixed.json
swagger/vra-cmx-fixed.json
sdk-test
tokens
examples/cloud_account/cloud_account
16 changes: 10 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: all swagger modified update update-blueprint update-catalog-deployment update-iaas update-content update-pipeline update-project clean
SWAGGER_VERSION=0.27.0
.PHONY: all swagger modified update update-blueprint update-catalog-deployment update-iaas update-content update-pipeline update-project update-cmx clean
SWAGGER_VERSION=0.29.0
SWAGGER_ENDPOINT ?= api.mgmt.cloud.vmware.com

all:
Expand All @@ -12,7 +12,8 @@ swagger: check-swagger
./hack/fix_catalog_deployment_swagger
./hack/fix_pipeline_swagger
./hack/fix_project_swagger
swagger mixin -c=1 swagger/vra-iaas-fixed.json swagger/vra-blueprint-fixed.json swagger/vra-catalog-deployment-fixed.json swagger/vra-content.json swagger/vra-pipeline-fixed.json swagger/vra-project-fixed.json | python3 -mjson.tool > swagger/vra-combined.json
./hack/fix_cmx_swagger
swagger mixin -c=1 swagger/vra-iaas-fixed.json swagger/vra-blueprint-fixed.json swagger/vra-catalog-deployment-fixed.json swagger/vra-content.json swagger/vra-pipeline-fixed.json swagger/vra-project-fixed.json swagger/vra-cmx-fixed.json | python3 -mjson.tool > swagger/vra-combined.json
./hack/fix_vra_swagger --omit-security
swagger generate client -f swagger/vra-combined.json -t pkg
./hack/fixup.sh
Expand All @@ -23,16 +24,16 @@ check-swagger:
modified:
git ls-files --modified | xargs git add

update: update-blueprint update-catalog-deployment update-iaas update-content update-pipeline update-project
update: update-blueprint update-catalog-deployment update-iaas update-content update-pipeline update-project update-cmx

update-blueprint:
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 --insecure 'https://${SWAGGER_ENDPOINT}/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=2020-08-25' | python3 -mjson.tool > swagger/vra-catalog-deployment.json

update-iaas:
curl --insecure 'https://${SWAGGER_ENDPOINT}/iaas/api/swagger/swagger/v2/api-docs?group=iaas' | python3 -mjson.tool > swagger/vra-iaas.json
curl --insecure 'https://${SWAGGER_ENDPOINT}/iaas/api/swagger?apiVersion=2021-07-15' | python3 -mjson.tool > swagger/vra-iaas.json

update-content:
curl --insecure 'https://${SWAGGER_ENDPOINT}/content/api/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-content.json
Expand All @@ -43,6 +44,9 @@ update-pipeline:
update-project:
curl --insecure 'https://${SWAGGER_ENDPOINT}/project/api/swagger/v2/api-docs?group=2019-01-15' | python3 -mjson.tool > swagger/vra-project.json

update-cmx:
curl --insecure 'https://${SWAGGER_ENDPOINT}/cmx/v2/api-docs' | python3 -mjson.tool > swagger/vra-cmx.json

test:
go build -o sdk-test

Expand Down
15 changes: 9 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@ module github.com/vmware/vra-sdk-go

require (
github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect
github.com/go-openapi/errors v0.20.0
github.com/go-openapi/runtime v0.19.29
github.com/go-openapi/strfmt v0.20.1
github.com/go-openapi/analysis v0.21.1 // indirect
github.com/go-openapi/errors v0.20.1
github.com/go-openapi/runtime v0.21.0
github.com/go-openapi/strfmt v0.21.1
github.com/go-openapi/swag v0.19.15
github.com/go-openapi/validate v0.19.11
github.com/go-openapi/validate v0.20.3
github.com/go-stack/stack v1.8.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mitchellh/mapstructure v1.4.1 // indirect
go.mongodb.org/mongo-driver v1.7.0 // indirect
github.com/mitchellh/mapstructure v1.4.3 // indirect
go.mongodb.org/mongo-driver v1.8.2 // indirect
golang.org/x/net v0.0.0-20220111093109-d55c255bac03 // indirect
)

go 1.14
101 changes: 80 additions & 21 deletions go.sum

Large diffs are not rendered by default.

21 changes: 19 additions & 2 deletions hack/fix_blueprint_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ new_filename = "swagger/vra-blueprint-fixed.json"

def replace_value(d, k, v, new):
if k in d and d[k] == v:
print(d[k])
print("found one")
d[k] = new
for child in d.values():
if isinstance(child, dict):
Expand All @@ -33,15 +31,34 @@ def rename_blueprint_models(swagger):
replace_value(swagger, "$ref", oldRef, newRef)


def remove_global_security(swagger):
if 'securityDefinitions' in swagger:
del swagger['securityDefinitions']


# See https://jira.eng.vmware.com/browse/TCS-4017 for context
def remove_security(swagger):
for p in swagger['paths']:
param_list = swagger['paths'][p]
for method in param_list:
if 'security' in swagger['paths'][p][method]:
del swagger['paths'][p][method]['security']


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--omit-security', action='store_false')
args = parser.parse_args()

# read in the swagger spec
swagger = json.loads(open(old_filename).read())

rename_blueprint_models(swagger)

if args.omit_security:
remove_global_security(swagger)
remove_security(swagger)

# Overwrite the swagger spec
f = open(new_filename, "w")
f.write(json.dumps(swagger, sort_keys=False, indent=2))
Expand Down
2 changes: 0 additions & 2 deletions hack/fix_catalog_deployment_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ def add_apiVersion(swagger):

def replace_value(d, k, v, new):
if k in d and d[k] == v:
print(d[k])
print("found one")
d[k] = new
for child in d.values():
if isinstance(child, dict):
Expand Down
53 changes: 53 additions & 0 deletions hack/fix_cmx_swagger
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3

import argparse
import json


# This is the location of the CMX swagger
old_filename = "swagger/vra-cmx.json"
new_filename = "swagger/vra-cmx-fixed.json"


def replace_value(d, k, v, new):
if k in d and d[k] == v:
d[k] = new
for child in d.values():
if isinstance(child, dict):
replace_value(child, k, v, new)
elif isinstance(child, list):
for i in child:
if isinstance(i, dict):
replace_value(i, k, v, new)


def remove_global_security(swagger):
if 'securityDefinitions' in swagger:
del swagger['securityDefinitions']


# See https://jira.eng.vmware.com/browse/TCS-4017 for context
def remove_security(swagger):
for p in swagger['paths']:
param_list = swagger['paths'][p]
for method in param_list:
if 'security' in swagger['paths'][p][method]:
del swagger['paths'][p][method]['security']


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--omit-security', action='store_false')
args = parser.parse_args()

# read in the swagger spec
swagger = json.loads(open(old_filename).read())

if args.omit_security:
remove_global_security(swagger)
remove_security(swagger)

# Overwrite the swagger spec
f = open(new_filename, "w")
f.write(json.dumps(swagger, sort_keys=False, indent=2))
f.write('\n')
21 changes: 19 additions & 2 deletions hack/fix_iaas_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ new_filename = "swagger/vra-iaas-fixed.json"

def replace_value(d, k, v, new):
if k in d and d[k] == v:
print(d[k])
print("found one")
d[k] = new
for child in d.values():
if isinstance(child, dict):
Expand All @@ -39,15 +37,34 @@ def rename_iaas_models(swagger):
replace_value(swagger, "$ref", oldRef, newRef)


def remove_global_security(swagger):
if 'securityDefinitions' in swagger:
del swagger['securityDefinitions']


# See https://jira.eng.vmware.com/browse/TCS-4017 for context
def remove_security(swagger):
for p in swagger['paths']:
param_list = swagger['paths'][p]
for method in param_list:
if 'security' in swagger['paths'][p][method]:
del swagger['paths'][p][method]['security']


if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--omit-security', action='store_false')
args = parser.parse_args()

# read in the swagger spec
swagger = json.loads(open(old_filename).read())

rename_iaas_models(swagger)

if args.omit_security:
remove_global_security(swagger)
remove_security(swagger)

# Overwrite the swagger spec
f = open(new_filename, "w")
f.write(json.dumps(swagger, sort_keys=False, indent=2))
Expand Down
2 changes: 0 additions & 2 deletions hack/fix_project_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ new_filename = "swagger/vra-project-fixed.json"

def replace_value(d, k, v, new):
if k in d and d[k] == v:
print(d[k])
print("found one")
d[k] = new
for child in d.values():
if isinstance(child, dict):
Expand Down
13 changes: 11 additions & 2 deletions hack/fix_vra_swagger
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,16 @@ def add_filter_params(swagger):
# To add a response code in the swagger, enable this method and add the apis
def add_204(swagger):
paths = [
('/iaas/api/machines/{id}/disks/{id1}', 'delete'),
('/iaas/api/machines/{id}/disks/{diskId}', 'delete'),
# //https://jira.eng.vmware.com/browse/VRAE-10681
('/iaas/api/cloud-accounts-azure/{id}', 'delete'),
('/iaas/api/cloud-accounts-aws/{id}', 'delete'),
('/iaas/api/cloud-accounts-gcp/{id}', 'delete'),
('/iaas/api/cloud-accounts-nsx-t/{id}', 'delete'),
('/iaas/api/cloud-accounts-nsx-v/{id}', 'delete'),
('/iaas/api/cloud-accounts-vcf/{id}', 'delete'),
('/iaas/api/cloud-accounts-vmc/{id}', 'delete'),
('/iaas/api/cloud-accounts-vsphere/{id}', 'delete'),
]

# Update the needed paths
Expand Down Expand Up @@ -360,7 +369,7 @@ if __name__ == "__main__":
swagger = json.loads(open(filename).read())

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

add_blockdevice_persistent(swagger)
Expand Down
4 changes: 3 additions & 1 deletion 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 f8f241c

Please sign in to comment.