diff --git a/Gopkg.lock b/Gopkg.lock index 6560aec38..b77022a7a 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -301,9 +301,10 @@ revision = "611e8accdfc92c4187d399e95ce826046d4c8d73" [[projects]] - digest = "1:27f22f5f78d7258edae2bedc36f7abb2b3224044e0d7fe900cce272b9b857d1c" + digest = "1:5e14df5b9539151b485eeb3ebea90a2823347516732978b0911ff17acea2842c" name = "github.com/golang/mock" packages = [ + "gomock", "mockgen", "mockgen/model", ] @@ -774,14 +775,6 @@ revision = "ba968bfe8b2f7e042a574c888954fccecfa385b4" version = "v0.8.1" -[[projects]] - digest = "1:0028cb19b2e4c3112225cd871870f2d9cf49b9b4276531f03438a88e94be86fe" - name = "github.com/pmezard/go-difflib" - packages = ["difflib"] - pruneopts = "UT" - revision = "792786c7400a136282c1664665ae0a8db921c6c2" - version = "v1.0.0" - [[projects]] digest = "1:274f67cb6fed9588ea2521ecdac05a6d62a8c51c074c1fccc6a49a40ba80e925" name = "github.com/satori/go.uuid" @@ -822,14 +815,6 @@ revision = "2e9d26c8c37aae03e3f9d4e90b7116f5accb7cab" version = "v1.0.5" -[[projects]] - digest = "1:8548c309c65a85933a625be5e7d52b6ac927ca30c56869fae58123b8a77a75e1" - name = "github.com/stretchr/testify" - packages = ["assert"] - pruneopts = "UT" - revision = "221dbe5ed46703ee255b1da0dec05086f5035f62" - version = "v1.4.0" - [[projects]] digest = "1:5a1cf4e370bc86137b58da2ae065e76526d32b11f62a7665f36dbd5f41fa95ff" name = "github.com/ugorji/go" @@ -1396,8 +1381,10 @@ "github.com/Azure/go-autorest/autorest/azure", "github.com/Azure/go-autorest/autorest/azure/auth", "github.com/Azure/go-autorest/autorest/to", + "github.com/Azure/go-autorest/tracing", "github.com/alvaroloes/enumer", "github.com/apparentlymart/go-cidr/cidr", + "github.com/golang/mock/gomock", "github.com/golang/mock/mockgen", "github.com/gorilla/mux", "github.com/jim-minter/go-cosmosdb/cmd/gencosmosdb", @@ -1430,7 +1417,6 @@ "github.com/satori/go.uuid", "github.com/shurcooL/vfsgen", "github.com/sirupsen/logrus", - "github.com/stretchr/testify/assert", "github.com/ugorji/go/codec", "golang.org/x/crypto/ssh", "golang.org/x/tools/cmd/goimports", diff --git a/Gopkg.toml b/Gopkg.toml index 332997c36..30be7cceb 100644 --- a/Gopkg.toml +++ b/Gopkg.toml @@ -13,6 +13,10 @@ required = [ name = "github.com/Azure/azure-sdk-for-go" version = "36.2.0" +[[constraint]] + name = "github.com/golang/mock" + version = "1.3.1" + [[constraint]] name = "github.com/gorilla/mux" version = "1.7.3" @@ -73,11 +77,3 @@ required = [ [[prune.project]] name = "github.com/openshift/installer" unused-packages = false - -[[constraint]] - name = "github.com/golang/mock" - version = "1.3.1" - -[[constraint]] - name = "github.com/stretchr/testify" - version = "1.4.0" diff --git a/Makefile b/Makefile index 27aca295c..5bfbb052b 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,21 @@ rp: clean: rm -f rp +client: + go generate ./... + rm -rf pkg/client + sudo docker run \ + -v $(PWD)/pkg/client:/github.com/jim-minter/rp/pkg/client \ + -v $(PWD)/swagger:/swagger \ + azuresdk/autorest \ + --go \ + --namespace=redhatopenshift \ + --input-file=/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json \ + --output-folder=/github.com/jim-minter/rp/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift + + sudo chown -R $(USER):$(USER) pkg/client + go run ./vendor/golang.org/x/tools/cmd/goimports -w -local=github.com/jim-minter/rp pkg/client + image: rp docker build -t rp:$(COMMIT) . @@ -22,17 +37,4 @@ test: go vet ./... go test ./... -generate-sdk: - go generate ./... - # Due to orering https://github.com/Azure/autorest.go/blob/3f9bdd60fd7a7c8740bbe3ec986f583f7ffa5fbd/src/Model/CodeModelGo.cs#L120-L141 - # package FQDN are either hardcoded to azure sdk or set wrong. For this we do - # replace in the end - podman run --privileged --workdir=/go/src -it -v $(GOPATH):/go --entrypoint autorest \ - azuresdk/autorest ./github.com/jim-minter/rp/rest-api-spec/redhatopenshift/resource-manager/readme.md \ - --go --go-sdks-folder=./github.com/jim-minter/rp/pkg/sdk --multiapi \ - --use=@microsoft.azure/autorest.go@~2.1.137 --use-onever --verbose - # HACK to align pkg imports when running in non default repository - find . -type f -name "*.go" -exec sed -i 's/go\/src\/github.com/github.com/g' {} + - -.PHONY: clean generate-sdk image rp test - +.PHONY: rp clean client image test diff --git a/docs/build-sdk.md b/docs/build-sdk.md deleted file mode 100644 index 45d4cc7f6..000000000 --- a/docs/build-sdk.md +++ /dev/null @@ -1,54 +0,0 @@ -# Dev golang SDK build - -This document explains how to generate SDK version - -## Dev SDK build - -1. Generate new api swagger spec - ``` - export APIVERSION=v20191231preview - go run ./hack/swagger/swagger.go -i=$APIVERSION -o pkg/api/${APIVERSION}/swagger.json - or - make generate - ``` - -1. Create required folder sturcture with example in `rest-api-spec` - - ``` - mkdir -p rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview - # copy generated swagger spec by updating generate.go in each api subfolder - ``` - -1. Update all `readme` files files as they are used to generate SDK - -1. Generate dev SDK - - ``` - make generate-sdk - ``` - -## Upstream GoLang build - -1. Clone `azure-rest-api-spec` and azure-sdk-for-go git repositories - - ``` - git clone https://github.com/Azure/azure-rest-api-specs - git clone https://github.com/Azure/azure-sdk-for-go - ``` - -1. Run code generation - - ``` - podman run --privileged -it -v $GOPATH:/go --entrypoint autorest \ - azuresdk/autorest /go/src/github.com/Azure/azure-rest-api-specs-pr/specification/redhatopenshift/resource-manager/readme.md \ - --go --go-sdks-folder=/go/src/github.com/Azure/azure-sdk-for-go/ --multiapi \ - --use=@microsoft.azure/autorest.go@~2.1.137 --use-onever --verbose - ``` - -1. Go SDK will be generate inside `azure-sdk-for-go` project - -## Useful links - -* https://github.com/Azure/adx-documentation-pr/wiki/SDK-generation - -* https://github.com/Azure/adx-documentation-pr diff --git a/hack/swagger/swagger.go b/hack/swagger/swagger.go index 1d4a256db..d20640b38 100644 --- a/hack/swagger/swagger.go +++ b/hack/swagger/swagger.go @@ -7,19 +7,13 @@ import ( ) var ( - outputFile = flag.String("o", "", "output file") - inputVersion = flag.String("i", "", "api version for input [example v20190211preview]") + outputFile = flag.String("o", "", "output file") ) func main() { flag.Parse() - err := swagger.ValidateVersion(*inputVersion) - if err != nil { - panic(err) - } - - if err := swagger.Run(*outputFile, *inputVersion); err != nil { + if err := swagger.Run(*outputFile); err != nil { panic(err) } } diff --git a/pkg/api/v20191231preview/generate.go b/pkg/api/v20191231preview/generate.go index 3b7756533..e82ca4ebe 100644 --- a/pkg/api/v20191231preview/generate.go +++ b/pkg/api/v20191231preview/generate.go @@ -1,4 +1,3 @@ -//go:generate go run ../../../hack/swagger -o swagger.json -i $GOPACKAGE -//go:generate cp swagger.json ../../../rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json +//go:generate go run ../../../hack/swagger -o ../../../swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json package v20191231preview diff --git a/pkg/api/v20191231preview/swagger.json b/pkg/api/v20191231preview/swagger.json deleted file mode 100644 index a789e2926..000000000 --- a/pkg/api/v20191231preview/swagger.json +++ /dev/null @@ -1,678 +0,0 @@ -{ - "swagger": "2.0", - "info": { - "title": "Azure Red Hat OpenShift", - "description": "Rest API for Azure Red Hat OpenShift", - "version": "2019-12-31-preview" - }, - "host": "management.azure.com", - "schemes": [ - "https" - ], - "consumes": [ - "application/json" - ], - "produces": [ - "application/json" - ], - "paths": { - "/providers/Microsoft.RedHatOpenShift/operations": { - "get": { - "tags": [ - "Operations" - ], - "summary": "Lists all of the available RP operations.", - "description": "Lists all of the available RP operations. The operation returns the operations.", - "operationId": "Operations_List", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OperationList" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters": { - "get": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Lists OpenShift clusters in the specified subscription.", - "description": "Lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift cluster.", - "operationId": "OpenShiftClusters_List", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftClusterList" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters": { - "get": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Lists OpenShift clusters in the specified subscription and resource group.", - "description": "Lists OpenShift clusters in the specified subscription and resource group. The operation returns properties of each OpenShift cluster.", - "operationId": "OpenShiftClusters_ListByResourceGroup", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftClusterList" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - } - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}": { - "get": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Gets a OpenShift cluster with the specified subscription, resource group and resource name.", - "description": "Gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster.", - "operationId": "OpenShiftClusters_Get", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - }, - { - "name": "resourceName", - "in": "path", - "description": "The name of the OpenShift cluster resource.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - } - }, - "put": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name.", - "description": "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster.", - "operationId": "OpenShiftClusters_Create", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - }, - { - "name": "resourceName", - "in": "path", - "description": "The name of the OpenShift cluster resource.", - "required": true, - "type": "string" - }, - { - "name": "parameters", - "in": "body", - "description": "The OpenShift cluster resource.", - "required": true, - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - }, - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - }, - "x-ms-long-running-operation": true - }, - "delete": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Deletes a OpenShift cluster with the specified subscription, resource group and resource name.", - "description": "Deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns nothing.", - "operationId": "OpenShiftClusters_Delete", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - }, - { - "name": "resourceName", - "in": "path", - "description": "The name of the OpenShift cluster resource.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK" - }, - "204": { - "description": "No Content" - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - }, - "x-ms-long-running-operation": true - }, - "patch": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name.", - "description": "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns properties of a OpenShift cluster.", - "operationId": "OpenShiftClusters_Update", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - }, - { - "name": "resourceName", - "in": "path", - "description": "The name of the OpenShift cluster resource.", - "required": true, - "type": "string" - }, - { - "name": "parameters", - "in": "body", - "description": "The OpenShift cluster resource.", - "required": true, - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - }, - "201": { - "description": "Created", - "schema": { - "$ref": "#/definitions/OpenShiftCluster" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - }, - "x-ms-long-running-operation": true - } - }, - "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/credentials": { - "post": { - "tags": [ - "OpenShiftClusters" - ], - "summary": "Gets credentials of a OpenShift cluster with the specified subscription, resource group and resource name.", - "description": "Gets credentials of a OpenShift cluster with the specified subscription, resource group and resource name. The operation returns the credentials.", - "operationId": "OpenShiftClusters_GetCredentials", - "parameters": [ - { - "$ref": "#/parameters/ApiVersionParameter" - }, - { - "$ref": "#/parameters/SubscriptionIdParameter" - }, - { - "name": "resourceGroupName", - "in": "path", - "description": "The name of the resource group.", - "required": true, - "type": "string" - }, - { - "name": "resourceName", - "in": "path", - "description": "The name of the OpenShift cluster resource.", - "required": true, - "type": "string" - } - ], - "responses": { - "200": { - "description": "OK", - "schema": { - "$ref": "#/definitions/OpenShiftClusterCredentials" - } - }, - "default": { - "description": "Error response describing why the operation failed. If the resource doesn't exist, 404 (Not Found) is returned. If any of the input parameters is wrong, 400 (Bad Request) is returned.", - "schema": { - "$ref": "#/definitions/CloudError" - } - } - } - } - } - }, - "definitions": { - "CloudError": { - "description": "CloudError represents a cloud error.", - "properties": { - "error": { - "$ref": "#/definitions/CloudErrorBody", - "description": "An error response from the service." - } - } - }, - "CloudErrorBody": { - "description": "CloudErrorBody represents the body of a cloud error.", - "properties": { - "code": { - "description": "An identifier for the error. Codes are invariant and are intended to be consumed programmatically.", - "type": "string" - }, - "message": { - "description": "A message describing the error, intended to be suitable for display in a user interface.", - "type": "string" - }, - "target": { - "description": "The target of the particular error. For example, the name of the property in error.", - "type": "string" - }, - "details": { - "description": "A list of additional details about the error.", - "type": "array", - "items": { - "$ref": "#/definitions/CloudErrorBody" - } - } - } - }, - "Display": { - "description": "Display represents the display details of an operation.", - "properties": { - "provider": { - "description": "Friendly name of the resource provider.", - "type": "string" - }, - "resource": { - "description": "Resource type on which the operation is performed.", - "type": "string" - }, - "operation": { - "description": "Operation type: read, write, delete, listKeys/action, etc.", - "type": "string" - }, - "description": { - "description": "Friendly name of the operation.", - "type": "string" - } - } - }, - "MasterProfile": { - "description": "MasterProfile represents a master profile.", - "properties": { - "vmSize": { - "$ref": "#/definitions/VMSize", - "description": "The size of the master VMs (immutable)." - }, - "subnetId": { - "description": "The Azure resource ID of the worker subnet (immutable).", - "type": "string" - } - } - }, - "NetworkProfile": { - "description": "NetworkProfile represents a network profile.", - "properties": { - "podCidr": { - "description": "The CIDR used for OpenShift/Kubernetes Pods (immutable).", - "type": "string" - }, - "serviceCidr": { - "description": "The CIDR used for OpenShift/Kubernetes Services (immutable).", - "type": "string" - } - } - }, - "OpenShiftCluster": { - "description": "OpenShiftCluster represents an Azure Red Hat OpenShift cluster.", - "properties": { - "id": { - "description": "The resource ID (immutable).", - "type": "string", - "readOnly": true - }, - "name": { - "description": "The resource name (immutable).", - "type": "string", - "readOnly": true - }, - "type": { - "description": "The resource type (immutable).", - "type": "string", - "readOnly": true - }, - "location": { - "description": "The resource location (immutable).", - "type": "string", - "x-ms-mutability": [ - "create", - "read" - ] - }, - "tags": { - "$ref": "#/definitions/Tags", - "description": "The resource tags." - }, - "properties": { - "$ref": "#/definitions/Properties", - "description": "The cluster properties.", - "x-ms-client-flatten": true - } - }, - "x-ms-azure-resource": true - }, - "OpenShiftClusterCredentials": { - "description": "OpenShiftClusterCredentials represents an OpenShift cluster's credentials", - "properties": { - "kubeadminPassword": { - "description": "The password for the kubeadmin user", - "type": "string" - } - } - }, - "OpenShiftClusterList": { - "description": "OpenShiftClusterList represents a list of OpenShift clusters.", - "properties": { - "value": { - "description": "The list of OpenShift clusters.", - "type": "array", - "items": { - "$ref": "#/definitions/OpenShiftCluster" - } - } - } - }, - "Operation": { - "description": "Operation represents an operation.", - "properties": { - "name": { - "description": "Operation name: {provider}/{resource}/{operation}.", - "type": "string" - }, - "display": { - "$ref": "#/definitions/Display", - "description": "The object that describes the operation." - } - } - }, - "OperationList": { - "description": "OperationList represents an operation list.", - "properties": { - "value": { - "description": "List of operations supported by the resource provider.", - "type": "array", - "items": { - "$ref": "#/definitions/Operation" - } - } - } - }, - "Properties": { - "description": "Properties represents an OpenShift cluster's properties.", - "properties": { - "provisioningState": { - "$ref": "#/definitions/ProvisioningState", - "description": "The cluster provisioning state (immutable)." - }, - "servicePrincipalProfile": { - "$ref": "#/definitions/ServicePrincipalProfile", - "description": "The cluster service principal profile." - }, - "networkProfile": { - "$ref": "#/definitions/NetworkProfile", - "description": "The cluster network profile." - }, - "masterProfile": { - "$ref": "#/definitions/MasterProfile", - "description": "The cluster master profile." - }, - "workerProfiles": { - "description": "The cluster worker profiles.", - "type": "array", - "items": { - "$ref": "#/definitions/WorkerProfile" - } - }, - "apiserverUrl": { - "description": "The URL to access the cluster API server (immutable).", - "type": "string" - }, - "consoleUrl": { - "description": "The URL to access the cluster console (immutable).", - "type": "string" - } - } - }, - "ProvisioningState": { - "description": "ProvisioningState represents a provisioning state.", - "enum": [ - "Creating", - "Deleting", - "Failed", - "Succeeded", - "Updating" - ], - "type": "string" - }, - "ServicePrincipalProfile": { - "description": "ServicePrincipalProfile represents a service principal profile.", - "properties": { - "clientId": { - "description": "The client ID used for the cluster", - "type": "string" - }, - "clientSecret": { - "description": "The client secret used for the cluster", - "type": "string" - } - } - }, - "Tags": { - "description": "Tags represents an OpenShift cluster's tags.", - "type": "object", - "additionalProperties": { - "type": "string" - } - }, - "VMSize": { - "description": "VMSize represents a VM size.", - "enum": [ - "Standard_D2s_v3", - "Standard_D4s_v3", - "Standard_D8s_v3" - ], - "type": "string" - }, - "WorkerProfile": { - "description": "WorkerProfile represents a worker profile.", - "properties": { - "name": { - "description": "The worker profile name. Must be \"worker\" (immutable).", - "type": "string" - }, - "vmSize": { - "$ref": "#/definitions/VMSize", - "description": "The size of the worker VMs (immutable)." - }, - "diskSizeGB": { - "description": "The disk size of the worker VMs. Must be 128 or greater (immutable).", - "type": "integer" - }, - "subnetId": { - "description": "The Azure resource ID of the worker subnet (immutable).", - "type": "string" - }, - "count": { - "description": "The number of worker VMs. Must be between 3 and 20.", - "type": "integer" - } - } - } - }, - "parameters": { - "ApiVersionParameter": { - "name": "api-version", - "in": "query", - "description": "Client API version.", - "required": true, - "type": "string" - }, - "SubscriptionIdParameter": { - "name": "subscriptionId", - "in": "path", - "description": "Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "required": true, - "type": "string" - } - }, - "securityDefinitions": { - "azure_auth": { - "type": "oauth2", - "description": "Azure Active Directory OAuth2 Flow", - "flow": "implicit", - "authorizationUrl": "https://login.microsoftonline.com/common/oauth2/authorize", - "scopes": { - "user_impersonation": "impersonate your user account" - } - } - }, - "security": [ - { - "azure_auth": [ - "user_impersonation" - ] - } - ] -} diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go new file mode 100644 index 000000000..0dbda6693 --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go @@ -0,0 +1,37 @@ +// Package redhatopenshift implements the Azure ARM Redhatopenshift service API version 2019-12-31-preview. +// +// Rest API for Azure Red Hat OpenShift +package redhatopenshift + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Redhatopenshift + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Redhatopenshift. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient client. +func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go new file mode 100644 index 000000000..db120e6d2 --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go @@ -0,0 +1,368 @@ +package redhatopenshift + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "encoding/json" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" +) + +// The package's fully qualified name. +const fqdn = "github.com/jim-minter/rp/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift" + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Creating ... + Creating ProvisioningState = "Creating" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Creating, Deleting, Failed, Succeeded, Updating} +} + +// VMSize enumerates the values for vm size. +type VMSize string + +const ( + // StandardD2sV3 ... + StandardD2sV3 VMSize = "Standard_D2s_v3" + // StandardD4sV3 ... + StandardD4sV3 VMSize = "Standard_D4s_v3" + // StandardD8sV3 ... + StandardD8sV3 VMSize = "Standard_D8s_v3" +) + +// PossibleVMSizeValues returns an array of possible values for the VMSize const type. +func PossibleVMSizeValues() []VMSize { + return []VMSize{StandardD2sV3, StandardD4sV3, StandardD8sV3} +} + +// VMSize1 enumerates the values for vm size 1. +type VMSize1 string + +const ( + // VMSize1StandardD2sV3 ... + VMSize1StandardD2sV3 VMSize1 = "Standard_D2s_v3" + // VMSize1StandardD4sV3 ... + VMSize1StandardD4sV3 VMSize1 = "Standard_D4s_v3" + // VMSize1StandardD8sV3 ... + VMSize1StandardD8sV3 VMSize1 = "Standard_D8s_v3" +) + +// PossibleVMSize1Values returns an array of possible values for the VMSize1 const type. +func PossibleVMSize1Values() []VMSize1 { + return []VMSize1{VMSize1StandardD2sV3, VMSize1StandardD4sV3, VMSize1StandardD8sV3} +} + +// CloudError cloudError represents a cloud error. +type CloudError struct { + // Error - An error response from the service. + Error *CloudErrorBody `json:"error,omitempty"` +} + +// CloudErrorBody cloudErrorBody represents the body of a cloud error. +type CloudErrorBody struct { + // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. + Code *string `json:"code,omitempty"` + // Message - A message describing the error, intended to be suitable for display in a user interface. + Message *string `json:"message,omitempty"` + // Target - The target of the particular error. For example, the name of the property in error. + Target *string `json:"target,omitempty"` + // Details - A list of additional details about the error. + Details *[]CloudErrorBody `json:"details,omitempty"` +} + +// Display display represents the display details of an operation. +type Display struct { + // Provider - Friendly name of the resource provider. + Provider *string `json:"provider,omitempty"` + // Resource - Resource type on which the operation is performed. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type: read, write, delete, listKeys/action, etc. + Operation *string `json:"operation,omitempty"` + // Description - Friendly name of the operation. + Description *string `json:"description,omitempty"` +} + +// MasterProfile masterProfile represents a master profile. +type MasterProfile struct { + // VMSize - The size of the master VMs (immutable). Possible values include: 'StandardD2sV3', 'StandardD4sV3', 'StandardD8sV3' + VMSize VMSize `json:"vmSize,omitempty"` + // SubnetID - The Azure resource ID of the worker subnet (immutable). + SubnetID *string `json:"subnetId,omitempty"` +} + +// NetworkProfile networkProfile represents a network profile. +type NetworkProfile struct { + // PodCidr - The CIDR used for OpenShift/Kubernetes Pods (immutable). + PodCidr *string `json:"podCidr,omitempty"` + // ServiceCidr - The CIDR used for OpenShift/Kubernetes Services (immutable). + ServiceCidr *string `json:"serviceCidr,omitempty"` +} + +// OpenShiftCluster openShiftCluster represents an Azure Red Hat OpenShift cluster. +type OpenShiftCluster struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; The resource ID (immutable). + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The resource name (immutable). + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The resource type (immutable). + Type *string `json:"type,omitempty"` + // Location - The resource location (immutable). + Location *string `json:"location,omitempty"` + // Tags - The resource tags. + Tags map[string]*string `json:"tags"` + // Properties - The cluster properties. + *Properties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for OpenShiftCluster. +func (osc OpenShiftCluster) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if osc.Location != nil { + objectMap["location"] = osc.Location + } + if osc.Tags != nil { + objectMap["tags"] = osc.Tags + } + if osc.Properties != nil { + objectMap["properties"] = osc.Properties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for OpenShiftCluster struct. +func (osc *OpenShiftCluster) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + osc.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + osc.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + osc.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + osc.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + osc.Tags = tags + } + case "properties": + if v != nil { + var properties Properties + err = json.Unmarshal(*v, &properties) + if err != nil { + return err + } + osc.Properties = &properties + } + } + } + + return nil +} + +// OpenShiftClusterCredentials openShiftClusterCredentials represents an OpenShift cluster's credentials +type OpenShiftClusterCredentials struct { + autorest.Response `json:"-"` + // KubeadminPassword - The password for the kubeadmin user + KubeadminPassword *string `json:"kubeadminPassword,omitempty"` +} + +// OpenShiftClusterList openShiftClusterList represents a list of OpenShift clusters. +type OpenShiftClusterList struct { + autorest.Response `json:"-"` + // Value - The list of OpenShift clusters. + Value *[]OpenShiftCluster `json:"value,omitempty"` +} + +// OpenShiftClustersCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OpenShiftClustersCreateFuture) Result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.CreateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// OpenShiftClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OpenShiftClustersDeleteFuture) Result(client OpenShiftClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// OpenShiftClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type OpenShiftClustersUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *OpenShiftClustersUpdateFuture) Result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { + osc, err = client.UpdateResponder(osc.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") + } + } + return +} + +// Operation operation represents an operation. +type Operation struct { + // Name - Operation name: {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + // Display - The object that describes the operation. + Display *Display `json:"display,omitempty"` +} + +// OperationList operationList represents an operation list. +type OperationList struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the resource provider. + Value *[]Operation `json:"value,omitempty"` +} + +// Properties properties represents an OpenShift cluster's properties. +type Properties struct { + // ProvisioningState - The cluster provisioning state (immutable). Possible values include: 'Creating', 'Deleting', 'Failed', 'Succeeded', 'Updating' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // ServicePrincipalProfile - The cluster service principal profile. + ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` + // NetworkProfile - The cluster network profile. + NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` + // MasterProfile - The cluster master profile. + MasterProfile *MasterProfile `json:"masterProfile,omitempty"` + // WorkerProfiles - The cluster worker profiles. + WorkerProfiles *[]WorkerProfile `json:"workerProfiles,omitempty"` + // ApiserverURL - The URL to access the cluster API server (immutable). + ApiserverURL *string `json:"apiserverUrl,omitempty"` + // ConsoleURL - The URL to access the cluster console (immutable). + ConsoleURL *string `json:"consoleUrl,omitempty"` +} + +// ServicePrincipalProfile servicePrincipalProfile represents a service principal profile. +type ServicePrincipalProfile struct { + // ClientID - The client ID used for the cluster + ClientID *string `json:"clientId,omitempty"` + // ClientSecret - The client secret used for the cluster + ClientSecret *string `json:"clientSecret,omitempty"` +} + +// WorkerProfile workerProfile represents a worker profile. +type WorkerProfile struct { + // Name - The worker profile name. Must be "worker" (immutable). + Name *string `json:"name,omitempty"` + // VMSize - The size of the worker VMs (immutable). Possible values include: 'VMSize1StandardD2sV3', 'VMSize1StandardD4sV3', 'VMSize1StandardD8sV3' + VMSize VMSize1 `json:"vmSize,omitempty"` + // DiskSizeGB - The disk size of the worker VMs. Must be 128 or greater (immutable). + DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` + // SubnetID - The Azure resource ID of the worker subnet (immutable). + SubnetID *string `json:"subnetId,omitempty"` + // Count - The number of worker VMs. Must be between 3 and 20. + Count *int32 `json:"count,omitempty"` +} diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go new file mode 100644 index 000000000..18d8ec7d4 --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go @@ -0,0 +1,578 @@ +package redhatopenshift + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" +) + +// OpenShiftClustersClient is the rest API for Azure Red Hat OpenShift +type OpenShiftClustersClient struct { + BaseClient +} + +// NewOpenShiftClustersClient creates an instance of the OpenShiftClustersClient client. +func NewOpenShiftClustersClient(subscriptionID string) OpenShiftClustersClient { + return NewOpenShiftClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOpenShiftClustersClientWithBaseURI creates an instance of the OpenShiftClustersClient client. +func NewOpenShiftClustersClientWithBaseURI(baseURI string, subscriptionID string) OpenShiftClustersClient { + return OpenShiftClustersClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. +// The operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) Create(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client OpenShiftClustersClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) CreateSender(req *http.Request) (future OpenShiftClustersCreateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) CreateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation +// returns nothing. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client OpenShiftClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) DeleteSender(req *http.Request) (future OpenShiftClustersDeleteFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation +// returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftCluster, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client OpenShiftClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) GetSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) GetResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// GetCredentials gets credentials of a OpenShift cluster with the specified subscription, resource group and resource +// name. The operation returns the credentials. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the OpenShift cluster resource. +func (client OpenShiftClustersClient) GetCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterCredentials, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.GetCredentials") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetCredentialsPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", nil, "Failure preparing request") + return + } + + resp, err := client.GetCredentialsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", resp, "Failure sending request") + return + } + + result, err = client.GetCredentialsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", resp, "Failure responding to request") + } + + return +} + +// GetCredentialsPreparer prepares the GetCredentials request. +func (client OpenShiftClustersClient) GetCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/credentials", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetCredentialsSender sends the GetCredentials request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) GetCredentialsSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// GetCredentialsResponder handles the response to the GetCredentials request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) GetCredentialsResponder(resp *http.Response) (result OpenShiftClusterCredentials, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift +// cluster. +func (client OpenShiftClustersClient) List(ctx context.Context) (result OpenShiftClusterList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OpenShiftClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListByResourceGroup lists OpenShift clusters in the specified subscription and resource group. The operation +// returns properties of each OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +func (client OpenShiftClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result OpenShiftClusterList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure responding to request") + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client OpenShiftClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) ListByResourceGroupResponder(resp *http.Response) (result OpenShiftClusterList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. +// The operation returns properties of a OpenShift cluster. +// Parameters: +// resourceGroupName - the name of the resource group. +// resourceName - the name of the OpenShift cluster resource. +// parameters - the OpenShift cluster resource. +func (client OpenShiftClustersClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OpenShiftClustersClient.Update") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", nil, "Failure preparing request") + return + } + + result, err = client.UpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", result.Response(), "Failure sending request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client OpenShiftClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + parameters.ID = nil + parameters.Name = nil + parameters.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client OpenShiftClustersClient) UpdateSender(req *http.Request) (future OpenShiftClustersUpdateFuture, err error) { + sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, sd...) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client OpenShiftClustersClient) UpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go new file mode 100644 index 000000000..1594d835f --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go @@ -0,0 +1,96 @@ +package redhatopenshift + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "net/http" + + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" +) + +// OperationsClient is the rest API for Azure Red Hat OpenShift +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. +func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List lists all of the available RP operations. The operation returns the operations. +func (client OperationsClient) List(ctx context.Context) (result OperationList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure sending request") + return + } + + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2019-12-31-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.RedHatOpenShift/operations"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + return autorest.SendWithSender(client, req, sd...) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go new file mode 100644 index 000000000..3cbac7569 --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go @@ -0,0 +1,30 @@ +package redhatopenshiftapi + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + + "github.com/jim-minter/rp/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift" +) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result redhatopenshift.OperationList, err error) +} + +var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil) + +// OpenShiftClustersClientAPI contains the set of methods on the OpenShiftClustersClient type. +type OpenShiftClustersClientAPI interface { + Create(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClustersDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftCluster, err error) + GetCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterCredentials, err error) + List(ctx context.Context) (result redhatopenshift.OpenShiftClusterList, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterList, err error) + Update(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersUpdateFuture, err error) +} + +var _ OpenShiftClustersClientAPI = (*redhatopenshift.OpenShiftClustersClient)(nil) diff --git a/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go new file mode 100644 index 000000000..3e64e3b38 --- /dev/null +++ b/pkg/client/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go @@ -0,0 +1,14 @@ +package redhatopenshift + +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/0.0.0 redhatopenshift/2019-12-31-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return "0.0.0" +} diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go deleted file mode 100644 index cdec5c5a5..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/client.go +++ /dev/null @@ -1,51 +0,0 @@ -// Package redhatopenshift implements the Azure ARM Redhatopenshift service API version 2019-12-31-preview. -// -// Rest API for Azure Red Hat OpenShift -package redhatopenshift - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" -) - -const ( -// DefaultBaseURI is the default URI used for the service Redhatopenshift -DefaultBaseURI = "https://management.azure.com") - -// BaseClient is the base client for Redhatopenshift. -type BaseClient struct { - autorest.Client - BaseURI string - SubscriptionID string -} - -// New creates an instance of the BaseClient client. -func New(subscriptionID string)BaseClient { - return NewWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewWithBaseURI creates an instance of the BaseClient client. -func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { - return BaseClient{ - Client: autorest.NewClientWithUserAgent(UserAgent()), - BaseURI: baseURI, - SubscriptionID: subscriptionID, - } -} - diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go deleted file mode 100644 index 0d2a3d34c..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/models.go +++ /dev/null @@ -1,375 +0,0 @@ -package redhatopenshift - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "encoding/json" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// The package's fully qualified name. -const fqdn = "github.com/jim-minter/rp/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift" - - // ProvisioningState enumerates the values for provisioning state. - type ProvisioningState string - - const ( - // Creating ... - Creating ProvisioningState = "Creating" - // Deleting ... - Deleting ProvisioningState = "Deleting" - // Failed ... - Failed ProvisioningState = "Failed" - // Succeeded ... - Succeeded ProvisioningState = "Succeeded" - // Updating ... - Updating ProvisioningState = "Updating" - ) - // PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. - func PossibleProvisioningStateValues() []ProvisioningState { - return []ProvisioningState{Creating,Deleting,Failed,Succeeded,Updating} - } - - // VMSize enumerates the values for vm size. - type VMSize string - - const ( - // StandardD2sV3 ... - StandardD2sV3 VMSize = "Standard_D2s_v3" - // StandardD4sV3 ... - StandardD4sV3 VMSize = "Standard_D4s_v3" - // StandardD8sV3 ... - StandardD8sV3 VMSize = "Standard_D8s_v3" - ) - // PossibleVMSizeValues returns an array of possible values for the VMSize const type. - func PossibleVMSizeValues() []VMSize { - return []VMSize{StandardD2sV3,StandardD4sV3,StandardD8sV3} - } - - // VMSize1 enumerates the values for vm size 1. - type VMSize1 string - - const ( - // VMSize1StandardD2sV3 ... - VMSize1StandardD2sV3 VMSize1 = "Standard_D2s_v3" - // VMSize1StandardD4sV3 ... - VMSize1StandardD4sV3 VMSize1 = "Standard_D4s_v3" - // VMSize1StandardD8sV3 ... - VMSize1StandardD8sV3 VMSize1 = "Standard_D8s_v3" - ) - // PossibleVMSize1Values returns an array of possible values for the VMSize1 const type. - func PossibleVMSize1Values() []VMSize1 { - return []VMSize1{VMSize1StandardD2sV3,VMSize1StandardD4sV3,VMSize1StandardD8sV3} - } - - // CloudError cloudError represents a cloud error. - type CloudError struct { - // Error - An error response from the service. - Error *CloudErrorBody `json:"error,omitempty"` - } - - // CloudErrorBody cloudErrorBody represents the body of a cloud error. - type CloudErrorBody struct { - // Code - An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - Code *string `json:"code,omitempty"` - // Message - A message describing the error, intended to be suitable for display in a user interface. - Message *string `json:"message,omitempty"` - // Target - The target of the particular error. For example, the name of the property in error. - Target *string `json:"target,omitempty"` - // Details - A list of additional details about the error. - Details *[]CloudErrorBody `json:"details,omitempty"` - } - - // Display display represents the display details of an operation. - type Display struct { - // Provider - Friendly name of the resource provider. - Provider *string `json:"provider,omitempty"` - // Resource - Resource type on which the operation is performed. - Resource *string `json:"resource,omitempty"` - // Operation - Operation type: read, write, delete, listKeys/action, etc. - Operation *string `json:"operation,omitempty"` - // Description - Friendly name of the operation. - Description *string `json:"description,omitempty"` - } - - // MasterProfile masterProfile represents a master profile. - type MasterProfile struct { - // VMSize - The size of the master VMs (immutable). Possible values include: 'StandardD2sV3', 'StandardD4sV3', 'StandardD8sV3' - VMSize VMSize `json:"vmSize,omitempty"` - // SubnetID - The Azure resource ID of the worker subnet (immutable). - SubnetID *string `json:"subnetId,omitempty"` - } - - // NetworkProfile networkProfile represents a network profile. - type NetworkProfile struct { - // PodCidr - The CIDR used for OpenShift/Kubernetes Pods (immutable). - PodCidr *string `json:"podCidr,omitempty"` - // ServiceCidr - The CIDR used for OpenShift/Kubernetes Services (immutable). - ServiceCidr *string `json:"serviceCidr,omitempty"` - } - - // OpenShiftCluster openShiftCluster represents an Azure Red Hat OpenShift cluster. - type OpenShiftCluster struct { - autorest.Response `json:"-"` - // ID - READ-ONLY; The resource ID (immutable). - ID *string `json:"id,omitempty"` - // Name - READ-ONLY; The resource name (immutable). - Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The resource type (immutable). - Type *string `json:"type,omitempty"` - // Location - The resource location (immutable). - Location *string `json:"location,omitempty"` - // Tags - The resource tags. - Tags map[string]*string `json:"tags"` - // Properties - The cluster properties. - *Properties `json:"properties,omitempty"` - } - - // MarshalJSON is the custom marshaler for OpenShiftCluster. - func (osc OpenShiftCluster)MarshalJSON() ([]byte, error){ - objectMap := make(map[string]interface{}) - if(osc.Location != nil) { - objectMap["location"] = osc.Location - } - if(osc.Tags != nil) { - objectMap["tags"] = osc.Tags - } - if(osc.Properties != nil) { - objectMap["properties"] = osc.Properties - } - return json.Marshal(objectMap) - } - // UnmarshalJSON is the custom unmarshaler for OpenShiftCluster struct. - func (osc *OpenShiftCluster) UnmarshalJSON(body []byte) error { - var m map[string]*json.RawMessage - err := json.Unmarshal(body, &m) - if err != nil { - return err - } - for k, v := range m { - switch k { - case "id": - if v != nil { - var ID string - err = json.Unmarshal(*v, &ID) - if err != nil { - return err - } - osc.ID = &ID - } - case "name": - if v != nil { - var name string - err = json.Unmarshal(*v, &name) - if err != nil { - return err - } - osc.Name = &name - } - case "type": - if v != nil { - var typeVar string - err = json.Unmarshal(*v, &typeVar) - if err != nil { - return err - } - osc.Type = &typeVar - } - case "location": - if v != nil { - var location string - err = json.Unmarshal(*v, &location) - if err != nil { - return err - } - osc.Location = &location - } - case "tags": - if v != nil { - var tags map[string]*string - err = json.Unmarshal(*v, &tags) - if err != nil { - return err - } - osc.Tags = tags - } - case "properties": - if v != nil { - var properties Properties - err = json.Unmarshal(*v, &properties) - if err != nil { - return err - } - osc.Properties = &properties - } - } - } - - return nil - } - - // OpenShiftClusterCredentials openShiftClusterCredentials represents an OpenShift cluster's credentials - type OpenShiftClusterCredentials struct { - autorest.Response `json:"-"` - // KubeadminPassword - The password for the kubeadmin user - KubeadminPassword *string `json:"kubeadminPassword,omitempty"` - } - - // OpenShiftClusterList openShiftClusterList represents a list of OpenShift clusters. - type OpenShiftClusterList struct { - autorest.Response `json:"-"` - // Value - The list of OpenShift clusters. - Value *[]OpenShiftCluster `json:"value,omitempty"` - } - - // OpenShiftClustersCreateFuture an abstraction for monitoring and retrieving the results of a long-running - // operation. - type OpenShiftClustersCreateFuture struct { - azure.Future - } - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - func (future *OpenShiftClustersCreateFuture) Result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersCreateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { - osc, err = client.CreateResponder(osc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersCreateFuture", "Result", osc.Response.Response, "Failure responding to request") - } - } - return - } - - // OpenShiftClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running - // operation. - type OpenShiftClustersDeleteFuture struct { - azure.Future - } - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - func (future *OpenShiftClustersDeleteFuture) Result(client OpenShiftClustersClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersDeleteFuture") - return - } - ar.Response = future.Response() - return - } - - // OpenShiftClustersUpdateFuture an abstraction for monitoring and retrieving the results of a long-running - // operation. - type OpenShiftClustersUpdateFuture struct { - azure.Future - } - // Result returns the result of the asynchronous operation. - // If the operation has not completed it will return an error. - func (future *OpenShiftClustersUpdateFuture) Result(client OpenShiftClustersClient) (osc OpenShiftCluster, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("redhatopenshift.OpenShiftClustersUpdateFuture") - return - } - sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - if osc.Response.Response, err = future.GetResult(sender); err == nil && osc.Response.Response.StatusCode != http.StatusNoContent { - osc, err = client.UpdateResponder(osc.Response.Response) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersUpdateFuture", "Result", osc.Response.Response, "Failure responding to request") - } - } - return - } - - // Operation operation represents an operation. - type Operation struct { - // Name - Operation name: {provider}/{resource}/{operation}. - Name *string `json:"name,omitempty"` - // Display - The object that describes the operation. - Display *Display `json:"display,omitempty"` - } - - // OperationList operationList represents an operation list. - type OperationList struct { - autorest.Response `json:"-"` - // Value - List of operations supported by the resource provider. - Value *[]Operation `json:"value,omitempty"` - } - - // Properties properties represents an OpenShift cluster's properties. - type Properties struct { - // ProvisioningState - The cluster provisioning state (immutable). Possible values include: 'Creating', 'Deleting', 'Failed', 'Succeeded', 'Updating' - ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` - // ServicePrincipalProfile - The cluster service principal profile. - ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"` - // NetworkProfile - The cluster network profile. - NetworkProfile *NetworkProfile `json:"networkProfile,omitempty"` - // MasterProfile - The cluster master profile. - MasterProfile *MasterProfile `json:"masterProfile,omitempty"` - // WorkerProfiles - The cluster worker profiles. - WorkerProfiles *[]WorkerProfile `json:"workerProfiles,omitempty"` - // ApiserverURL - The URL to access the cluster API server (immutable). - ApiserverURL *string `json:"apiserverUrl,omitempty"` - // ConsoleURL - The URL to access the cluster console (immutable). - ConsoleURL *string `json:"consoleUrl,omitempty"` - } - - // ServicePrincipalProfile servicePrincipalProfile represents a service principal profile. - type ServicePrincipalProfile struct { - // ClientID - The client ID used for the cluster - ClientID *string `json:"clientId,omitempty"` - // ClientSecret - The client secret used for the cluster - ClientSecret *string `json:"clientSecret,omitempty"` - } - - // WorkerProfile workerProfile represents a worker profile. - type WorkerProfile struct { - // Name - The worker profile name. Must be "worker" (immutable). - Name *string `json:"name,omitempty"` - // VMSize - The size of the worker VMs (immutable). Possible values include: 'VMSize1StandardD2sV3', 'VMSize1StandardD4sV3', 'VMSize1StandardD8sV3' - VMSize VMSize1 `json:"vmSize,omitempty"` - // DiskSizeGB - The disk size of the worker VMs. Must be 128 or greater (immutable). - DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` - // SubnetID - The Azure resource ID of the worker subnet (immutable). - SubnetID *string `json:"subnetId,omitempty"` - // Count - The number of worker VMs. Must be between 3 and 20. - Count *int32 `json:"count,omitempty"` - } - diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go deleted file mode 100644 index f586184e0..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/openshiftclusters.go +++ /dev/null @@ -1,591 +0,0 @@ -package redhatopenshift - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "context" - "github.com/Azure/go-autorest/tracing" -) - -// OpenShiftClustersClient is the rest API for Azure Red Hat OpenShift -type OpenShiftClustersClient struct { - BaseClient -} -// NewOpenShiftClustersClient creates an instance of the OpenShiftClustersClient client. -func NewOpenShiftClustersClient(subscriptionID string) OpenShiftClustersClient { - return NewOpenShiftClustersClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOpenShiftClustersClientWithBaseURI creates an instance of the OpenShiftClustersClient client. - func NewOpenShiftClustersClientWithBaseURI(baseURI string, subscriptionID string) OpenShiftClustersClient { - return OpenShiftClustersClient{ NewWithBaseURI(baseURI, subscriptionID)} - } - -// Create creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. -// The operation returns properties of a OpenShift cluster. - // Parameters: - // resourceGroupName - the name of the resource group. - // resourceName - the name of the OpenShift cluster resource. - // parameters - the OpenShift cluster resource. -func (client OpenShiftClustersClient) Create(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersCreateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.Create") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.CreatePreparer(ctx, resourceGroupName, resourceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Create", nil , "Failure preparing request") - return - } - - result, err = client.CreateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Create", result.Response(), "Failure sending request") - return - } - - return - } - - // CreatePreparer prepares the Create request. - func (client OpenShiftClustersClient) CreatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "resourceName": autorest.Encode("path",resourceName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Name = nil - parameters.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPut(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}",pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // CreateSender sends the Create request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) CreateSender(req *http.Request) (future OpenShiftClustersCreateFuture, err error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, sd...) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return - } - -// CreateResponder handles the response to the Create request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) CreateResponder(resp *http.Response) (result OpenShiftCluster, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - -// Delete deletes a OpenShift cluster with the specified subscription, resource group and resource name. The operation -// returns nothing. - // Parameters: - // resourceGroupName - the name of the resource group. - // resourceName - the name of the OpenShift cluster resource. -func (client OpenShiftClustersClient) Delete(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClustersDeleteFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.Delete") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.DeletePreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", nil , "Failure preparing request") - return - } - - result, err = client.DeleteSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Delete", result.Response(), "Failure sending request") - return - } - - return - } - - // DeletePreparer prepares the Delete request. - func (client OpenShiftClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "resourceName": autorest.Encode("path",resourceName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsDelete(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}",pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // DeleteSender sends the Delete request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) DeleteSender(req *http.Request) (future OpenShiftClustersDeleteFuture, err error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, sd...) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return - } - -// DeleteResponder handles the response to the Delete request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusNoContent), - autorest.ByClosing()) - result.Response = resp - return - } - -// Get gets a OpenShift cluster with the specified subscription, resource group and resource name. The operation -// returns properties of a OpenShift cluster. - // Parameters: - // resourceGroupName - the name of the resource group. - // resourceName - the name of the OpenShift cluster resource. -func (client OpenShiftClustersClient) Get(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftCluster, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.Get") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", nil , "Failure preparing request") - return - } - - resp, err := client.GetSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure sending request") - return - } - - result, err = client.GetResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Get", resp, "Failure responding to request") - } - - return - } - - // GetPreparer prepares the Get request. - func (client OpenShiftClustersClient) GetPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "resourceName": autorest.Encode("path",resourceName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}",pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // GetSender sends the Get request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) GetSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) - } - -// GetResponder handles the response to the Get request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) GetResponder(resp *http.Response) (result OpenShiftCluster, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - -// GetCredentials gets credentials of a OpenShift cluster with the specified subscription, resource group and resource -// name. The operation returns the credentials. - // Parameters: - // resourceGroupName - the name of the resource group. - // resourceName - the name of the OpenShift cluster resource. -func (client OpenShiftClustersClient) GetCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result OpenShiftClusterCredentials, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.GetCredentials") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.GetCredentialsPreparer(ctx, resourceGroupName, resourceName) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", nil , "Failure preparing request") - return - } - - resp, err := client.GetCredentialsSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", resp, "Failure sending request") - return - } - - result, err = client.GetCredentialsResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "GetCredentials", resp, "Failure responding to request") - } - - return - } - - // GetCredentialsPreparer prepares the GetCredentials request. - func (client OpenShiftClustersClient) GetCredentialsPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "resourceName": autorest.Encode("path",resourceName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/credentials",pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // GetCredentialsSender sends the GetCredentials request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) GetCredentialsSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) - } - -// GetCredentialsResponder handles the response to the GetCredentials request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) GetCredentialsResponder(resp *http.Response) (result OpenShiftClusterCredentials, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - -// List lists OpenShift clusters in the specified subscription. The operation returns properties of each OpenShift -// cluster. -func (client OpenShiftClustersClient) List(ctx context.Context) (result OpenShiftClusterList, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", nil , "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "List", resp, "Failure responding to request") - } - - return - } - - // ListPreparer prepares the List request. - func (client OpenShiftClustersClient) ListPreparer(ctx context.Context) (*http.Request, error) { - pathParameters := map[string]interface{} { - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.RedHatOpenShift/openShiftClusters",pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // ListSender sends the List request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) ListSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) - } - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) ListResponder(resp *http.Response) (result OpenShiftClusterList, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - -// ListByResourceGroup lists OpenShift clusters in the specified subscription and resource group. The operation -// returns properties of each OpenShift cluster. - // Parameters: - // resourceGroupName - the name of the resource group. -func (client OpenShiftClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result OpenShiftClusterList, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.ListByResourceGroup") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", nil , "Failure preparing request") - return - } - - resp, err := client.ListByResourceGroupSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure sending request") - return - } - - result, err = client.ListByResourceGroupResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "ListByResourceGroup", resp, "Failure responding to request") - } - - return - } - - // ListByResourceGroupPreparer prepares the ListByResourceGroup request. - func (client OpenShiftClustersClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters",pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - return autorest.SendWithSender(client, req, sd...) - } - -// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) ListByResourceGroupResponder(resp *http.Response) (result OpenShiftClusterList, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - -// Update creates or updates a OpenShift cluster with the specified subscription, resource group and resource name. -// The operation returns properties of a OpenShift cluster. - // Parameters: - // resourceGroupName - the name of the resource group. - // resourceName - the name of the OpenShift cluster resource. - // parameters - the OpenShift cluster resource. -func (client OpenShiftClustersClient) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (result OpenShiftClustersUpdateFuture, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OpenShiftClustersClient.Update") - defer func() { - sc := -1 - if result.Response() != nil { - sc = result.Response().StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.UpdatePreparer(ctx, resourceGroupName, resourceName, parameters) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", nil , "Failure preparing request") - return - } - - result, err = client.UpdateSender(req) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OpenShiftClustersClient", "Update", result.Response(), "Failure sending request") - return - } - - return - } - - // UpdatePreparer prepares the Update request. - func (client OpenShiftClustersClient) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters OpenShiftCluster) (*http.Request, error) { - pathParameters := map[string]interface{} { - "resourceGroupName": autorest.Encode("path",resourceGroupName), - "resourceName": autorest.Encode("path",resourceName), - "subscriptionId": autorest.Encode("path",client.SubscriptionID), - } - - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - parameters.ID = nil - parameters.Name = nil - parameters.Type = nil - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPatch(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}",pathParameters), - autorest.WithJSON(parameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // UpdateSender sends the Update request. The method will close the - // http.Response Body if it receives an error. - func (client OpenShiftClustersClient) UpdateSender(req *http.Request) (future OpenShiftClustersUpdateFuture, err error) { - sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client)) - var resp *http.Response - resp, err = autorest.SendWithSender(client, req, sd...) - if err != nil { - return - } - future.Future, err = azure.NewFutureFromResponse(resp) - return - } - -// UpdateResponder handles the response to the Update request. The method always -// closes the http.Response Body. -func (client OpenShiftClustersClient) UpdateResponder(resp *http.Response) (result OpenShiftCluster, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK,http.StatusCreated), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go deleted file mode 100644 index aa184c012..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/operations.go +++ /dev/null @@ -1,109 +0,0 @@ -package redhatopenshift - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" - "context" - "github.com/Azure/go-autorest/tracing" -) - -// OperationsClient is the rest API for Azure Red Hat OpenShift -type OperationsClient struct { - BaseClient -} -// NewOperationsClient creates an instance of the OperationsClient client. -func NewOperationsClient(subscriptionID string) OperationsClient { - return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewOperationsClientWithBaseURI creates an instance of the OperationsClient client. - func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { - return OperationsClient{ NewWithBaseURI(baseURI, subscriptionID)} - } - -// List lists all of the available RP operations. The operation returns the operations. -func (client OperationsClient) List(ctx context.Context) (result OperationList, err error) { - if tracing.IsEnabled() { - ctx = tracing.StartSpan(ctx, fqdn + "/OperationsClient.List") - defer func() { - sc := -1 - if result.Response.Response != nil { - sc = result.Response.Response.StatusCode - } - tracing.EndSpan(ctx, sc, err) - }() - } - req, err := client.ListPreparer(ctx) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", nil , "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "redhatopenshift.OperationsClient", "List", resp, "Failure responding to request") - } - - return - } - - // ListPreparer prepares the List request. - func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2019-12-31-preview" - queryParameters := map[string]interface{} { - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPath("/providers/Microsoft.RedHatOpenShift/operations"), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) - } - - // ListSender sends the List request. The method will close the - // http.Response Body if it receives an error. - func (client OperationsClient) ListSender(req *http.Request) (*http.Response, error) { - sd := autorest.GetSendDecorators(req.Context(), autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) - return autorest.SendWithSender(client, req, sd...) - } - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client OperationsClient) ListResponder(resp *http.Response) (result OperationList, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return - } - diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go deleted file mode 100644 index 8767ed472..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/redhatopenshiftapi/interfaces.go +++ /dev/null @@ -1,42 +0,0 @@ -package redhatopenshiftapi - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/jim-minter/rp/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift" -) - - // OperationsClientAPI contains the set of methods on the OperationsClient type. - type OperationsClientAPI interface { - List(ctx context.Context) (result redhatopenshift.OperationList, err error) - } - - var _ OperationsClientAPI = (*redhatopenshift.OperationsClient)(nil) - // OpenShiftClustersClientAPI contains the set of methods on the OpenShiftClustersClient type. - type OpenShiftClustersClientAPI interface { - Create(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersCreateFuture, err error) - Delete(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClustersDeleteFuture, err error) - Get(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftCluster, err error) - GetCredentials(ctx context.Context, resourceGroupName string, resourceName string) (result redhatopenshift.OpenShiftClusterCredentials, err error) - List(ctx context.Context) (result redhatopenshift.OpenShiftClusterList, err error) - ListByResourceGroup(ctx context.Context, resourceGroupName string) (result redhatopenshift.OpenShiftClusterList, err error) - Update(ctx context.Context, resourceGroupName string, resourceName string, parameters redhatopenshift.OpenShiftCluster) (result redhatopenshift.OpenShiftClustersUpdateFuture, err error) - } - - var _ OpenShiftClustersClientAPI = (*redhatopenshift.OpenShiftClustersClient)(nil) diff --git a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go b/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go deleted file mode 100644 index aa2d401fb..000000000 --- a/pkg/sdk/services/preview/redhatopenshift/mgmt/2019-12-31-preview/redhatopenshift/version.go +++ /dev/null @@ -1,31 +0,0 @@ -package redhatopenshift - -import "github.com/Azure/azure-sdk-for-go/version" - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - - -// UserAgent returns the UserAgent string to use when sending http.Requests. -func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " redhatopenshift/2019-12-31-preview" -} - -// Version returns the semantic version (see http://semver.org) of the client. -func Version() string { - return version.Number -} diff --git a/pkg/swagger/paths.go b/pkg/swagger/paths.go index 559777b47..91d790e78 100644 --- a/pkg/swagger/paths.go +++ b/pkg/swagger/paths.go @@ -157,3 +157,21 @@ func populateTopLevelPaths(resourceProviderNamespace, resourceType, friendlyName return } + +func populateExamples(ps Paths) { + for p, pi := range ps { + for _, op := range []*Operation{pi.Get, pi.Put, pi.Post, pi.Delete, pi.Options, pi.Head, pi.Patch} { + if op == nil { + continue + } + + op.Examples = map[string]Reference{ + op.Summary: { + Ref: "./examples/" + op.OperationID + ".json", + }, + } + } + + ps[p] = pi + } +} diff --git a/pkg/swagger/swagger.go b/pkg/swagger/swagger.go index 72f647c38..9298b2b85 100644 --- a/pkg/swagger/swagger.go +++ b/pkg/swagger/swagger.go @@ -6,17 +6,13 @@ import ( "os" ) -func Run(outputFile, shortVersion string) error { - longVersion, err := longVersion(shortVersion) - if err != nil { - return err - } +func Run(outputFile string) error { s := &Swagger{ Swagger: "2.0", Info: &Info{ Title: "Azure Red Hat OpenShift", Description: "Rest API for Azure Red Hat OpenShift", - Version: longVersion, + Version: "2019-12-31-preview", }, Host: "management.azure.com", Schemes: []string{"https"}, @@ -97,7 +93,9 @@ func Run(outputFile, shortVersion string) error { }, } - err = define(s.Definitions, "github.com/jim-minter/rp/pkg/api/"+shortVersion, "OpenShiftCluster", "OpenShiftClusterCredentials") + populateExamples(s.Paths) + + err := define(s.Definitions, "github.com/jim-minter/rp/pkg/api/v20191231preview", "OpenShiftCluster", "OpenShiftClusterCredentials") if err != nil { return err } diff --git a/pkg/swagger/types.go b/pkg/swagger/types.go index 7839c2be7..92fd425ad 100644 --- a/pkg/swagger/types.go +++ b/pkg/swagger/types.go @@ -83,7 +83,8 @@ type Operation struct { Schemes []string `json:"schemes,omitempty"` Deprecated bool `json:"deprecated,omitempty"` - LongRunningOperation bool `json:"x-ms-long-running-operation,omitempty"` + LongRunningOperation bool `json:"x-ms-long-running-operation,omitempty"` + Examples map[string]Reference `json:"x-ms-examples,omitempty"` } // ExternalDocumentation represents an External Documentation object diff --git a/pkg/swagger/utils.go b/pkg/swagger/utils.go deleted file mode 100644 index a907d93e4..000000000 --- a/pkg/swagger/utils.go +++ /dev/null @@ -1,33 +0,0 @@ -package swagger - -import ( - "fmt" - "regexp" - "strings" -) - -var shortVersion = regexp.MustCompile(`^v(\d{1,4}\d{1,2}\d{1,2})(preview)?$`) - -// ValidateVersion validates if version was provided -// in short format - v19890211[preview] -func ValidateVersion(input string) error { - if !shortVersion.MatchString(input) { - return fmt.Errorf("wrong version format %s", input) - } - return nil -} - -// longVersion return long version format from short version -func longVersion(input string) (short string, err error) { - input = strings.Replace(input, "v", "", 1) - yearIndex := 4 - monthIntex := 7 - dayIndex := 10 - q := input[:yearIndex] + "-" + input[yearIndex:] - q = q[:monthIntex] + "-" + q[monthIntex:] - if strings.Contains(input, "preview") { - q = q[:dayIndex] + "-" + q[dayIndex:] - } - - return q, nil -} diff --git a/pkg/swagger/utils_test.go b/pkg/swagger/utils_test.go deleted file mode 100644 index ed60c48a4..000000000 --- a/pkg/swagger/utils_test.go +++ /dev/null @@ -1,83 +0,0 @@ -package swagger - -import ( - "fmt" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestValidateVersion(t *testing.T) { - tests := []struct { - name string - expectErr error - input string - }{ - { - name: "correct preview version", - expectErr: nil, - input: "v20190211preview", - }, - { - name: "correct ga version", - expectErr: nil, - input: "v20190211", - }, - { - name: "wrong short version", - expectErr: fmt.Errorf("wrong version format 2019-02-11"), - input: "2019-02-11", - }, - { - name: "wrong long version", - expectErr: fmt.Errorf("wrong version format 2019-02-11-preview"), - input: "2019-02-11-preview", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - - err := ValidateVersion(test.input) - if !assert.Equal(t, test.expectErr, err) { - t.Errorf("%s: expected result:\n %v \ngot result:\n %v \n", test.name, test.expectErr, err) - } - - }) - } - -} - -func TestLongVersion(t *testing.T) { - tests := []struct { - name string - input string - expected string - }{ - { - name: "short version", - input: "v20190211preview", - expected: "2019-02-11-preview", - }, - { - name: "long version", - input: "v20190211", - expected: "2019-02-11", - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - - short, err := longVersion(test.input) - if err != nil { - t.Error(err) - } - if !assert.Equal(t, test.expected, short) { - t.Errorf("%s: expected result:\n %v \ngot result:\n %v \n", test.name, test.expected, short) - } - - }) - } - -} diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Create.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Create.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Create.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Create.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Delete.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Delete.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Delete.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Delete.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Get.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Get.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Get.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Get.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_GetCredentials.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_GetCredentials.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_GetCredentials.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_GetCredentials.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListBySubscription.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_List.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListBySubscription.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_List.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListByResourceGroup.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListByResourceGroup.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListByResourceGroup.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_ListByResourceGroup.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Update.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Update.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Update.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/OpenShiftClusters_Update.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/Operations_List.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/Operations_List.json similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/Operations_List.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/examples/Operations_List.json diff --git a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json similarity index 92% rename from rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json rename to swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json index a789e2926..27756d23d 100644 --- a/rest-api-spec/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json +++ b/swagger/redhatopenshift/resource-manager/Microsoft.RedHatOpenShift/preview/2019-12-31-preview/redhatopenshift.json @@ -42,6 +42,11 @@ "$ref": "#/definitions/CloudError" } } + }, + "x-ms-examples": { + "Lists all of the available RP operations.": { + "$ref": "./examples/Operations_List.json" + } } } }, @@ -74,6 +79,11 @@ "$ref": "#/definitions/CloudError" } } + }, + "x-ms-examples": { + "Lists OpenShift clusters in the specified subscription.": { + "$ref": "./examples/OpenShiftClusters_List.json" + } } } }, @@ -113,6 +123,11 @@ "$ref": "#/definitions/CloudError" } } + }, + "x-ms-examples": { + "Lists OpenShift clusters in the specified subscription and resource group.": { + "$ref": "./examples/OpenShiftClusters_ListByResourceGroup.json" + } } } }, @@ -159,6 +174,11 @@ "$ref": "#/definitions/CloudError" } } + }, + "x-ms-examples": { + "Gets a OpenShift cluster with the specified subscription, resource group and resource name.": { + "$ref": "./examples/OpenShiftClusters_Get.json" + } } }, "put": { @@ -219,7 +239,12 @@ } } }, - "x-ms-long-running-operation": true + "x-ms-long-running-operation": true, + "x-ms-examples": { + "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name.": { + "$ref": "./examples/OpenShiftClusters_Create.json" + } + } }, "delete": { "tags": [ @@ -264,7 +289,12 @@ } } }, - "x-ms-long-running-operation": true + "x-ms-long-running-operation": true, + "x-ms-examples": { + "Deletes a OpenShift cluster with the specified subscription, resource group and resource name.": { + "$ref": "./examples/OpenShiftClusters_Delete.json" + } + } }, "patch": { "tags": [ @@ -324,7 +354,12 @@ } } }, - "x-ms-long-running-operation": true + "x-ms-long-running-operation": true, + "x-ms-examples": { + "Creates or updates a OpenShift cluster with the specified subscription, resource group and resource name.": { + "$ref": "./examples/OpenShiftClusters_Update.json" + } + } } }, "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.RedHatOpenShift/openShiftClusters/{resourceName}/credentials": { @@ -370,6 +405,11 @@ "$ref": "#/definitions/CloudError" } } + }, + "x-ms-examples": { + "Gets credentials of a OpenShift cluster with the specified subscription, resource group and resource name.": { + "$ref": "./examples/OpenShiftClusters_GetCredentials.json" + } } } } diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.csharp.md b/swagger/redhatopenshift/resource-manager/readme.csharp.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.csharp.md rename to swagger/redhatopenshift/resource-manager/readme.csharp.md diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.go.md b/swagger/redhatopenshift/resource-manager/readme.go.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.go.md rename to swagger/redhatopenshift/resource-manager/readme.go.md diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.md b/swagger/redhatopenshift/resource-manager/readme.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.md rename to swagger/redhatopenshift/resource-manager/readme.md diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.python.md b/swagger/redhatopenshift/resource-manager/readme.python.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.python.md rename to swagger/redhatopenshift/resource-manager/readme.python.md diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.ruby.md b/swagger/redhatopenshift/resource-manager/readme.ruby.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.ruby.md rename to swagger/redhatopenshift/resource-manager/readme.ruby.md diff --git a/rest-api-spec/redhatopenshift/resource-manager/readme.typescript.md b/swagger/redhatopenshift/resource-manager/readme.typescript.md similarity index 100% rename from rest-api-spec/redhatopenshift/resource-manager/readme.typescript.md rename to swagger/redhatopenshift/resource-manager/readme.typescript.md diff --git a/vendor/github.com/golang/mock/gomock/call.go b/vendor/github.com/golang/mock/gomock/call.go new file mode 100644 index 000000000..3d54d9f5d --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/call.go @@ -0,0 +1,420 @@ +// Copyright 2010 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gomock + +import ( + "fmt" + "reflect" + "strconv" + "strings" +) + +// Call represents an expected call to a mock. +type Call struct { + t TestHelper // for triggering test failures on invalid call setup + + receiver interface{} // the receiver of the method call + method string // the name of the method + methodType reflect.Type // the type of the method + args []Matcher // the args + origin string // file and line number of call setup + + preReqs []*Call // prerequisite calls + + // Expectations + minCalls, maxCalls int + + numCalls int // actual number made + + // actions are called when this Call is called. Each action gets the args and + // can set the return values by returning a non-nil slice. Actions run in the + // order they are created. + actions []func([]interface{}) []interface{} +} + +// newCall creates a *Call. It requires the method type in order to support +// unexported methods. +func newCall(t TestHelper, receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { + t.Helper() + + // TODO: check arity, types. + margs := make([]Matcher, len(args)) + for i, arg := range args { + if m, ok := arg.(Matcher); ok { + margs[i] = m + } else if arg == nil { + // Handle nil specially so that passing a nil interface value + // will match the typed nils of concrete args. + margs[i] = Nil() + } else { + margs[i] = Eq(arg) + } + } + + origin := callerInfo(3) + actions := []func([]interface{}) []interface{}{func([]interface{}) []interface{} { + // Synthesize the zero value for each of the return args' types. + rets := make([]interface{}, methodType.NumOut()) + for i := 0; i < methodType.NumOut(); i++ { + rets[i] = reflect.Zero(methodType.Out(i)).Interface() + } + return rets + }} + return &Call{t: t, receiver: receiver, method: method, methodType: methodType, + args: margs, origin: origin, minCalls: 1, maxCalls: 1, actions: actions} +} + +// AnyTimes allows the expectation to be called 0 or more times +func (c *Call) AnyTimes() *Call { + c.minCalls, c.maxCalls = 0, 1e8 // close enough to infinity + return c +} + +// MinTimes requires the call to occur at least n times. If AnyTimes or MaxTimes have not been called, MinTimes also +// sets the maximum number of calls to infinity. +func (c *Call) MinTimes(n int) *Call { + c.minCalls = n + if c.maxCalls == 1 { + c.maxCalls = 1e8 + } + return c +} + +// MaxTimes limits the number of calls to n times. If AnyTimes or MinTimes have not been called, MaxTimes also +// sets the minimum number of calls to 0. +func (c *Call) MaxTimes(n int) *Call { + c.maxCalls = n + if c.minCalls == 1 { + c.minCalls = 0 + } + return c +} + +// DoAndReturn declares the action to run when the call is matched. +// The return values from this function are returned by the mocked function. +// It takes an interface{} argument to support n-arity functions. +func (c *Call) DoAndReturn(f interface{}) *Call { + // TODO: Check arity and types here, rather than dying badly elsewhere. + v := reflect.ValueOf(f) + + c.addAction(func(args []interface{}) []interface{} { + vargs := make([]reflect.Value, len(args)) + ft := v.Type() + for i := 0; i < len(args); i++ { + if args[i] != nil { + vargs[i] = reflect.ValueOf(args[i]) + } else { + // Use the zero value for the arg. + vargs[i] = reflect.Zero(ft.In(i)) + } + } + vrets := v.Call(vargs) + rets := make([]interface{}, len(vrets)) + for i, ret := range vrets { + rets[i] = ret.Interface() + } + return rets + }) + return c +} + +// Do declares the action to run when the call is matched. The function's +// return values are ignored to retain backward compatibility. To use the +// return values call DoAndReturn. +// It takes an interface{} argument to support n-arity functions. +func (c *Call) Do(f interface{}) *Call { + // TODO: Check arity and types here, rather than dying badly elsewhere. + v := reflect.ValueOf(f) + + c.addAction(func(args []interface{}) []interface{} { + vargs := make([]reflect.Value, len(args)) + ft := v.Type() + for i := 0; i < len(args); i++ { + if args[i] != nil { + vargs[i] = reflect.ValueOf(args[i]) + } else { + // Use the zero value for the arg. + vargs[i] = reflect.Zero(ft.In(i)) + } + } + v.Call(vargs) + return nil + }) + return c +} + +// Return declares the values to be returned by the mocked function call. +func (c *Call) Return(rets ...interface{}) *Call { + c.t.Helper() + + mt := c.methodType + if len(rets) != mt.NumOut() { + c.t.Fatalf("wrong number of arguments to Return for %T.%v: got %d, want %d [%s]", + c.receiver, c.method, len(rets), mt.NumOut(), c.origin) + } + for i, ret := range rets { + if got, want := reflect.TypeOf(ret), mt.Out(i); got == want { + // Identical types; nothing to do. + } else if got == nil { + // Nil needs special handling. + switch want.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice: + // ok + default: + c.t.Fatalf("argument %d to Return for %T.%v is nil, but %v is not nillable [%s]", + i, c.receiver, c.method, want, c.origin) + } + } else if got.AssignableTo(want) { + // Assignable type relation. Make the assignment now so that the generated code + // can return the values with a type assertion. + v := reflect.New(want).Elem() + v.Set(reflect.ValueOf(ret)) + rets[i] = v.Interface() + } else { + c.t.Fatalf("wrong type of argument %d to Return for %T.%v: %v is not assignable to %v [%s]", + i, c.receiver, c.method, got, want, c.origin) + } + } + + c.addAction(func([]interface{}) []interface{} { + return rets + }) + + return c +} + +// Times declares the exact number of times a function call is expected to be executed. +func (c *Call) Times(n int) *Call { + c.minCalls, c.maxCalls = n, n + return c +} + +// SetArg declares an action that will set the nth argument's value, +// indirected through a pointer. Or, in the case of a slice, SetArg +// will copy value's elements into the nth argument. +func (c *Call) SetArg(n int, value interface{}) *Call { + c.t.Helper() + + mt := c.methodType + // TODO: This will break on variadic methods. + // We will need to check those at invocation time. + if n < 0 || n >= mt.NumIn() { + c.t.Fatalf("SetArg(%d, ...) called for a method with %d args [%s]", + n, mt.NumIn(), c.origin) + } + // Permit setting argument through an interface. + // In the interface case, we don't (nay, can't) check the type here. + at := mt.In(n) + switch at.Kind() { + case reflect.Ptr: + dt := at.Elem() + if vt := reflect.TypeOf(value); !vt.AssignableTo(dt) { + c.t.Fatalf("SetArg(%d, ...) argument is a %v, not assignable to %v [%s]", + n, vt, dt, c.origin) + } + case reflect.Interface: + // nothing to do + case reflect.Slice: + // nothing to do + default: + c.t.Fatalf("SetArg(%d, ...) referring to argument of non-pointer non-interface non-slice type %v [%s]", + n, at, c.origin) + } + + c.addAction(func(args []interface{}) []interface{} { + v := reflect.ValueOf(value) + switch reflect.TypeOf(args[n]).Kind() { + case reflect.Slice: + setSlice(args[n], v) + default: + reflect.ValueOf(args[n]).Elem().Set(v) + } + return nil + }) + return c +} + +// isPreReq returns true if other is a direct or indirect prerequisite to c. +func (c *Call) isPreReq(other *Call) bool { + for _, preReq := range c.preReqs { + if other == preReq || preReq.isPreReq(other) { + return true + } + } + return false +} + +// After declares that the call may only match after preReq has been exhausted. +func (c *Call) After(preReq *Call) *Call { + c.t.Helper() + + if c == preReq { + c.t.Fatalf("A call isn't allowed to be its own prerequisite") + } + if preReq.isPreReq(c) { + c.t.Fatalf("Loop in call order: %v is a prerequisite to %v (possibly indirectly).", c, preReq) + } + + c.preReqs = append(c.preReqs, preReq) + return c +} + +// Returns true if the minimum number of calls have been made. +func (c *Call) satisfied() bool { + return c.numCalls >= c.minCalls +} + +// Returns true iff the maximum number of calls have been made. +func (c *Call) exhausted() bool { + return c.numCalls >= c.maxCalls +} + +func (c *Call) String() string { + args := make([]string, len(c.args)) + for i, arg := range c.args { + args[i] = arg.String() + } + arguments := strings.Join(args, ", ") + return fmt.Sprintf("%T.%v(%s) %s", c.receiver, c.method, arguments, c.origin) +} + +// Tests if the given call matches the expected call. +// If yes, returns nil. If no, returns error with message explaining why it does not match. +func (c *Call) matches(args []interface{}) error { + if !c.methodType.IsVariadic() { + if len(args) != len(c.args) { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: %d", + c.origin, len(args), len(c.args)) + } + + for i, m := range c.args { + if !m.Matches(args[i]) { + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i], m) + } + } + } else { + if len(c.args) < c.methodType.NumIn()-1 { + return fmt.Errorf("Expected call at %s has the wrong number of matchers. Got: %d, want: %d", + c.origin, len(c.args), c.methodType.NumIn()-1) + } + if len(c.args) != c.methodType.NumIn() && len(args) != len(c.args) { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: %d", + c.origin, len(args), len(c.args)) + } + if len(args) < len(c.args)-1 { + return fmt.Errorf("Expected call at %s has the wrong number of arguments. Got: %d, want: greater than or equal to %d", + c.origin, len(args), len(c.args)-1) + } + + for i, m := range c.args { + if i < c.methodType.NumIn()-1 { + // Non-variadic args + if !m.Matches(args[i]) { + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i], m) + } + continue + } + // The last arg has a possibility of a variadic argument, so let it branch + + // sample: Foo(a int, b int, c ...int) + if i < len(c.args) && i < len(args) { + if m.Matches(args[i]) { + // Got Foo(a, b, c) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, someSliceMatcher) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC) + // Got Foo(a, b) want Foo(matcherA, matcherB) + // Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD) + continue + } + } + + // The number of actual args don't match the number of matchers, + // or the last matcher is a slice and the last arg is not. + // If this function still matches it is because the last matcher + // matches all the remaining arguments or the lack of any. + // Convert the remaining arguments, if any, into a slice of the + // expected type. + vargsType := c.methodType.In(c.methodType.NumIn() - 1) + vargs := reflect.MakeSlice(vargsType, 0, len(args)-i) + for _, arg := range args[i:] { + vargs = reflect.Append(vargs, reflect.ValueOf(arg)) + } + if m.Matches(vargs.Interface()) { + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, someSliceMatcher) + // Got Foo(a, b) want Foo(matcherA, matcherB, gomock.Any()) + // Got Foo(a, b) want Foo(matcherA, matcherB, someEmptySliceMatcher) + break + } + // Wrong number of matchers or not match. Fail. + // Got Foo(a, b) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c, d) want Foo(matcherA, matcherB, matcherC, matcherD, matcherE) + // Got Foo(a, b, c, d, e) want Foo(matcherA, matcherB, matcherC, matcherD) + // Got Foo(a, b, c) want Foo(matcherA, matcherB) + return fmt.Errorf("Expected call at %s doesn't match the argument at index %s.\nGot: %v\nWant: %v", + c.origin, strconv.Itoa(i), args[i:], c.args[i]) + + } + } + + // Check that all prerequisite calls have been satisfied. + for _, preReqCall := range c.preReqs { + if !preReqCall.satisfied() { + return fmt.Errorf("Expected call at %s doesn't have a prerequisite call satisfied:\n%v\nshould be called before:\n%v", + c.origin, preReqCall, c) + } + } + + // Check that the call is not exhausted. + if c.exhausted() { + return fmt.Errorf("Expected call at %s has already been called the max number of times.", c.origin) + } + + return nil +} + +// dropPrereqs tells the expected Call to not re-check prerequisite calls any +// longer, and to return its current set. +func (c *Call) dropPrereqs() (preReqs []*Call) { + preReqs = c.preReqs + c.preReqs = nil + return +} + +func (c *Call) call(args []interface{}) []func([]interface{}) []interface{} { + c.numCalls++ + return c.actions +} + +// InOrder declares that the given calls should occur in order. +func InOrder(calls ...*Call) { + for i := 1; i < len(calls); i++ { + calls[i].After(calls[i-1]) + } +} + +func setSlice(arg interface{}, v reflect.Value) { + va := reflect.ValueOf(arg) + for i := 0; i < v.Len(); i++ { + va.Index(i).Set(v.Index(i)) + } +} + +func (c *Call) addAction(action func([]interface{}) []interface{}) { + c.actions = append(c.actions, action) +} diff --git a/vendor/github.com/golang/mock/gomock/callset.go b/vendor/github.com/golang/mock/gomock/callset.go new file mode 100644 index 000000000..c44a8a585 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/callset.go @@ -0,0 +1,108 @@ +// Copyright 2011 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gomock + +import ( + "bytes" + "fmt" +) + +// callSet represents a set of expected calls, indexed by receiver and method +// name. +type callSet struct { + // Calls that are still expected. + expected map[callSetKey][]*Call + // Calls that have been exhausted. + exhausted map[callSetKey][]*Call +} + +// callSetKey is the key in the maps in callSet +type callSetKey struct { + receiver interface{} + fname string +} + +func newCallSet() *callSet { + return &callSet{make(map[callSetKey][]*Call), make(map[callSetKey][]*Call)} +} + +// Add adds a new expected call. +func (cs callSet) Add(call *Call) { + key := callSetKey{call.receiver, call.method} + m := cs.expected + if call.exhausted() { + m = cs.exhausted + } + m[key] = append(m[key], call) +} + +// Remove removes an expected call. +func (cs callSet) Remove(call *Call) { + key := callSetKey{call.receiver, call.method} + calls := cs.expected[key] + for i, c := range calls { + if c == call { + // maintain order for remaining calls + cs.expected[key] = append(calls[:i], calls[i+1:]...) + cs.exhausted[key] = append(cs.exhausted[key], call) + break + } + } +} + +// FindMatch searches for a matching call. Returns error with explanation message if no call matched. +func (cs callSet) FindMatch(receiver interface{}, method string, args []interface{}) (*Call, error) { + key := callSetKey{receiver, method} + + // Search through the expected calls. + expected := cs.expected[key] + var callsErrors bytes.Buffer + for _, call := range expected { + err := call.matches(args) + if err != nil { + fmt.Fprintf(&callsErrors, "\n%v", err) + } else { + return call, nil + } + } + + // If we haven't found a match then search through the exhausted calls so we + // get useful error messages. + exhausted := cs.exhausted[key] + for _, call := range exhausted { + if err := call.matches(args); err != nil { + fmt.Fprintf(&callsErrors, "\n%v", err) + } + } + + if len(expected)+len(exhausted) == 0 { + fmt.Fprintf(&callsErrors, "there are no expected calls of the method %q for that receiver", method) + } + + return nil, fmt.Errorf(callsErrors.String()) +} + +// Failures returns the calls that are not satisfied. +func (cs callSet) Failures() []*Call { + failures := make([]*Call, 0, len(cs.expected)) + for _, calls := range cs.expected { + for _, call := range calls { + if !call.satisfied() { + failures = append(failures, call) + } + } + } + return failures +} diff --git a/vendor/github.com/golang/mock/gomock/controller.go b/vendor/github.com/golang/mock/gomock/controller.go new file mode 100644 index 000000000..0651c91e4 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/controller.go @@ -0,0 +1,264 @@ +// Copyright 2010 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// Package gomock is a mock framework for Go. +// +// Standard usage: +// (1) Define an interface that you wish to mock. +// type MyInterface interface { +// SomeMethod(x int64, y string) +// } +// (2) Use mockgen to generate a mock from the interface. +// (3) Use the mock in a test: +// func TestMyThing(t *testing.T) { +// mockCtrl := gomock.NewController(t) +// defer mockCtrl.Finish() +// +// mockObj := something.NewMockMyInterface(mockCtrl) +// mockObj.EXPECT().SomeMethod(4, "blah") +// // pass mockObj to a real object and play with it. +// } +// +// By default, expected calls are not enforced to run in any particular order. +// Call order dependency can be enforced by use of InOrder and/or Call.After. +// Call.After can create more varied call order dependencies, but InOrder is +// often more convenient. +// +// The following examples create equivalent call order dependencies. +// +// Example of using Call.After to chain expected call order: +// +// firstCall := mockObj.EXPECT().SomeMethod(1, "first") +// secondCall := mockObj.EXPECT().SomeMethod(2, "second").After(firstCall) +// mockObj.EXPECT().SomeMethod(3, "third").After(secondCall) +// +// Example of using InOrder to declare expected call order: +// +// gomock.InOrder( +// mockObj.EXPECT().SomeMethod(1, "first"), +// mockObj.EXPECT().SomeMethod(2, "second"), +// mockObj.EXPECT().SomeMethod(3, "third"), +// ) +// +// TODO: +// - Handle different argument/return types (e.g. ..., chan, map, interface). +package gomock + +import ( + "context" + "fmt" + "reflect" + "runtime" + "sync" +) + +// A TestReporter is something that can be used to report test failures. It +// is satisfied by the standard library's *testing.T. +type TestReporter interface { + Errorf(format string, args ...interface{}) + Fatalf(format string, args ...interface{}) +} + +// TestHelper is a TestReporter that has the Helper method. It is satisfied +// by the standard library's *testing.T. +type TestHelper interface { + TestReporter + Helper() +} + +// A Controller represents the top-level control of a mock ecosystem. It +// defines the scope and lifetime of mock objects, as well as their +// expectations. It is safe to call Controller's methods from multiple +// goroutines. Each test should create a new Controller and invoke Finish via +// defer. +// +// func TestFoo(t *testing.T) { +// ctrl := gomock.NewController(st) +// defer ctrl.Finish() +// // .. +// } +// +// func TestBar(t *testing.T) { +// t.Run("Sub-Test-1", st) { +// ctrl := gomock.NewController(st) +// defer ctrl.Finish() +// // .. +// }) +// t.Run("Sub-Test-2", st) { +// ctrl := gomock.NewController(st) +// defer ctrl.Finish() +// // .. +// }) +// }) +type Controller struct { + // T should only be called within a generated mock. It is not intended to + // be used in user code and may be changed in future versions. T is the + // TestReporter passed in when creating the Controller via NewController. + // If the TestReporter does not implement a TestHelper it will be wrapped + // with a nopTestHelper. + T TestHelper + mu sync.Mutex + expectedCalls *callSet + finished bool +} + +// NewController returns a new Controller. It is the preferred way to create a +// Controller. +func NewController(t TestReporter) *Controller { + h, ok := t.(TestHelper) + if !ok { + h = nopTestHelper{t} + } + + return &Controller{ + T: h, + expectedCalls: newCallSet(), + } +} + +type cancelReporter struct { + TestHelper + cancel func() +} + +func (r *cancelReporter) Errorf(format string, args ...interface{}) { + r.TestHelper.Errorf(format, args...) +} +func (r *cancelReporter) Fatalf(format string, args ...interface{}) { + defer r.cancel() + r.TestHelper.Fatalf(format, args...) +} + +// WithContext returns a new Controller and a Context, which is cancelled on any +// fatal failure. +func WithContext(ctx context.Context, t TestReporter) (*Controller, context.Context) { + h, ok := t.(TestHelper) + if !ok { + h = nopTestHelper{t} + } + + ctx, cancel := context.WithCancel(ctx) + return NewController(&cancelReporter{h, cancel}), ctx +} + +type nopTestHelper struct { + TestReporter +} + +func (h nopTestHelper) Helper() {} + +// RecordCall is called by a mock. It should not be called by user code. +func (ctrl *Controller) RecordCall(receiver interface{}, method string, args ...interface{}) *Call { + ctrl.T.Helper() + + recv := reflect.ValueOf(receiver) + for i := 0; i < recv.Type().NumMethod(); i++ { + if recv.Type().Method(i).Name == method { + return ctrl.RecordCallWithMethodType(receiver, method, recv.Method(i).Type(), args...) + } + } + ctrl.T.Fatalf("gomock: failed finding method %s on %T", method, receiver) + panic("unreachable") +} + +// RecordCallWithMethodType is called by a mock. It should not be called by user code. +func (ctrl *Controller) RecordCallWithMethodType(receiver interface{}, method string, methodType reflect.Type, args ...interface{}) *Call { + ctrl.T.Helper() + + call := newCall(ctrl.T, receiver, method, methodType, args...) + + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + ctrl.expectedCalls.Add(call) + + return call +} + +// Call is called by a mock. It should not be called by user code. +func (ctrl *Controller) Call(receiver interface{}, method string, args ...interface{}) []interface{} { + ctrl.T.Helper() + + // Nest this code so we can use defer to make sure the lock is released. + actions := func() []func([]interface{}) []interface{} { + ctrl.T.Helper() + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + + expected, err := ctrl.expectedCalls.FindMatch(receiver, method, args) + if err != nil { + origin := callerInfo(2) + ctrl.T.Fatalf("Unexpected call to %T.%v(%v) at %s because: %s", receiver, method, args, origin, err) + } + + // Two things happen here: + // * the matching call no longer needs to check prerequite calls, + // * and the prerequite calls are no longer expected, so remove them. + preReqCalls := expected.dropPrereqs() + for _, preReqCall := range preReqCalls { + ctrl.expectedCalls.Remove(preReqCall) + } + + actions := expected.call(args) + if expected.exhausted() { + ctrl.expectedCalls.Remove(expected) + } + return actions + }() + + var rets []interface{} + for _, action := range actions { + if r := action(args); r != nil { + rets = r + } + } + + return rets +} + +// Finish checks to see if all the methods that were expected to be called +// were called. It should be invoked for each Controller. It is not idempotent +// and therefore can only be invoked once. +func (ctrl *Controller) Finish() { + ctrl.T.Helper() + + ctrl.mu.Lock() + defer ctrl.mu.Unlock() + + if ctrl.finished { + ctrl.T.Fatalf("Controller.Finish was called more than once. It has to be called exactly once.") + } + ctrl.finished = true + + // If we're currently panicking, probably because this is a deferred call, + // pass through the panic. + if err := recover(); err != nil { + panic(err) + } + + // Check that all remaining expected calls are satisfied. + failures := ctrl.expectedCalls.Failures() + for _, call := range failures { + ctrl.T.Errorf("missing call(s) to %v", call) + } + if len(failures) != 0 { + ctrl.T.Fatalf("aborting test due to missing call(s)") + } +} + +func callerInfo(skip int) string { + if _, file, line, ok := runtime.Caller(skip + 1); ok { + return fmt.Sprintf("%s:%d", file, line) + } + return "unknown file" +} diff --git a/vendor/github.com/golang/mock/gomock/matchers.go b/vendor/github.com/golang/mock/gomock/matchers.go new file mode 100644 index 000000000..fbff06062 --- /dev/null +++ b/vendor/github.com/golang/mock/gomock/matchers.go @@ -0,0 +1,141 @@ +// Copyright 2010 Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package gomock + +import ( + "fmt" + "reflect" +) + +// A Matcher is a representation of a class of values. +// It is used to represent the valid or expected arguments to a mocked method. +type Matcher interface { + // Matches returns whether x is a match. + Matches(x interface{}) bool + + // String describes what the matcher matches. + String() string +} + +type anyMatcher struct{} + +func (anyMatcher) Matches(x interface{}) bool { + return true +} + +func (anyMatcher) String() string { + return "is anything" +} + +type eqMatcher struct { + x interface{} +} + +func (e eqMatcher) Matches(x interface{}) bool { + return reflect.DeepEqual(e.x, x) +} + +func (e eqMatcher) String() string { + return fmt.Sprintf("is equal to %v", e.x) +} + +type nilMatcher struct{} + +func (nilMatcher) Matches(x interface{}) bool { + if x == nil { + return true + } + + v := reflect.ValueOf(x) + switch v.Kind() { + case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, + reflect.Ptr, reflect.Slice: + return v.IsNil() + } + + return false +} + +func (nilMatcher) String() string { + return "is nil" +} + +type notMatcher struct { + m Matcher +} + +func (n notMatcher) Matches(x interface{}) bool { + return !n.m.Matches(x) +} + +func (n notMatcher) String() string { + // TODO: Improve this if we add a NotString method to the Matcher interface. + return "not(" + n.m.String() + ")" +} + +type assignableToTypeOfMatcher struct { + targetType reflect.Type +} + +func (m assignableToTypeOfMatcher) Matches(x interface{}) bool { + return reflect.TypeOf(x).AssignableTo(m.targetType) +} + +func (m assignableToTypeOfMatcher) String() string { + return "is assignable to " + m.targetType.Name() +} + +// Constructors +// Any returns a matcher that always matches. +func Any() Matcher { return anyMatcher{} } + +// Eq returns a matcher that matches on equality. +// +// Example usage: +// Eq(5).Matches(5) // returns true +// Eq(5).Matches(4) // returns false +func Eq(x interface{}) Matcher { return eqMatcher{x} } + +// Nil returns a matcher that matches if the received value is nil. +// +// Example usage: +// var x *bytes.Buffer +// Nil().Matches(x) // returns true +// x = &bytes.Buffer{} +// Nil().Matches(x) // returns false +func Nil() Matcher { return nilMatcher{} } + +// Not reverses the results of its given child matcher. +// +// Example usage: +// Not(Eq(5)).Matches(4) // returns true +// Not(Eq(5)).Matches(5) // returns false +func Not(x interface{}) Matcher { + if m, ok := x.(Matcher); ok { + return notMatcher{m} + } + return notMatcher{Eq(x)} +} + +// AssignableToTypeOf is a Matcher that matches if the parameter to the mock +// function is assignable to the type of the parameter to this function. +// +// Example usage: +// var s fmt.Stringer = &bytes.Buffer{} +// AssignableToTypeOf(s).Matches(time.Second) // returns true +// AssignableToTypeOf(s).Matches(99) // returns false +func AssignableToTypeOf(x interface{}) Matcher { + return assignableToTypeOfMatcher{reflect.TypeOf(x)} +} diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE deleted file mode 100644 index c67dad612..000000000 --- a/vendor/github.com/pmezard/go-difflib/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -Copyright (c) 2013, Patrick Mezard -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - The names of its contributors may not be used to endorse or promote -products derived from this software without specific prior written -permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS -IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go deleted file mode 100644 index 003e99fad..000000000 --- a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go +++ /dev/null @@ -1,772 +0,0 @@ -// Package difflib is a partial port of Python difflib module. -// -// It provides tools to compare sequences of strings and generate textual diffs. -// -// The following class and functions have been ported: -// -// - SequenceMatcher -// -// - unified_diff -// -// - context_diff -// -// Getting unified diffs was the main goal of the port. Keep in mind this code -// is mostly suitable to output text differences in a human friendly way, there -// are no guarantees generated diffs are consumable by patch(1). -package difflib - -import ( - "bufio" - "bytes" - "fmt" - "io" - "strings" -) - -func min(a, b int) int { - if a < b { - return a - } - return b -} - -func max(a, b int) int { - if a > b { - return a - } - return b -} - -func calculateRatio(matches, length int) float64 { - if length > 0 { - return 2.0 * float64(matches) / float64(length) - } - return 1.0 -} - -type Match struct { - A int - B int - Size int -} - -type OpCode struct { - Tag byte - I1 int - I2 int - J1 int - J2 int -} - -// SequenceMatcher compares sequence of strings. The basic -// algorithm predates, and is a little fancier than, an algorithm -// published in the late 1980's by Ratcliff and Obershelp under the -// hyperbolic name "gestalt pattern matching". The basic idea is to find -// the longest contiguous matching subsequence that contains no "junk" -// elements (R-O doesn't address junk). The same idea is then applied -// recursively to the pieces of the sequences to the left and to the right -// of the matching subsequence. This does not yield minimal edit -// sequences, but does tend to yield matches that "look right" to people. -// -// SequenceMatcher tries to compute a "human-friendly diff" between two -// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the -// longest *contiguous* & junk-free matching subsequence. That's what -// catches peoples' eyes. The Windows(tm) windiff has another interesting -// notion, pairing up elements that appear uniquely in each sequence. -// That, and the method here, appear to yield more intuitive difference -// reports than does diff. This method appears to be the least vulnerable -// to synching up on blocks of "junk lines", though (like blank lines in -// ordinary text files, or maybe "
" lines in HTML files). That may be
-// because this is the only method of the 3 that has a *concept* of
-// "junk"