зеркало из https://github.com/Azure/ARO-RP.git
Initial commit
This commit is contained in:
Коммит
561fb3b639
|
@ -0,0 +1 @@
|
||||||
|
/env
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,79 @@
|
||||||
|
# Gopkg.toml example
|
||||||
|
#
|
||||||
|
# Refer to https://golang.github.io/dep/docs/Gopkg.toml.html
|
||||||
|
# for detailed Gopkg.toml documentation.
|
||||||
|
#
|
||||||
|
# required = ["github.com/user/thing/cmd/thing"]
|
||||||
|
# ignored = ["github.com/user/project/pkgX", "bitbucket.org/user/project/pkgA/pkgY"]
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project"
|
||||||
|
# version = "1.0.0"
|
||||||
|
#
|
||||||
|
# [[constraint]]
|
||||||
|
# name = "github.com/user/project2"
|
||||||
|
# branch = "dev"
|
||||||
|
# source = "github.com/myfork/project2"
|
||||||
|
#
|
||||||
|
# [[override]]
|
||||||
|
# name = "github.com/x/y"
|
||||||
|
# version = "2.4.0"
|
||||||
|
#
|
||||||
|
# [prune]
|
||||||
|
# non-go = false
|
||||||
|
# go-tests = true
|
||||||
|
# unused-packages = true
|
||||||
|
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "github.com/Azure/azure-sdk-for-go"
|
||||||
|
version = "33.4.0"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "k8s.io/api"
|
||||||
|
version = "kubernetes-1.14.0"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "k8s.io/apimachinery"
|
||||||
|
version = "kubernetes-1.14.0"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "k8s.io/client-go"
|
||||||
|
version = "kubernetes-1.14.0"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "k8s.io/utils"
|
||||||
|
revision = "c2654d5206da6b7b6ace12841e8f359bb89b443c"
|
||||||
|
|
||||||
|
[[override]]
|
||||||
|
name = "github.com/openshift/api"
|
||||||
|
branch = "release-4.2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/Azure/go-autorest"
|
||||||
|
version = "13.0.1"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/gorilla/mux"
|
||||||
|
version = "1.7.3"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/openshift/client-go"
|
||||||
|
branch = "release-4.2"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/openshift/installer"
|
||||||
|
branch = "release-4.2-azure"
|
||||||
|
source = "https://github.com/jim-minter/installer"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/satori/go.uuid"
|
||||||
|
version = "1.2.0"
|
||||||
|
|
||||||
|
[[constraint]]
|
||||||
|
name = "github.com/ugorji/go"
|
||||||
|
version = "1.1.7"
|
||||||
|
|
||||||
|
[prune]
|
||||||
|
go-tests = true
|
||||||
|
unused-packages = true
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,64 @@
|
||||||
|
## Useful links
|
||||||
|
|
||||||
|
https://github.com/Azure/azure-resource-manager-rpc
|
||||||
|
|
||||||
|
https://github.com/microsoft/api-guidelines
|
||||||
|
|
||||||
|
https://docs.microsoft.com/en-gb/rest/api/cosmos-db
|
||||||
|
|
||||||
|
https://docs.microsoft.com/en-gb/rest/api/storageservices/queue-service-rest-api
|
||||||
|
|
||||||
|
https://github.com/jim-minter/go-cosmosdb
|
||||||
|
|
||||||
|
## Getting started
|
||||||
|
|
||||||
|
* Copy env.example to env, edit the values and source it (`. ./env`)
|
||||||
|
|
||||||
|
* Deploy a CosmosDB SQL database and a v2 storage account to a resource group:
|
||||||
|
`az group create -g "$RP_RESOURCEGROUP" -l "$LOCATION"`
|
||||||
|
`az group deployment create -g "$RP_RESOURCEGROUP" --mode complete --template-file deploy/rp.json --parameters "location=$LOCATION" "storageAccountName=$STORAGE_ACCOUNT" "databaseAccountName=$COSMOSDB_ACCOUNT"`
|
||||||
|
|
||||||
|
* `go run ./cmd/rp`
|
||||||
|
|
||||||
|
## Useful commands
|
||||||
|
|
||||||
|
`export CLUSTER=cluster`
|
||||||
|
|
||||||
|
`curl -X PUT "localhost:8080/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$CLUSTER/providers/RedHat.OpenShift/OpenShiftClusters/$CLUSTER?api-version=2019-12-31-preview" -H 'Content-Type: application/json' -d '{"location":"'"$LOCATION"'", "properties": {"pullSecret": "'"$(base64 -w0 <<<$PULL_SECRET)"'"}}'`
|
||||||
|
|
||||||
|
`curl "localhost:8080/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$CLUSTER/providers/RedHat.OpenShift/OpenShiftClusters/$CLUSTER?api-version=2019-12-31-preview"`
|
||||||
|
|
||||||
|
`curl "localhost:8080/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$CLUSTER/providers/RedHat.OpenShift/OpenShiftClusters/$CLUSTER/credentials?api-version=2019-12-31-preview"`
|
||||||
|
|
||||||
|
`curl -X DELETE "localhost:8080/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$CLUSTER/providers/RedHat.OpenShift/OpenShiftClusters/$CLUSTER?api-version=2019-12-31-preview"`
|
||||||
|
|
||||||
|
## Basic architecture
|
||||||
|
|
||||||
|
* pkg/frontend is intended to become a spec-compliant RP web server. It is
|
||||||
|
backed by CosmosDB. Incoming PUT/DELETE requests are written to the database
|
||||||
|
with an Updating/Deleting provisioningState and unqueued flag set.
|
||||||
|
|
||||||
|
* pkg/queue/forwarder is a worker which spots unqueued documents, writes their
|
||||||
|
IDs into a queue and unsets the flag. It is intended that a document ID may
|
||||||
|
be accidently written to the queue more than once without ill effect.
|
||||||
|
|
||||||
|
* pkg/backend reads IDs off the queue and asynchronously updates desired state,
|
||||||
|
finally updating the database document with a terminal provisioningState
|
||||||
|
(Succeeded/Failed). The backend sends a heartbeat to the queue - if this
|
||||||
|
fails, the ID will be picked up by a different worker.
|
||||||
|
|
||||||
|
* As CosmosDB does not support document patch, care is taken to correctly pass
|
||||||
|
through any fields in the internal model which the reader is unaware of (see
|
||||||
|
`github.com/ugorji/go/codec.MissingFielder`). This is intended to help in
|
||||||
|
upgrade cases and (in the future) with multiple microservices reading from the
|
||||||
|
database in parallel.
|
||||||
|
|
||||||
|
* Care is taken to correctly use optimistic concurrency to avoid document
|
||||||
|
corruption through concurrent writes (see `RetryOnPreconditionFailed`).
|
||||||
|
|
||||||
|
* The pkg/api architecture differs somewhat from
|
||||||
|
`github.com/openshift/openshift-azure`: the intention is to fix the broken
|
||||||
|
merge semantics and try pushing validation into the versioned APIs to improve
|
||||||
|
error reporting.
|
||||||
|
|
||||||
|
* Everything is intended to be crash/restart/upgrade-safe...
|
|
@ -0,0 +1,20 @@
|
||||||
|
## TODO
|
||||||
|
|
||||||
|
* Installer: mustn't connect to Azure or write to .azure/osServicePrincipal.json
|
||||||
|
* Installer: must take credentials, resource group name as inputs
|
||||||
|
* Unit tests
|
||||||
|
* E2E tests
|
||||||
|
* Subscription lifecycle API (need clarity from Microsoft)
|
||||||
|
* RBAC? (need clarity from Microsoft)
|
||||||
|
* Metrics
|
||||||
|
* Admin API
|
||||||
|
* Adopt AMA if appropriate
|
||||||
|
* Signed cluster TLS certificates
|
||||||
|
* BBM
|
||||||
|
|
||||||
|
(Lower priority)
|
||||||
|
|
||||||
|
* Implement ARM move API
|
||||||
|
* Implement paging on list APIs
|
||||||
|
* Formal ARM asynchronous operation (Azure-AsyncOperation header)
|
||||||
|
* Make installer providers pluggable
|
|
@ -0,0 +1,105 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
_ "net/http/pprof"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"syscall"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/queue/leaser"
|
||||||
|
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure/auth"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
_ "github.com/jim-minter/rp/pkg/api/v20191231preview"
|
||||||
|
"github.com/jim-minter/rp/pkg/backend"
|
||||||
|
"github.com/jim-minter/rp/pkg/database"
|
||||||
|
"github.com/jim-minter/rp/pkg/database/cosmosdb"
|
||||||
|
"github.com/jim-minter/rp/pkg/frontend"
|
||||||
|
"github.com/jim-minter/rp/pkg/queue"
|
||||||
|
"github.com/jim-minter/rp/pkg/queue/forwarder"
|
||||||
|
)
|
||||||
|
|
||||||
|
func run(log *logrus.Entry) error {
|
||||||
|
for _, key := range []string{
|
||||||
|
"COSMOSDB_ACCOUNT",
|
||||||
|
"COSMOSDB_KEY",
|
||||||
|
"DOMAIN",
|
||||||
|
"DOMAIN_RESOURCEGROUP",
|
||||||
|
"STORAGE_ACCOUNT",
|
||||||
|
"STORAGE_KEY",
|
||||||
|
"LOCATION",
|
||||||
|
"HOME",
|
||||||
|
} {
|
||||||
|
if _, found := os.LookupEnv(key); !found {
|
||||||
|
return fmt.Errorf("environment variable %q unset", key)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dbc, err := cosmosdb.NewDatabaseClient(http.DefaultClient, os.Getenv("COSMOSDB_ACCOUNT"), os.Getenv("COSMOSDB_KEY"))
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
db := database.NewOpenShiftClusters(dbc, "OpenShiftClusters", "OpenShiftClusterDocuments")
|
||||||
|
|
||||||
|
authorizer, err := auth.NewAuthorizerFromEnvironment()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sigterm := make(chan os.Signal, 1)
|
||||||
|
done := make(chan struct{})
|
||||||
|
signal.Notify(sigterm, syscall.SIGTERM)
|
||||||
|
|
||||||
|
{
|
||||||
|
log := log.WithField("component", "backend")
|
||||||
|
q, err := queue.NewQueue(log, os.Getenv("STORAGE_ACCOUNT"), os.Getenv("STORAGE_KEY"), "openshiftclusterdocuments")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
go backend.NewBackend(log, authorizer, q, db).Run(done)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
log := log.WithField("component", "queue")
|
||||||
|
q, err := queue.NewQueue(log, os.Getenv("STORAGE_ACCOUNT"), os.Getenv("STORAGE_KEY"), "openshiftclusterdocuments")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
l := leaser.NewLeaser(log, dbc, "OpenShiftClusters", "Leases", "forwarder", 10*time.Second, 60*time.Second)
|
||||||
|
go forwarder.NewForwarder(log, q, db, l).Run(done)
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err := net.Listen("tcp", ":8080")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Print("listening")
|
||||||
|
|
||||||
|
go frontend.NewFrontend(log.WithField("component", "frontend"), l, db, api.APIs).Run(done)
|
||||||
|
|
||||||
|
<-sigterm
|
||||||
|
log.Print("received SIGTERM")
|
||||||
|
close(done)
|
||||||
|
|
||||||
|
select {}
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
logrus.SetReportCaller(true)
|
||||||
|
logrus.SetFormatter(&logrus.TextFormatter{
|
||||||
|
FullTimestamp: true,
|
||||||
|
DisableLevelTruncation: true,
|
||||||
|
})
|
||||||
|
log := logrus.NewEntry(logrus.StandardLogger())
|
||||||
|
|
||||||
|
if err := run(log); err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,119 @@
|
||||||
|
{
|
||||||
|
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||||
|
"contentVersion": "1.0.0.0",
|
||||||
|
"parameters": {
|
||||||
|
"location": {
|
||||||
|
"defaultValue": "eastus",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"storageAccountName": {
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"databaseAccountName": {
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"variables": {},
|
||||||
|
"resources": [
|
||||||
|
{
|
||||||
|
"name": "[parameters('databaseAccountName')]",
|
||||||
|
"type": "Microsoft.DocumentDB/databaseAccounts",
|
||||||
|
"apiVersion": "2015-04-08",
|
||||||
|
"location": "[parameters('location')]",
|
||||||
|
"tags": {
|
||||||
|
"defaultExperience": "Core (SQL)"
|
||||||
|
},
|
||||||
|
"kind": "GlobalDocumentDB",
|
||||||
|
"properties": {
|
||||||
|
"consistencyPolicy": {
|
||||||
|
"defaultConsistencyLevel": "Strong"
|
||||||
|
},
|
||||||
|
"locations": [
|
||||||
|
{
|
||||||
|
"locationName": "[parameters('location')]"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"databaseAccountOfferType": "Standard"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[concat(parameters('databaseAccountName'), '/sql/OpenShiftClusters')]",
|
||||||
|
"type": "Microsoft.DocumentDB/databaseAccounts/apis/databases",
|
||||||
|
"apiVersion": "2015-04-08",
|
||||||
|
"dependsOn": [
|
||||||
|
"[resourceId('Microsoft.DocumentDB/databaseAccounts/', parameters('databaseAccountName'))]"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"resource": {
|
||||||
|
"id": "OpenShiftClusters"
|
||||||
|
},
|
||||||
|
"options": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[concat(parameters('databaseAccountName'), '/sql/OpenShiftClusters/OpenShiftClusterDocuments')]",
|
||||||
|
"type": "Microsoft.DocumentDB/databaseAccounts/apis/databases/containers",
|
||||||
|
"apiVersion": "2015-04-08",
|
||||||
|
"dependsOn": [
|
||||||
|
"[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', parameters('databaseAccountName'), 'sql', 'OpenShiftClusters')]"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"resource": {
|
||||||
|
"id": "OpenShiftClusterDocuments",
|
||||||
|
"partitionKey": {
|
||||||
|
"paths": [
|
||||||
|
"/subscriptionId"
|
||||||
|
],
|
||||||
|
"kind": "Hash"
|
||||||
|
},
|
||||||
|
"uniqueKeyPolicy": {
|
||||||
|
"uniqueKeys": [
|
||||||
|
{
|
||||||
|
"paths": [
|
||||||
|
"/openShiftCluster/id"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[concat(parameters('databaseAccountName'), '/sql/OpenShiftClusters/Leases')]",
|
||||||
|
"type": "Microsoft.DocumentDB/databaseAccounts/apis/databases/containers",
|
||||||
|
"apiVersion": "2015-04-08",
|
||||||
|
"dependsOn": [
|
||||||
|
"[resourceId('Microsoft.DocumentDB/databaseAccounts/apis/databases', parameters('databaseAccountName'), 'sql', 'OpenShiftClusters')]"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"resource": {
|
||||||
|
"id": "Leases",
|
||||||
|
"defaultTtl": -1,
|
||||||
|
"partitionKey": {
|
||||||
|
"paths": [
|
||||||
|
"/id"
|
||||||
|
],
|
||||||
|
"kind": "Hash"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"options": {}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "[parameters('storageAccountName')]",
|
||||||
|
"type": "Microsoft.Storage/storageAccounts",
|
||||||
|
"apiVersion": "2019-04-01",
|
||||||
|
"location": "[parameters('location')]",
|
||||||
|
"sku": {
|
||||||
|
"name": "Standard_LRS"
|
||||||
|
},
|
||||||
|
"kind": "StorageV2",
|
||||||
|
"properties": {
|
||||||
|
"networkAcls": {
|
||||||
|
"defaultAction": "Allow"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
export AZURE_TENANT_ID=7a1815fb-63ba-4af7-8f33-e7333e421980
|
||||||
|
export AZURE_SUBSCRIPTION_ID=225e02bc-43d0-43d1-a01a-17e584a4ef69
|
||||||
|
export AZURE_CLIENT_ID=xxx
|
||||||
|
export AZURE_CLIENT_SECRET=xxx
|
||||||
|
|
||||||
|
export LOCATION=eastus
|
||||||
|
|
||||||
|
RP_RESOURCEGROUP=xxx
|
||||||
|
export COSMOSDB_ACCOUNT=xxx
|
||||||
|
export STORAGE_ACCOUNT=xxx
|
||||||
|
export COSMOSDB_KEY=$(az cosmosdb keys list -g $RP_RESOURCEGROUP -n $COSMOSDB_ACCOUNT --query primaryMasterKey -o tsv)
|
||||||
|
export STORAGE_KEY=$(az storage account keys list -g $RP_RESOURCEGROUP -n $STORAGE_ACCOUNT --query '[?keyName=='\''key1'\''].value' -o tsv)
|
||||||
|
|
||||||
|
export DOMAIN=osadev.cloud
|
||||||
|
export DOMAIN_RESOURCEGROUP=dns
|
||||||
|
|
||||||
|
export PULL_SECRET=xxx
|
|
@ -0,0 +1,52 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
// CloudError is a cloud error
|
||||||
|
type CloudError struct {
|
||||||
|
StatusCode int `json:"-"`
|
||||||
|
CloudErrorBody `json:"error,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (err *CloudError) Error() string {
|
||||||
|
return fmt.Sprintf("%d: %s: %s", err.StatusCode, err.Code, err.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudErrorBody is a cloud error body
|
||||||
|
type CloudErrorBody struct {
|
||||||
|
Code string `json:"code,omitempty"`
|
||||||
|
Message string `json:"message,omitempty"`
|
||||||
|
Target string `json:"target,omitempty"`
|
||||||
|
Details []CloudErrorBody `json:"details,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// CloudErrorCodes
|
||||||
|
var (
|
||||||
|
CloudErrorCodeInternalServerError = "InternalServerError"
|
||||||
|
CloudErrorCodeInvalidParameter = "InvalidParameter"
|
||||||
|
CloudErrorCodeInvalidRequestContent = "InvalidRequestContent"
|
||||||
|
CloudErrorCodeInvalidResource = "InvalidResource"
|
||||||
|
CloudErrorCodeInvalidResourceNamespace = "InvalidResourceNamespace"
|
||||||
|
CloudErrorCodeInvalidResourceType = "InvalidResourceType"
|
||||||
|
CloudErrorCodeInvalidSubscriptionID = "CloudErrorCodeInvalidSubscriptionID"
|
||||||
|
CloudErrorCodeMismatchingResourceID = "MismatchingResourceID"
|
||||||
|
CloudErrorCodeMismatchingResourceName = "MismatchingResourceName"
|
||||||
|
CloudErrorCodeMismatchingResourceType = "MismatchingResourceType"
|
||||||
|
CloudErrorCodePropertyChangeNotAllowed = "PropertyChangeNotAllowed"
|
||||||
|
CloudErrorCodeRequestNotAllowed = "RequestNotAllowed"
|
||||||
|
CloudErrorCodeResourceGroupNotFound = "ResourceGroupNotFound"
|
||||||
|
CloudErrorCodeResourceNotFound = "ResourceNotFound"
|
||||||
|
CloudErrorCodeUnsupportedMediaType = "UnsupportedMediaType"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NewCloudError returns a new CloudError
|
||||||
|
func NewCloudError(statusCode int, code, target, message string, a ...interface{}) *CloudError {
|
||||||
|
return &CloudError{
|
||||||
|
StatusCode: statusCode,
|
||||||
|
CloudErrorBody: CloudErrorBody{
|
||||||
|
Code: code,
|
||||||
|
Message: fmt.Sprintf(message, a...),
|
||||||
|
Target: target,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,3 @@
|
||||||
|
//go:generate go run github.com/alvaroloes/enumer -type InstallationPhase -output zz_generated_installationphase_enumer.go
|
||||||
|
|
||||||
|
package api
|
|
@ -0,0 +1,30 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LeaseDocuments represents a lease documents.
|
||||||
|
// pkg/database/cosmosdb requires its definition.
|
||||||
|
type LeaseDocuments struct {
|
||||||
|
Count int `json:"_count,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
LeaseDocuments []*LeaseDocument `json:"Documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// LeaseDocument represents a lease document.
|
||||||
|
// pkg/database/cosmosdb requires its definition.
|
||||||
|
type LeaseDocument struct {
|
||||||
|
MissingFields
|
||||||
|
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Timestamp int `json:"_ts,omitempty"`
|
||||||
|
Self string `json:"_self,omitempty"`
|
||||||
|
ETag string `json:"_etag,omitempty"`
|
||||||
|
Attachments string `json:"_attachments,omitempty"`
|
||||||
|
|
||||||
|
TTL int `json:"ttl,omitempty"`
|
||||||
|
|
||||||
|
Holder uuid.UUID `json:"holder,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rsa"
|
||||||
|
"crypto/x509"
|
||||||
|
"encoding/json"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/ugorji/go/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AddExtensions adds extensions to a ugorji/go/codec to enable it to serialise
|
||||||
|
// our types properly
|
||||||
|
func AddExtensions(h *codec.BasicHandle) error {
|
||||||
|
err := h.AddExt(reflect.TypeOf(&rsa.PrivateKey{}), 0, func(v reflect.Value) ([]byte, error) {
|
||||||
|
if reflect.DeepEqual(v.Elem().Interface(), rsa.PrivateKey{}) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
return x509.MarshalPKCS1PrivateKey(v.Interface().(*rsa.PrivateKey)), nil
|
||||||
|
}, func(v reflect.Value, b []byte) error {
|
||||||
|
key, err := x509.ParsePKCS1PrivateKey(b)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
v.Elem().Set(reflect.ValueOf(key).Elem())
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON marshals an InstallationPhase
|
||||||
|
func (p InstallationPhase) MarshalJSON() ([]byte, error) {
|
||||||
|
return json.Marshal(p.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals an InstallationPhase
|
||||||
|
func (p *InstallationPhase) UnmarshalJSON(b []byte) error {
|
||||||
|
var s string
|
||||||
|
err := json.Unmarshal(b, &s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*p, err = InstallationPhaseString(s)
|
||||||
|
return err
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
// MissingFields retains values that do not map to struct fields during JSON
|
||||||
|
// marshalling/unmarshalling. MissingFields implements
|
||||||
|
// github.com/ugorji/go/codec.MissingFielder.
|
||||||
|
type MissingFields struct {
|
||||||
|
m map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CodecMissingField is called to set a missing field and value pair
|
||||||
|
func (mf *MissingFields) CodecMissingField(field []byte, value interface{}) bool {
|
||||||
|
if mf.m == nil {
|
||||||
|
mf.m = map[string]interface{}{}
|
||||||
|
}
|
||||||
|
(mf.m)[string(field)] = value
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// CodecMissingFields returns the set of fields which are not struct fields
|
||||||
|
func (mf *MissingFields) CodecMissingFields() map[string]interface{} {
|
||||||
|
return mf.m
|
||||||
|
}
|
|
@ -0,0 +1,103 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/rsa"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OpenShiftCluster represents an OpenShift cluster
|
||||||
|
type OpenShiftCluster struct {
|
||||||
|
MissingFields
|
||||||
|
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
Location string `json:"location,omitempty"`
|
||||||
|
Tags map[string]string `json:"tags,omitempty"`
|
||||||
|
Properties Properties `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Properties represents an OpenShift cluster's properties
|
||||||
|
type Properties struct {
|
||||||
|
MissingFields
|
||||||
|
|
||||||
|
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
|
||||||
|
|
||||||
|
PullSecret []byte `json:"pullSecret,omitempty"` // w/o
|
||||||
|
|
||||||
|
NetworkProfile NetworkProfile `json:"networkProfile,omitempty"`
|
||||||
|
|
||||||
|
MasterProfile MasterProfile `json:"masterProfile,omitempty"`
|
||||||
|
|
||||||
|
WorkerProfiles []WorkerProfile `json:"workerProfiles,omitempty"`
|
||||||
|
|
||||||
|
APIServerURL string `json:"apiserverURL,omitempty"` // r/o
|
||||||
|
ConsoleURL string `json:"consoleURL,omitempty"` // r/o
|
||||||
|
|
||||||
|
Installation *Installation `json:"installation,omitempty"`
|
||||||
|
|
||||||
|
ResourceGroup string `json:"resourceGroup,omitempty"`
|
||||||
|
StorageSuffix string `json:"storageSuffix,omitempty"`
|
||||||
|
|
||||||
|
SSHKey *rsa.PrivateKey `json:"sshKey,omitempty"`
|
||||||
|
AdminKubeconfig []byte `json:"adminKubeconfig,omitempty"`
|
||||||
|
KubeadminPassword string `json:"kubeadminPassword,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProvisioningState represents a provisioning state
|
||||||
|
type ProvisioningState string
|
||||||
|
|
||||||
|
// ProvisioningState constants
|
||||||
|
const (
|
||||||
|
ProvisioningStateUpdating ProvisioningState = "Updating"
|
||||||
|
ProvisioningStateDeleting ProvisioningState = "Deleting"
|
||||||
|
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
|
||||||
|
ProvisioningStateFailed ProvisioningState = "Failed"
|
||||||
|
)
|
||||||
|
|
||||||
|
type NetworkProfile struct {
|
||||||
|
VNetCIDR string `json:"vnetCidr,omitempty"`
|
||||||
|
PodCIDR string `json:"podCidr,omitempty"`
|
||||||
|
ServiceCIDR string `json:"serviceCidr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MasterProfile represents a master profile
|
||||||
|
type MasterProfile struct {
|
||||||
|
VMSize VMSize `json:"vmSize,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VMSize represents a VM size
|
||||||
|
type VMSize string
|
||||||
|
|
||||||
|
// VMSize constants
|
||||||
|
const (
|
||||||
|
VMSizeStandardD2sV3 VMSize = "Standard_D2s_v3"
|
||||||
|
VMSizeStandardD4sV3 VMSize = "Standard_D4s_v3"
|
||||||
|
VMSizeStandardD8sV3 VMSize = "Standard_D8s_v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WorkerProfile represents a worker profile
|
||||||
|
type WorkerProfile struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
VMSize VMSize `json:"vmSize,omitempty"`
|
||||||
|
DiskSizeGB int `json:"diskSizeGB,omitempty"`
|
||||||
|
Count int `json:"count,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Installation represents an installation process
|
||||||
|
type Installation struct {
|
||||||
|
MissingFields
|
||||||
|
|
||||||
|
Now time.Time `json:"now,omitempty"`
|
||||||
|
Phase InstallationPhase `json:"phase"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationPhase represents an installation phase
|
||||||
|
type InstallationPhase int
|
||||||
|
|
||||||
|
// InstallationPhase constants
|
||||||
|
const (
|
||||||
|
InstallationPhaseDeployStorage InstallationPhase = iota
|
||||||
|
InstallationPhaseDeployResources
|
||||||
|
InstallationPhaseRemoveBootstrap
|
||||||
|
)
|
|
@ -0,0 +1,28 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
// OpenShiftClusterDocuments represents OpenShift cluster documents.
|
||||||
|
// pkg/database/cosmosdb requires its definition.
|
||||||
|
type OpenShiftClusterDocuments struct {
|
||||||
|
Count int `json:"_count,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
OpenShiftClusterDocuments []*OpenShiftClusterDocument `json:"Documents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenShiftClusterDocument represents an OpenShift cluster document.
|
||||||
|
// pkg/database/cosmosdb requires its definition.
|
||||||
|
type OpenShiftClusterDocument struct {
|
||||||
|
MissingFields
|
||||||
|
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Timestamp int `json:"_ts,omitempty"`
|
||||||
|
Self string `json:"_self,omitempty"`
|
||||||
|
ETag string `json:"_etag,omitempty"`
|
||||||
|
Attachments string `json:"_attachments,omitempty"`
|
||||||
|
|
||||||
|
SubscriptionID string `json:"subscriptionId,omitempty"` // partition key
|
||||||
|
|
||||||
|
OpenShiftCluster *OpenShiftCluster `json:"openShiftCluster,omitempty"`
|
||||||
|
|
||||||
|
Unqueued bool `json:"unqueued,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package api
|
||||||
|
|
||||||
|
// External is the interface that an external API must implement
|
||||||
|
type External interface {
|
||||||
|
Validate(string, *OpenShiftCluster) error
|
||||||
|
ToInternal(*OpenShiftCluster)
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIVersionType represents an APIVersion and a Type
|
||||||
|
type APIVersionType struct {
|
||||||
|
APIVersion string
|
||||||
|
Type string
|
||||||
|
}
|
||||||
|
|
||||||
|
// APIs is the map of registered external APIs
|
||||||
|
var APIs = map[APIVersionType]func(*OpenShiftCluster) External{}
|
|
@ -0,0 +1,71 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
// OpenShiftCluster represents an OpenShift cluster
|
||||||
|
type OpenShiftCluster struct {
|
||||||
|
ID string `json:"id,omitempty"` // GET only
|
||||||
|
Name string `json:"name,omitempty"` // GET only
|
||||||
|
Type string `json:"type,omitempty"` // GET only
|
||||||
|
Location string `json:"location,omitempty"` // r/o
|
||||||
|
Tags Tags `json:"tags,omitempty"`
|
||||||
|
Properties Properties `json:"properties,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tags represents an OpenShift cluster's tags
|
||||||
|
type Tags map[string]string
|
||||||
|
|
||||||
|
// Properties represents an OpenShift cluster's properties
|
||||||
|
type Properties struct {
|
||||||
|
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` // r/o
|
||||||
|
|
||||||
|
PullSecret []byte `json:"pullSecret,omitempty"` // w/o
|
||||||
|
|
||||||
|
NetworkProfile NetworkProfile `json:"networkProfile,omitempty"`
|
||||||
|
|
||||||
|
MasterProfile MasterProfile `json:"masterProfile,omitempty"`
|
||||||
|
|
||||||
|
WorkerProfiles []WorkerProfile `json:"workerProfiles,omitempty"`
|
||||||
|
|
||||||
|
APIServerURL string `json:"apiserverURL,omitempty"` // r/o
|
||||||
|
ConsoleURL string `json:"consoleURL,omitempty"` // r/o
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProvisioningState represents a provisioning state
|
||||||
|
type ProvisioningState string
|
||||||
|
|
||||||
|
// ProvisioningState constants
|
||||||
|
const (
|
||||||
|
ProvisioningStateUpdating ProvisioningState = "Updating"
|
||||||
|
ProvisioningStateDeleting ProvisioningState = "Deleting"
|
||||||
|
ProvisioningStateSucceeded ProvisioningState = "Succeeded"
|
||||||
|
ProvisioningStateFailed ProvisioningState = "Failed"
|
||||||
|
)
|
||||||
|
|
||||||
|
// NetworkProfile represents a network profile
|
||||||
|
type NetworkProfile struct {
|
||||||
|
VNetCIDR string `json:"vnetCidr,omitempty"`
|
||||||
|
PodCIDR string `json:"podCidr,omitempty"`
|
||||||
|
ServiceCIDR string `json:"serviceCidr,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MasterProfile represents a master profile
|
||||||
|
type MasterProfile struct {
|
||||||
|
VMSize VMSize `json:"vmSize,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// VMSize represents a VM size
|
||||||
|
type VMSize string
|
||||||
|
|
||||||
|
// VMSize constants
|
||||||
|
const (
|
||||||
|
VMSizeStandardD2sV3 VMSize = "Standard_D2s_v3"
|
||||||
|
VMSizeStandardD4sV3 VMSize = "Standard_D4s_v3"
|
||||||
|
VMSizeStandardD8sV3 VMSize = "Standard_D8s_v3"
|
||||||
|
)
|
||||||
|
|
||||||
|
// WorkerProfile represents a worker profile
|
||||||
|
type WorkerProfile struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
VMSize VMSize `json:"vmSize,omitempty"`
|
||||||
|
DiskSizeGB int `json:"diskSizeGB,omitempty"`
|
||||||
|
Count int `json:"count,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OpenShiftClusterToExternal returns a new external representation of the
|
||||||
|
// internal object, reading from the subset of the internal object's fields that
|
||||||
|
// appear in the external representation. ToExternal does not modify its
|
||||||
|
// argument; there is no pointer aliasing between the passed and returned
|
||||||
|
// objects.
|
||||||
|
func OpenShiftClusterToExternal(oc *api.OpenShiftCluster) *OpenShiftCluster {
|
||||||
|
out := &OpenShiftCluster{
|
||||||
|
ID: oc.ID,
|
||||||
|
Name: oc.Name,
|
||||||
|
Type: oc.Type,
|
||||||
|
Location: oc.Location,
|
||||||
|
Properties: Properties{
|
||||||
|
ProvisioningState: ProvisioningState(oc.Properties.ProvisioningState),
|
||||||
|
PullSecret: append([]byte(nil), oc.Properties.PullSecret...),
|
||||||
|
NetworkProfile: NetworkProfile{
|
||||||
|
VNetCIDR: oc.Properties.NetworkProfile.VNetCIDR,
|
||||||
|
PodCIDR: oc.Properties.NetworkProfile.PodCIDR,
|
||||||
|
ServiceCIDR: oc.Properties.NetworkProfile.ServiceCIDR,
|
||||||
|
},
|
||||||
|
MasterProfile: MasterProfile{
|
||||||
|
VMSize: VMSize(oc.Properties.MasterProfile.VMSize),
|
||||||
|
},
|
||||||
|
APIServerURL: oc.Properties.APIServerURL,
|
||||||
|
ConsoleURL: oc.Properties.ConsoleURL,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
if oc.Properties.WorkerProfiles != nil {
|
||||||
|
out.Properties.WorkerProfiles = make([]WorkerProfile, 0, len(oc.Properties.WorkerProfiles))
|
||||||
|
for _, p := range oc.Properties.WorkerProfiles {
|
||||||
|
out.Properties.WorkerProfiles = append(out.Properties.WorkerProfiles, WorkerProfile{
|
||||||
|
Name: p.Name,
|
||||||
|
VMSize: VMSize(p.VMSize),
|
||||||
|
DiskSizeGB: p.DiskSizeGB,
|
||||||
|
Count: p.Count,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if oc.Tags != nil {
|
||||||
|
out.Tags = make(map[string]string, len(oc.Tags))
|
||||||
|
for k, v := range oc.Tags {
|
||||||
|
out.Tags[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToInternal overwrites in place a pre-existing internal object, setting (only)
|
||||||
|
// all mapped fields from the external representation. ToInternal modifies its
|
||||||
|
// argument; there is no pointer aliasing between the passed and returned
|
||||||
|
// objects.
|
||||||
|
func (oc *OpenShiftCluster) ToInternal(out *api.OpenShiftCluster) {
|
||||||
|
out.ID = oc.ID
|
||||||
|
out.Name = oc.Name
|
||||||
|
out.Type = oc.Type
|
||||||
|
out.Location = oc.Location
|
||||||
|
out.Tags = nil
|
||||||
|
if oc.Tags != nil {
|
||||||
|
out.Tags = make(map[string]string, len(oc.Tags))
|
||||||
|
for k, v := range oc.Tags {
|
||||||
|
out.Tags[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.Properties.ProvisioningState = api.ProvisioningState(oc.Properties.ProvisioningState)
|
||||||
|
out.Properties.PullSecret = append([]byte(nil), oc.Properties.PullSecret...)
|
||||||
|
out.Properties.NetworkProfile.VNetCIDR = oc.Properties.NetworkProfile.VNetCIDR
|
||||||
|
out.Properties.NetworkProfile.PodCIDR = oc.Properties.NetworkProfile.PodCIDR
|
||||||
|
out.Properties.NetworkProfile.ServiceCIDR = oc.Properties.NetworkProfile.ServiceCIDR
|
||||||
|
out.Properties.MasterProfile.VMSize = api.VMSize(oc.Properties.MasterProfile.VMSize)
|
||||||
|
for _, p := range oc.Properties.WorkerProfiles {
|
||||||
|
var outp *api.WorkerProfile
|
||||||
|
for i, pp := range out.Properties.WorkerProfiles {
|
||||||
|
if pp.Name == p.Name {
|
||||||
|
outp = &out.Properties.WorkerProfiles[i]
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if outp == nil {
|
||||||
|
out.Properties.WorkerProfiles = append(out.Properties.WorkerProfiles, api.WorkerProfile{})
|
||||||
|
outp = &out.Properties.WorkerProfiles[len(out.Properties.WorkerProfiles)-1]
|
||||||
|
}
|
||||||
|
outp.Name = p.Name
|
||||||
|
outp.VMSize = api.VMSize(p.VMSize)
|
||||||
|
outp.DiskSizeGB = p.DiskSizeGB
|
||||||
|
outp.Count = p.Count
|
||||||
|
}
|
||||||
|
out.Properties.APIServerURL = oc.Properties.APIServerURL
|
||||||
|
out.Properties.ConsoleURL = oc.Properties.ConsoleURL
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UnmarshalJSON unmarshals tags. We override this to ensure that PATCH
|
||||||
|
// behaviour overwrites an existing tags map rather than endlessly adding to it
|
||||||
|
func (t *Tags) UnmarshalJSON(b []byte) error {
|
||||||
|
var m map[string]string
|
||||||
|
err := json.Unmarshal(b, &m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
*t = m
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,247 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/apparentlymart/go-cidr/cidr"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/util/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Validate validates an OpenShift cluster
|
||||||
|
func (oc *OpenShiftCluster) Validate(resourceID string, current *api.OpenShiftCluster) error {
|
||||||
|
err := oc.validate(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if current == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return oc.validateDelta(OpenShiftClusterToExternal(current))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oc *OpenShiftCluster) validate(resourceID string) error {
|
||||||
|
resourceName, err := resource.ResourceName(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !strings.EqualFold(oc.ID, resourceID) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceID, "id", "The provided resource ID '%s' did not match the name in the Url '%s'.", oc.ID, resourceID)
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(oc.Name, resourceName) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceName, "name", "The provided resource name '%s' did not match the name in the Url '%s'.", oc.Name, resourceName)
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(oc.Type, resourceProviderNamespace+"/"+resourceType) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeMismatchingResourceType, "type", "The provided resource type '%s' did not match the name in the Url '%s'.", oc.Type, resourceProviderNamespace+"/"+resourceType)
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(oc.Location, os.Getenv("LOCATION")) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "location", "The provided location '%s' is invalid.", oc.Location)
|
||||||
|
}
|
||||||
|
|
||||||
|
return oc.Properties.validate("properties")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Properties) validate(path string) error {
|
||||||
|
switch p.ProvisioningState {
|
||||||
|
case ProvisioningStateUpdating, ProvisioningStateDeleting,
|
||||||
|
ProvisioningStateSucceeded, ProvisioningStateFailed:
|
||||||
|
default:
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".provisioningState", "The provided provisioning state '%s' is invalid.", p.ProvisioningState)
|
||||||
|
}
|
||||||
|
if !json.Valid(p.PullSecret) ||
|
||||||
|
!bytes.HasPrefix(p.PullSecret, []byte("{")) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".pullSecret", "The provided pull secret is invalid.")
|
||||||
|
}
|
||||||
|
if err := p.NetworkProfile.validate(path + ".networkProfile"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.MasterProfile.validate(path + ".masterProfile"); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if len(p.WorkerProfiles) != 1 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".workerProfiles", "There should be exactly one worker profile.")
|
||||||
|
}
|
||||||
|
if err := p.WorkerProfiles[0].validate(path + `.workerProfiles["` + p.WorkerProfiles[0].Name + `"]`); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if p.APIServerURL != "" {
|
||||||
|
if _, err := url.Parse(p.APIServerURL); err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".apiserverURL", "The provided API server URL '%s' is invalid.", p.APIServerURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if p.ConsoleURL != "" {
|
||||||
|
if _, err := url.Parse(p.ConsoleURL); err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".consoleURL", "The provided console URL '%s' is invalid.", p.ConsoleURL)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (np *NetworkProfile) validate(path string) error {
|
||||||
|
_, vnet, err := net.ParseCIDR(np.VNetCIDR)
|
||||||
|
if err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vnetCidr", "The provided vnet CIDR '%s' is invalid: %q.", np.VNetCIDR, err)
|
||||||
|
}
|
||||||
|
if vnet.IP.To4() == nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vnetCidr", "The provided vnet CIDR '%s' is invalid: must be IPv4.", np.VNetCIDR)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ones, _ := vnet.Mask.Size()
|
||||||
|
if ones > 24 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vnetCidr", "The provided vnet CIDR '%s' is invalid: must be /24 or larger.", np.VNetCIDR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, pod, err := net.ParseCIDR(np.PodCIDR)
|
||||||
|
if err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: %q.", np.PodCIDR, err)
|
||||||
|
}
|
||||||
|
if pod.IP.To4() == nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided pod CIDR '%s' is invalid: must be IPv4.", np.PodCIDR)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ones, _ := pod.Mask.Size()
|
||||||
|
if ones > 18 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".podCidr", "The provided vnet CIDR '%s' is invalid: must be /18 or larger.", np.PodCIDR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_, service, err := net.ParseCIDR(np.ServiceCIDR)
|
||||||
|
if err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".serviceCidr", "The provided service CIDR '%s' is invalid: %q.", np.ServiceCIDR, err)
|
||||||
|
}
|
||||||
|
if service.IP.To4() == nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".serviceCidr", "The provided service CIDR '%s' is invalid: must be IPv4.", np.ServiceCIDR)
|
||||||
|
}
|
||||||
|
{
|
||||||
|
ones, _ := service.Mask.Size()
|
||||||
|
if ones > 22 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".serviceCidr", "The provided vnet CIDR '%s' is invalid: must be /22 or larger.", np.ServiceCIDR)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = cidr.VerifyNoOverlap([]*net.IPNet{vnet, pod, service}, &net.IPNet{IP: net.IPv4zero, Mask: net.IPMask(net.IPv4zero)}); err != nil {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "", "The provided CIDRs must not overlap: %q.", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mp *MasterProfile) validate(path string) error {
|
||||||
|
switch mp.VMSize {
|
||||||
|
case VMSizeStandardD8sV3:
|
||||||
|
default:
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided VM size '%s' is invalid.", mp.VMSize)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wp *WorkerProfile) validate(path string) error {
|
||||||
|
if wp.Name != "worker" {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".name", "The provided name '%s' is invalid.", wp.Name)
|
||||||
|
}
|
||||||
|
switch wp.VMSize {
|
||||||
|
case VMSizeStandardD2sV3, VMSizeStandardD4sV3, VMSizeStandardD8sV3:
|
||||||
|
default:
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".vmSize", "The provided VM size '%s' is invalid.", wp.VMSize)
|
||||||
|
}
|
||||||
|
if wp.DiskSizeGB < 128 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".diskSizeGB", "The provided disk size '%d' is invalid.", wp.DiskSizeGB)
|
||||||
|
}
|
||||||
|
if wp.Count < 3 || wp.Count > 20 {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, path+".count", "The provided count '%d' is invalid.", wp.Count)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (oc *OpenShiftCluster) validateDelta(current *OpenShiftCluster) error {
|
||||||
|
if !strings.EqualFold(current.ID, oc.ID) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, "id", "Changing property 'id' is not allowed.")
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(current.Name, oc.Name) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, "name", "Changing property 'name' is not allowed.")
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(current.Type, oc.Type) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, "type", "Changing property 'type' is not allowed.")
|
||||||
|
}
|
||||||
|
if !strings.EqualFold(current.Location, oc.Location) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, "location", "Changing property 'location' is not allowed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return oc.Properties.validateDelta("properties", ¤t.Properties)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Properties) validateDelta(path string, current *Properties) error {
|
||||||
|
if current.ProvisioningState != p.ProvisioningState {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".provisioningState", "Changing property '"+path+".provisioningState' is not allowed.")
|
||||||
|
}
|
||||||
|
if !bytes.Equal(current.PullSecret, p.PullSecret) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".pullSecret", "Changing property '"+path+".pullSecret' is not allowed.")
|
||||||
|
}
|
||||||
|
if err := p.NetworkProfile.validateDelta(path+".networkProfile", ¤t.NetworkProfile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.MasterProfile.validateDelta(path+".masterProfile", ¤t.MasterProfile); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if err := p.WorkerProfiles[0].validateDelta(path+`.workerProfiles["`+p.WorkerProfiles[0].Name+`"]`, ¤t.WorkerProfiles[0]); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if current.APIServerURL != p.APIServerURL {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".apiserverURL", "Changing property '"+path+".apiserverURL' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.ConsoleURL != p.ConsoleURL {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".consoleURL", "Changing property '"+path+".consoleURL' is not allowed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (np *NetworkProfile) validateDelta(path string, current *NetworkProfile) error {
|
||||||
|
if current.VNetCIDR != np.VNetCIDR {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".vnetCidr", "Changing property '"+path+".vnetCidr' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.PodCIDR != np.PodCIDR {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".podCidr", "Changing property '"+path+".podCidr' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.ServiceCIDR != np.ServiceCIDR {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".serviceCidr", "Changing property '"+path+".serviceCidr' is not allowed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (mp *MasterProfile) validateDelta(path string, current *MasterProfile) error {
|
||||||
|
if current.VMSize != mp.VMSize {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".vmSize", "Changing property '"+path+".vmSize' is not allowed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (wp *WorkerProfile) validateDelta(path string, current *WorkerProfile) error {
|
||||||
|
if current.Name != wp.Name {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".name", "Changing property '"+path+".name' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.VMSize != wp.VMSize {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".vmSize", "Changing property '"+path+".vmSize' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.DiskSizeGB != wp.DiskSizeGB {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".diskSizeGB", "Changing property '"+path+".diskSizeGB' is not allowed.")
|
||||||
|
}
|
||||||
|
if current.Count != wp.Count {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, path+".count", "Changing property '"+path+".count' is not allowed.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,6 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
// OpenShiftClusterCredentials represents an OpenShift cluster's credentials
|
||||||
|
type OpenShiftClusterCredentials struct {
|
||||||
|
KubeadminPassword string `json:"kubeadminPassword,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OpenShiftClusterCredentialsToExternal returns a new external representation
|
||||||
|
// of the internal object, reading from the subset of the internal object's
|
||||||
|
// fields that appear in the external representation. ToExternal does not
|
||||||
|
// modify its argument; there is no pointer aliasing between the passed and
|
||||||
|
// returned objects.
|
||||||
|
func OpenShiftClusterCredentialsToExternal(oc *api.OpenShiftCluster) *OpenShiftClusterCredentials {
|
||||||
|
out := &OpenShiftClusterCredentials{
|
||||||
|
KubeadminPassword: oc.Properties.KubeadminPassword,
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
// ToInternal overwrites in place a pre-existing internal object, setting (only)
|
||||||
|
// all mapped fields from the external representation. ToInternal modifies its
|
||||||
|
// argument; there is no pointer aliasing between the passed and returned
|
||||||
|
// objects.
|
||||||
|
func (occ *OpenShiftClusterCredentials) ToInternal(out *api.OpenShiftCluster) {
|
||||||
|
out.Properties.KubeadminPassword = occ.KubeadminPassword
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
var rxKubeadminPassword = regexp.MustCompile(`(?i)^[-a-z0-9]{0,64}$`)
|
||||||
|
|
||||||
|
// Validate validates an OpenShift cluster's credentials
|
||||||
|
func (occ *OpenShiftClusterCredentials) Validate(resourceID string, current *api.OpenShiftCluster) error {
|
||||||
|
err := occ.validate(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if current == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return occ.validateDelta(OpenShiftClusterToExternal(current))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (occ *OpenShiftClusterCredentials) validate(resourceID string) error {
|
||||||
|
if !rxKubeadminPassword.MatchString(occ.KubeadminPassword) {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidParameter, "kubeadminPassword", "The provided kubeadmin password is invalid.")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (occ *OpenShiftClusterCredentials) validateDelta(current *OpenShiftCluster) error {
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodePropertyChangeNotAllowed, "kubeadminPassword", "Changing property 'kubeadminPassword' is not allowed.")
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package v20191231preview
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
resourceProviderNamespace = "RedHat.OpenShift"
|
||||||
|
resourceType = "OpenShiftClusters"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
api.APIs[api.APIVersionType{APIVersion: "2019-12-31-preview", Type: "OpenShiftCluster"}] = func(oc *api.OpenShiftCluster) api.External {
|
||||||
|
return OpenShiftClusterToExternal(oc)
|
||||||
|
}
|
||||||
|
|
||||||
|
api.APIs[api.APIVersionType{APIVersion: "2019-12-31-preview", Type: "OpenShiftClusterCredentials"}] = func(oc *api.OpenShiftCluster) api.External {
|
||||||
|
return OpenShiftClusterCredentialsToExternal(oc)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,51 @@
|
||||||
|
// Code generated by "enumer -type InstallationPhase -output zz_generated_installationphase_enumer.go"; DO NOT EDIT.
|
||||||
|
|
||||||
|
//
|
||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
)
|
||||||
|
|
||||||
|
const _InstallationPhaseName = "InstallationPhaseDeployStorageInstallationPhaseDeployResourcesInstallationPhaseRemoveBootstrap"
|
||||||
|
|
||||||
|
var _InstallationPhaseIndex = [...]uint8{0, 30, 62, 94}
|
||||||
|
|
||||||
|
func (i InstallationPhase) String() string {
|
||||||
|
if i < 0 || i >= InstallationPhase(len(_InstallationPhaseIndex)-1) {
|
||||||
|
return fmt.Sprintf("InstallationPhase(%d)", i)
|
||||||
|
}
|
||||||
|
return _InstallationPhaseName[_InstallationPhaseIndex[i]:_InstallationPhaseIndex[i+1]]
|
||||||
|
}
|
||||||
|
|
||||||
|
var _InstallationPhaseValues = []InstallationPhase{0, 1, 2}
|
||||||
|
|
||||||
|
var _InstallationPhaseNameToValueMap = map[string]InstallationPhase{
|
||||||
|
_InstallationPhaseName[0:30]: 0,
|
||||||
|
_InstallationPhaseName[30:62]: 1,
|
||||||
|
_InstallationPhaseName[62:94]: 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationPhaseString retrieves an enum value from the enum constants string name.
|
||||||
|
// Throws an error if the param is not part of the enum.
|
||||||
|
func InstallationPhaseString(s string) (InstallationPhase, error) {
|
||||||
|
if val, ok := _InstallationPhaseNameToValueMap[s]; ok {
|
||||||
|
return val, nil
|
||||||
|
}
|
||||||
|
return 0, fmt.Errorf("%s does not belong to InstallationPhase values", s)
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstallationPhaseValues returns all values of the enum
|
||||||
|
func InstallationPhaseValues() []InstallationPhase {
|
||||||
|
return _InstallationPhaseValues
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsAInstallationPhase returns "true" if the value is listed in the enum definition. "false" otherwise
|
||||||
|
func (i InstallationPhase) IsAInstallationPhase() bool {
|
||||||
|
for _, v := range _InstallationPhaseValues {
|
||||||
|
if i == v {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
|
@ -0,0 +1,185 @@
|
||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"runtime/debug"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database"
|
||||||
|
"github.com/jim-minter/rp/pkg/queue"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
maxWorkers = 100
|
||||||
|
maxDequeueCount = 5
|
||||||
|
)
|
||||||
|
|
||||||
|
type backend struct {
|
||||||
|
baseLog *logrus.Entry
|
||||||
|
q queue.Queue
|
||||||
|
db database.OpenShiftClusters
|
||||||
|
|
||||||
|
authorizer autorest.Authorizer
|
||||||
|
|
||||||
|
mu sync.Mutex
|
||||||
|
cond *sync.Cond
|
||||||
|
workers int
|
||||||
|
stopping bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runnable represents a runnable object
|
||||||
|
type Runnable interface {
|
||||||
|
Run(stop <-chan struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBackend returns a new runnable backend
|
||||||
|
func NewBackend(log *logrus.Entry, authorizer autorest.Authorizer, q queue.Queue, db database.OpenShiftClusters) Runnable {
|
||||||
|
b := &backend{
|
||||||
|
baseLog: log,
|
||||||
|
q: q,
|
||||||
|
db: db,
|
||||||
|
|
||||||
|
authorizer: authorizer,
|
||||||
|
}
|
||||||
|
|
||||||
|
b.cond = sync.NewCond(&b.mu)
|
||||||
|
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backend) Run(stop <-chan struct{}) {
|
||||||
|
t := time.NewTicker(time.Second)
|
||||||
|
defer t.Stop()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-stop
|
||||||
|
b.mu.Lock()
|
||||||
|
b.stopping = true
|
||||||
|
b.mu.Unlock()
|
||||||
|
b.cond.Signal()
|
||||||
|
}()
|
||||||
|
|
||||||
|
out:
|
||||||
|
for {
|
||||||
|
b.mu.Lock()
|
||||||
|
for b.workers == maxWorkers && !b.stopping {
|
||||||
|
b.cond.Wait()
|
||||||
|
}
|
||||||
|
b.mu.Unlock()
|
||||||
|
|
||||||
|
m, err := b.q.Get()
|
||||||
|
switch {
|
||||||
|
case err != nil:
|
||||||
|
b.baseLog.Error(err)
|
||||||
|
|
||||||
|
case m != nil:
|
||||||
|
log := b.baseLog.WithField("resource", m.ID())
|
||||||
|
if m.DequeueCount() == maxDequeueCount {
|
||||||
|
log.Warnf("dequeued %d times, failing", maxDequeueCount)
|
||||||
|
b.db.Patch(m.ID(), func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateFailed
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
m.Done(nil)
|
||||||
|
} else {
|
||||||
|
log.Print("dequeued")
|
||||||
|
go b.handle(context.Background(), log, m)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-stop:
|
||||||
|
break out
|
||||||
|
default:
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-t.C:
|
||||||
|
case <-stop:
|
||||||
|
break out
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b.baseLog.Print("stopping")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backend) handle(ctx context.Context, log *logrus.Entry, m queue.Message) {
|
||||||
|
t := time.Now()
|
||||||
|
|
||||||
|
var err error
|
||||||
|
defer func() { // must add a closure to delay evaluation of err
|
||||||
|
if e := recover(); e != nil {
|
||||||
|
err = fmt.Errorf("panic: %#v\n%s", e, string(debug.Stack()))
|
||||||
|
log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Done(err)
|
||||||
|
}()
|
||||||
|
|
||||||
|
b.mu.Lock()
|
||||||
|
b.workers++
|
||||||
|
b.mu.Unlock()
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
b.mu.Lock()
|
||||||
|
b.workers--
|
||||||
|
b.mu.Unlock()
|
||||||
|
b.cond.Signal()
|
||||||
|
}()
|
||||||
|
|
||||||
|
err = b.handleOne(ctx, log, m)
|
||||||
|
log = log.WithField("durationMs", int(time.Now().Sub(t)/time.Millisecond))
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
} else {
|
||||||
|
log.Print("done")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (b *backend) handleOne(ctx context.Context, log *logrus.Entry, m queue.Message) error {
|
||||||
|
doc, err := b.db.Get(m.ID())
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch doc.OpenShiftCluster.Properties.ProvisioningState {
|
||||||
|
case api.ProvisioningStateUpdating:
|
||||||
|
log.Printf("updating")
|
||||||
|
err = b.update(ctx, log, doc)
|
||||||
|
case api.ProvisioningStateDeleting:
|
||||||
|
log.Printf("deleting")
|
||||||
|
err = b.delete(ctx, log, doc)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
log.Error(err)
|
||||||
|
doc, err = b.db.Patch(m.ID(), func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateFailed
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch doc.OpenShiftCluster.Properties.ProvisioningState {
|
||||||
|
case api.ProvisioningStateUpdating:
|
||||||
|
doc, err = b.db.Patch(m.ID(), func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateSucceeded
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
|
||||||
|
case api.ProvisioningStateDeleting:
|
||||||
|
return b.db.Delete(m.ID())
|
||||||
|
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unexpected state %q", doc.OpenShiftCluster.Properties.ProvisioningState)
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,37 @@
|
||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (b *backend) delete(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||||
|
groups := resources.NewGroupsClient(doc.SubscriptionID)
|
||||||
|
groups.Authorizer = b.authorizer
|
||||||
|
|
||||||
|
if doc.OpenShiftCluster.Properties.ResourceGroup == "" {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := groups.CheckExistence(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if resp.StatusCode != http.StatusNoContent {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Printf("deleting resource group %s", doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
future, err := groups.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Print("waiting for resource group deletion")
|
||||||
|
return future.WaitForCompletionRef(ctx, groups.Client)
|
||||||
|
}
|
|
@ -0,0 +1,102 @@
|
||||||
|
package backend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
|
"crypto/rsa"
|
||||||
|
"encoding/base64"
|
||||||
|
"os"
|
||||||
|
|
||||||
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/ipnet"
|
||||||
|
"github.com/openshift/installer/pkg/types"
|
||||||
|
"github.com/openshift/installer/pkg/types/azure"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"golang.org/x/crypto/ssh"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/deploy"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (b *backend) update(ctx context.Context, log *logrus.Entry, doc *api.OpenShiftClusterDocument) error {
|
||||||
|
if doc.OpenShiftCluster.Properties.Installation == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err := b.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
if doc.OpenShiftCluster.Properties.SSHKey == nil {
|
||||||
|
var err error
|
||||||
|
doc.OpenShiftCluster.Properties.SSHKey, err = rsa.GenerateKey(rand.Reader, 2048)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
sshkey, err := ssh.NewPublicKey(&doc.OpenShiftCluster.Properties.SSHKey.PublicKey)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
installConfig := &installconfig.InstallConfig{
|
||||||
|
Config: &types.InstallConfig{
|
||||||
|
ObjectMeta: metav1.ObjectMeta{
|
||||||
|
Name: doc.OpenShiftCluster.Name,
|
||||||
|
},
|
||||||
|
SSHKey: sshkey.Type() + " " + base64.StdEncoding.EncodeToString(sshkey.Marshal()),
|
||||||
|
BaseDomain: os.Getenv("DOMAIN"),
|
||||||
|
Networking: &types.Networking{
|
||||||
|
MachineCIDR: ipnet.MustParseCIDR(doc.OpenShiftCluster.Properties.NetworkProfile.VNetCIDR),
|
||||||
|
ClusterNetwork: []types.ClusterNetworkEntry{
|
||||||
|
{
|
||||||
|
CIDR: *ipnet.MustParseCIDR(doc.OpenShiftCluster.Properties.NetworkProfile.PodCIDR),
|
||||||
|
HostPrefix: 23,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ServiceNetwork: []ipnet.IPNet{
|
||||||
|
*ipnet.MustParseCIDR(doc.OpenShiftCluster.Properties.NetworkProfile.ServiceCIDR),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
ControlPlane: &types.MachinePool{
|
||||||
|
Name: "master",
|
||||||
|
Replicas: to.Int64Ptr(3),
|
||||||
|
Platform: types.MachinePoolPlatform{
|
||||||
|
Azure: &azure.MachinePool{
|
||||||
|
InstanceType: string(doc.OpenShiftCluster.Properties.MasterProfile.VMSize),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Platform: types.Platform{
|
||||||
|
Azure: &azure.Platform{
|
||||||
|
Region: doc.OpenShiftCluster.Location,
|
||||||
|
BaseDomainResourceGroupName: os.Getenv("DOMAIN_RESOURCEGROUP"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
PullSecret: string(doc.OpenShiftCluster.Properties.PullSecret),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, wp := range doc.OpenShiftCluster.Properties.WorkerProfiles {
|
||||||
|
installConfig.Config.Compute = append(installConfig.Config.Compute, types.MachinePool{
|
||||||
|
Name: wp.Name,
|
||||||
|
Replicas: to.Int64Ptr(int64(wp.Count)),
|
||||||
|
Platform: types.MachinePoolPlatform{
|
||||||
|
Azure: &azure.MachinePool{
|
||||||
|
InstanceType: string(wp.VMSize),
|
||||||
|
OSDisk: azure.OSDisk{
|
||||||
|
DiskSizeGB: int32(wp.DiskSizeGB),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
return deploy.NewDeployer(log, b.db, b.authorizer, doc.SubscriptionID).Deploy(ctx, doc, installConfig)
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
//go:generate go run github.com/jim-minter/go-cosmosdb/cmd/gencosmosdb github.com/jim-minter/rp/pkg/api,OpenShiftClusterDocument github.com/jim-minter/rp/pkg/api,LeaseDocument
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
api.AddExtensions(&JSONHandle.BasicHandle)
|
||||||
|
}
|
|
@ -0,0 +1,212 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Collection represents a collection
|
||||||
|
type Collection struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Timestamp int `json:"_ts,omitempty"`
|
||||||
|
Self string `json:"_self,omitempty"`
|
||||||
|
ETag string `json:"_etag,omitempty"`
|
||||||
|
Documents string `json:"_docs,omitempty"`
|
||||||
|
StoredProcedures string `json:"_sprocs,omitempty"`
|
||||||
|
Triggers string `json:"_triggers,omitempty"`
|
||||||
|
UserDefinedFunctions string `json:"_udfs,omitempty"`
|
||||||
|
Conflicts string `json:"_conflicts,omitempty"`
|
||||||
|
IndexingPolicy *IndexingPolicy `json:"indexingPolicy,omitempty"`
|
||||||
|
PartitionKey *PartitionKey `json:"partitionKey,omitempty"`
|
||||||
|
ConflictResolutionPolicy *ConflictResolutionPolicy `json:"conflictResolutionPolicy,omitempty"`
|
||||||
|
GeospatialConfig *GeospatialConfig `json:"geospatialConfig,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IndexingPolicy represents an indexing policy
|
||||||
|
type IndexingPolicy struct {
|
||||||
|
Automatic bool `json:"automatic,omitempty"`
|
||||||
|
IndexingMode string `json:"indexingMode,omitempty"`
|
||||||
|
IncludedPaths []IncludedPath `json:"includedPaths,omitempty"`
|
||||||
|
ExcludedPaths []IncludedPath `json:"excludedPaths,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// IncludedPath represents an included path
|
||||||
|
type IncludedPath struct {
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
Indexes []Index `json:"indexes,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Index represents an index
|
||||||
|
type Index struct {
|
||||||
|
DataType string `json:"dataType,omitempty"`
|
||||||
|
Kind string `json:"kind,omitempty"`
|
||||||
|
Precision int `json:"precision,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExcludedPath represents an excluded path
|
||||||
|
type ExcludedPath struct {
|
||||||
|
Path string `json:"path,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PartitionKey represents a partition key
|
||||||
|
type PartitionKey struct {
|
||||||
|
Paths []string `json:"paths,omitempty"`
|
||||||
|
Kind string `json:"kind,omitempty"`
|
||||||
|
Version int `json:"version,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// ConflictResolutionPolicy represents a conflict resolution policy
|
||||||
|
type ConflictResolutionPolicy struct {
|
||||||
|
Mode string `json:"mode,omitempty"`
|
||||||
|
ConflictResolutionPath string `json:"conflictResolutionPath,omitempty"`
|
||||||
|
ConflictResolutionProcedure string `json:"conflictResolutionProcedure,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// GeospatialConfig represents a geospatial config
|
||||||
|
type GeospatialConfig struct {
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Collections represents collections
|
||||||
|
type Collections struct {
|
||||||
|
Count int `json:"_count,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Collections []*Collection `json:"DocumentCollections,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PartitionKeyRanges represents partition key ranges
|
||||||
|
type PartitionKeyRanges struct {
|
||||||
|
Count int `json:"_count,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
PartitionKeyRanges []PartitionKeyRange `json:"PartitionKeyRanges,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// PartitionKeyRange represents a partition key range
|
||||||
|
type PartitionKeyRange struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Timestamp int `json:"_ts,omitempty"`
|
||||||
|
Self string `json:"_self,omitempty"`
|
||||||
|
ETag string `json:"_etag,omitempty"`
|
||||||
|
MaxExclusive string `json:"maxExclusive,omitempty"`
|
||||||
|
MinInclusive string `json:"minInclusive,omitempty"`
|
||||||
|
ResourceIDPrefix int `json:"ridPrefix,omitempty"`
|
||||||
|
ThroughputFraction int `json:"throughputFraction,omitempty"`
|
||||||
|
Status string `json:"status,omitempty"`
|
||||||
|
Parents []string `json:"parents,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type collectionClient struct {
|
||||||
|
*databaseClient
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
// CollectionClient is a collection client
|
||||||
|
type CollectionClient interface {
|
||||||
|
Create(*Collection) (*Collection, error)
|
||||||
|
List() CollectionIterator
|
||||||
|
ListAll() (*Collections, error)
|
||||||
|
Get(string) (*Collection, error)
|
||||||
|
Delete(*Collection) error
|
||||||
|
Replace(*Collection) (*Collection, error)
|
||||||
|
PartitionKeyRanges(string) (*PartitionKeyRanges, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type collectionListIterator struct {
|
||||||
|
*collectionClient
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// CollectionIterator is a collection iterator
|
||||||
|
type CollectionIterator interface {
|
||||||
|
Next() (*Collections, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewCollectionClient returns a new collection client
|
||||||
|
func NewCollectionClient(c DatabaseClient, dbid string) CollectionClient {
|
||||||
|
return &collectionClient{
|
||||||
|
databaseClient: c.(*databaseClient),
|
||||||
|
path: "dbs/" + dbid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) all(i CollectionIterator) (*Collections, error) {
|
||||||
|
allcolls := &Collections{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
colls, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if colls == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
allcolls.Count += colls.Count
|
||||||
|
allcolls.ResourceID = colls.ResourceID
|
||||||
|
allcolls.Collections = append(allcolls.Collections, colls.Collections...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return allcolls, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) Create(newcoll *Collection) (coll *Collection, err error) {
|
||||||
|
err = c.do(http.MethodPost, c.path+"/colls", "colls", c.path, http.StatusCreated, &newcoll, &coll, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) List() CollectionIterator {
|
||||||
|
return &collectionListIterator{collectionClient: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) ListAll() (*Collections, error) {
|
||||||
|
return c.all(c.List())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) Get(collid string) (coll *Collection, err error) {
|
||||||
|
err = c.do(http.MethodGet, c.path+"/colls/"+collid, "colls", c.path+"/colls/"+collid, http.StatusOK, nil, &coll, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) Delete(coll *Collection) error {
|
||||||
|
if coll.ETag == "" {
|
||||||
|
return ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", coll.ETag)
|
||||||
|
return c.do(http.MethodDelete, c.path+"/colls/"+coll.ID, "colls", c.path+"/colls/"+coll.ID, http.StatusNoContent, nil, nil, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) Replace(newcoll *Collection) (coll *Collection, err error) {
|
||||||
|
err = c.do(http.MethodPost, c.path+"/colls/"+newcoll.ID, "colls", c.path+"/colls/"+newcoll.ID, http.StatusCreated, &newcoll, &coll, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *collectionClient) PartitionKeyRanges(collid string) (pkrs *PartitionKeyRanges, err error) {
|
||||||
|
err = c.do(http.MethodGet, c.path+"/colls/"+collid+"/pkranges", "pkranges", c.path+"/colls/"+collid, http.StatusOK, nil, &pkrs, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *collectionListIterator) Next() (colls *Collections, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodGet, i.path+"/colls", "colls", i.path, http.StatusOK, nil, &colls, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,133 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"crypto/hmac"
|
||||||
|
"crypto/sha256"
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
"net/textproto"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/ugorji/go/codec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Error represents an error
|
||||||
|
type Error struct {
|
||||||
|
StatusCode int
|
||||||
|
Code string `json:"code"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e Error) Error() string {
|
||||||
|
return fmt.Sprintf("%d %s: %s", e.StatusCode, e.Code, e.Message)
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsErrorStatusCode returns true if err is of type Error and its StatusCode
|
||||||
|
// matches statusCode
|
||||||
|
func IsErrorStatusCode(err error, statusCode int) bool {
|
||||||
|
if err, ok := err.(Error); ok {
|
||||||
|
return err.StatusCode == statusCode
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// ErrETagRequired is the error returned if the ETag field is not populate on a
|
||||||
|
// PUT or DELETE operation
|
||||||
|
var ErrETagRequired = fmt.Errorf("ETag is required")
|
||||||
|
|
||||||
|
// RetryOnPreconditionFailed retries a function if it fails due to
|
||||||
|
// PreconditionFailed
|
||||||
|
func RetryOnPreconditionFailed(f func() error) (err error) {
|
||||||
|
for i := 0; i < 5; i++ {
|
||||||
|
err = f()
|
||||||
|
if !IsErrorStatusCode(err, http.StatusPreconditionFailed) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
time.Sleep(time.Duration(100*i) * time.Millisecond)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// JSONHandle exposes the encode/decode options used by
|
||||||
|
// github.com/ugorji/go/codec
|
||||||
|
var JSONHandle = &codec.JsonHandle{
|
||||||
|
BasicHandle: codec.BasicHandle{
|
||||||
|
DecodeOptions: codec.DecodeOptions{
|
||||||
|
ErrorIfNoField: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) authorizeRequest(req *http.Request, resourceType, resourceLink string) {
|
||||||
|
date := time.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05 GMT")
|
||||||
|
|
||||||
|
h := hmac.New(sha256.New, c.masterKey)
|
||||||
|
fmt.Fprintf(h, "%s\n%s\n%s\n%s\n\n", strings.ToLower(req.Method), resourceType, resourceLink, strings.ToLower(date))
|
||||||
|
|
||||||
|
req.Header.Set("Authorization", url.QueryEscape(fmt.Sprintf("type=master&ver=1.0&sig=%s", base64.StdEncoding.EncodeToString(h.Sum(nil)))))
|
||||||
|
req.Header.Set("x-ms-date", date)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) do(method, path, resourceType, resourceLink string, expectedStatusCode int, in, out interface{}, headers http.Header) error {
|
||||||
|
req, err := http.NewRequest(method, "https://"+c.databaseAccount+".documents.azure.com/"+path, nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if in != nil {
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
err := codec.NewEncoder(buf, JSONHandle).Encode(in)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
req.Body = ioutil.NopCloser(buf)
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
}
|
||||||
|
|
||||||
|
for k, v := range headers {
|
||||||
|
req.Header[textproto.CanonicalMIMEHeaderKey(k)] = v
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("x-ms-version", "2018-12-31")
|
||||||
|
|
||||||
|
c.authorizeRequest(req, resourceType, resourceLink)
|
||||||
|
|
||||||
|
resp, err := c.hc.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
if headers != nil {
|
||||||
|
for k := range headers {
|
||||||
|
delete(headers, k)
|
||||||
|
}
|
||||||
|
for k, v := range resp.Header {
|
||||||
|
headers[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
d := codec.NewDecoder(resp.Body, JSONHandle)
|
||||||
|
|
||||||
|
if resp.StatusCode != expectedStatusCode {
|
||||||
|
var err Error
|
||||||
|
if resp.Header.Get("Content-Type") == "application/json" {
|
||||||
|
d.Decode(&err)
|
||||||
|
}
|
||||||
|
err.StatusCode = resp.StatusCode
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if out != nil && resp.Header.Get("Content-Type") == "application/json" {
|
||||||
|
return d.Decode(&out)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,137 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/base64"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Database represents a database
|
||||||
|
type Database struct {
|
||||||
|
ID string `json:"id,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Timestamp int `json:"_ts,omitempty"`
|
||||||
|
Self string `json:"_self,omitempty"`
|
||||||
|
ETag string `json:"_etag,omitempty"`
|
||||||
|
Collections string `json:"_colls,omitempty"`
|
||||||
|
Users string `json:"_users,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Databases represents databases
|
||||||
|
type Databases struct {
|
||||||
|
Count int `json:"_count,omitempty"`
|
||||||
|
ResourceID string `json:"_rid,omitempty"`
|
||||||
|
Databases []*Database `json:"Databases,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type databaseClient struct {
|
||||||
|
hc *http.Client
|
||||||
|
databaseAccount string
|
||||||
|
masterKey []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
// DatabaseClient is a database client
|
||||||
|
type DatabaseClient interface {
|
||||||
|
Create(*Database) (*Database, error)
|
||||||
|
List() DatabaseIterator
|
||||||
|
ListAll() (*Databases, error)
|
||||||
|
Get(string) (*Database, error)
|
||||||
|
Delete(*Database) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type databaseListIterator struct {
|
||||||
|
*databaseClient
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// DatabaseIterator is a database iterator
|
||||||
|
type DatabaseIterator interface {
|
||||||
|
Next() (*Databases, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDatabaseClient returns a new database client
|
||||||
|
func NewDatabaseClient(hc *http.Client, databaseAccount, masterKey string) (DatabaseClient, error) {
|
||||||
|
var err error
|
||||||
|
|
||||||
|
c := &databaseClient{
|
||||||
|
hc: hc,
|
||||||
|
databaseAccount: databaseAccount,
|
||||||
|
}
|
||||||
|
|
||||||
|
c.masterKey, err = base64.StdEncoding.DecodeString(masterKey)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return c, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) all(i DatabaseIterator) (*Databases, error) {
|
||||||
|
alldbs := &Databases{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
dbs, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if dbs == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
alldbs.Count += dbs.Count
|
||||||
|
alldbs.ResourceID = dbs.ResourceID
|
||||||
|
alldbs.Databases = append(alldbs.Databases, dbs.Databases...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return alldbs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) Create(newdb *Database) (db *Database, err error) {
|
||||||
|
err = c.do(http.MethodPost, "dbs", "dbs", "", http.StatusCreated, &newdb, &db, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) List() DatabaseIterator {
|
||||||
|
return &databaseListIterator{databaseClient: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) ListAll() (*Databases, error) {
|
||||||
|
return c.all(c.List())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) Get(dbid string) (db *Database, err error) {
|
||||||
|
err = c.do(http.MethodGet, "dbs/"+dbid, "dbs", "dbs/"+dbid, http.StatusOK, nil, &db, nil)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *databaseClient) Delete(db *Database) error {
|
||||||
|
if db.ETag == "" {
|
||||||
|
return ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", db.ETag)
|
||||||
|
return c.do(http.MethodDelete, "dbs/"+db.ID, "dbs", "dbs/"+db.ID, http.StatusNoContent, nil, nil, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *databaseListIterator) Next() (dbs *Databases, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodGet, "dbs", "dbs", "", http.StatusOK, nil, &dbs, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
// Query represents a query
|
||||||
|
type Query struct {
|
||||||
|
Query string `json:"query,omitempty"`
|
||||||
|
Parameters []Parameter `json:"parameters,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parameter represents a parameter
|
||||||
|
type Parameter struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Value string `json:"value,omitempty"`
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
pkg "github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
type leaseDocumentClient struct {
|
||||||
|
*databaseClient
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
// LeaseDocumentClient is a leaseDocument client
|
||||||
|
type LeaseDocumentClient interface {
|
||||||
|
Create(string, *pkg.LeaseDocument) (*pkg.LeaseDocument, error)
|
||||||
|
List() LeaseDocumentIterator
|
||||||
|
ListAll() (*pkg.LeaseDocuments, error)
|
||||||
|
Get(string, string) (*pkg.LeaseDocument, error)
|
||||||
|
Replace(string, *pkg.LeaseDocument) (*pkg.LeaseDocument, error)
|
||||||
|
Delete(string, *pkg.LeaseDocument) error
|
||||||
|
Query(string, *Query) LeaseDocumentIterator
|
||||||
|
QueryAll(string, *Query) (*pkg.LeaseDocuments, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type leaseDocumentListIterator struct {
|
||||||
|
*leaseDocumentClient
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type leaseDocumentQueryIterator struct {
|
||||||
|
*leaseDocumentClient
|
||||||
|
partitionkey string
|
||||||
|
query *Query
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// LeaseDocumentIterator is a leaseDocument iterator
|
||||||
|
type LeaseDocumentIterator interface {
|
||||||
|
Next() (*pkg.LeaseDocuments, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLeaseDocumentClient returns a new leaseDocument client
|
||||||
|
func NewLeaseDocumentClient(collc CollectionClient, collid string) LeaseDocumentClient {
|
||||||
|
return &leaseDocumentClient{
|
||||||
|
databaseClient: collc.(*collectionClient).databaseClient,
|
||||||
|
path: collc.(*collectionClient).path + "/colls/" + collid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) all(i LeaseDocumentIterator) (*pkg.LeaseDocuments, error) {
|
||||||
|
allleaseDocuments := &pkg.LeaseDocuments{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
leaseDocuments, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if leaseDocuments == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
allleaseDocuments.Count += leaseDocuments.Count
|
||||||
|
allleaseDocuments.ResourceID = leaseDocuments.ResourceID
|
||||||
|
allleaseDocuments.LeaseDocuments = append(allleaseDocuments.LeaseDocuments, leaseDocuments.LeaseDocuments...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return allleaseDocuments, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) Create(partitionkey string, newleaseDocument *pkg.LeaseDocument) (leaseDocument *pkg.LeaseDocument, err error) {
|
||||||
|
headers := http.Header{}
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newleaseDocument, &leaseDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) List() LeaseDocumentIterator {
|
||||||
|
return &leaseDocumentListIterator{leaseDocumentClient: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) ListAll() (*pkg.LeaseDocuments, error) {
|
||||||
|
return c.all(c.List())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) Get(partitionkey, leaseDocumentid string) (leaseDocument *pkg.LeaseDocument, err error) {
|
||||||
|
headers := http.Header{}
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodGet, c.path+"/docs/"+leaseDocumentid, "docs", c.path+"/docs/"+leaseDocumentid, http.StatusOK, nil, &leaseDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) Replace(partitionkey string, newleaseDocument *pkg.LeaseDocument) (leaseDocument *pkg.LeaseDocument, err error) {
|
||||||
|
if newleaseDocument.ETag == "" {
|
||||||
|
return nil, ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", newleaseDocument.ETag)
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodPut, c.path+"/docs/"+newleaseDocument.ID, "docs", c.path+"/docs/"+newleaseDocument.ID, http.StatusOK, &newleaseDocument, &leaseDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) Delete(partitionkey string, leaseDocument *pkg.LeaseDocument) error {
|
||||||
|
if leaseDocument.ETag == "" {
|
||||||
|
return ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", leaseDocument.ETag)
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
return c.do(http.MethodDelete, c.path+"/docs/"+leaseDocument.ID, "docs", c.path+"/docs/"+leaseDocument.ID, http.StatusNoContent, nil, nil, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) Query(partitionkey string, query *Query) LeaseDocumentIterator {
|
||||||
|
return &leaseDocumentQueryIterator{leaseDocumentClient: c, partitionkey: partitionkey, query: query}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *leaseDocumentClient) QueryAll(partitionkey string, query *Query) (*pkg.LeaseDocuments, error) {
|
||||||
|
return c.all(c.Query(partitionkey, query))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *leaseDocumentListIterator) Next() (leaseDocuments *pkg.LeaseDocuments, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &leaseDocuments, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *leaseDocumentQueryIterator) Next() (leaseDocuments *pkg.LeaseDocuments, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("X-Ms-Documentdb-Isquery", "True")
|
||||||
|
headers.Set("Content-Type", "application/query+json")
|
||||||
|
if i.partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+i.partitionkey+`"]`)
|
||||||
|
} else {
|
||||||
|
headers.Set("X-Ms-Documentdb-Query-Enablecrosspartition", "True")
|
||||||
|
}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodPost, i.path+"/docs", "docs", i.path, http.StatusOK, &i.query, &leaseDocuments, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,181 @@
|
||||||
|
// Code generated by github.com/jim-minter/go-cosmosdb, DO NOT EDIT.
|
||||||
|
|
||||||
|
package cosmosdb
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
pkg "github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
type openShiftClusterDocumentClient struct {
|
||||||
|
*databaseClient
|
||||||
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenShiftClusterDocumentClient is a openShiftClusterDocument client
|
||||||
|
type OpenShiftClusterDocumentClient interface {
|
||||||
|
Create(string, *pkg.OpenShiftClusterDocument) (*pkg.OpenShiftClusterDocument, error)
|
||||||
|
List() OpenShiftClusterDocumentIterator
|
||||||
|
ListAll() (*pkg.OpenShiftClusterDocuments, error)
|
||||||
|
Get(string, string) (*pkg.OpenShiftClusterDocument, error)
|
||||||
|
Replace(string, *pkg.OpenShiftClusterDocument) (*pkg.OpenShiftClusterDocument, error)
|
||||||
|
Delete(string, *pkg.OpenShiftClusterDocument) error
|
||||||
|
Query(string, *Query) OpenShiftClusterDocumentIterator
|
||||||
|
QueryAll(string, *Query) (*pkg.OpenShiftClusterDocuments, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type openShiftClusterDocumentListIterator struct {
|
||||||
|
*openShiftClusterDocumentClient
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type openShiftClusterDocumentQueryIterator struct {
|
||||||
|
*openShiftClusterDocumentClient
|
||||||
|
partitionkey string
|
||||||
|
query *Query
|
||||||
|
continuation string
|
||||||
|
done bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenShiftClusterDocumentIterator is a openShiftClusterDocument iterator
|
||||||
|
type OpenShiftClusterDocumentIterator interface {
|
||||||
|
Next() (*pkg.OpenShiftClusterDocuments, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOpenShiftClusterDocumentClient returns a new openShiftClusterDocument client
|
||||||
|
func NewOpenShiftClusterDocumentClient(collc CollectionClient, collid string) OpenShiftClusterDocumentClient {
|
||||||
|
return &openShiftClusterDocumentClient{
|
||||||
|
databaseClient: collc.(*collectionClient).databaseClient,
|
||||||
|
path: collc.(*collectionClient).path + "/colls/" + collid,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) all(i OpenShiftClusterDocumentIterator) (*pkg.OpenShiftClusterDocuments, error) {
|
||||||
|
allopenShiftClusterDocuments := &pkg.OpenShiftClusterDocuments{}
|
||||||
|
|
||||||
|
for {
|
||||||
|
openShiftClusterDocuments, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if openShiftClusterDocuments == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
allopenShiftClusterDocuments.Count += openShiftClusterDocuments.Count
|
||||||
|
allopenShiftClusterDocuments.ResourceID = openShiftClusterDocuments.ResourceID
|
||||||
|
allopenShiftClusterDocuments.OpenShiftClusterDocuments = append(allopenShiftClusterDocuments.OpenShiftClusterDocuments, openShiftClusterDocuments.OpenShiftClusterDocuments...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return allopenShiftClusterDocuments, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) Create(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
||||||
|
headers := http.Header{}
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodPost, c.path+"/docs", "docs", c.path, http.StatusCreated, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) List() OpenShiftClusterDocumentIterator {
|
||||||
|
return &openShiftClusterDocumentListIterator{openShiftClusterDocumentClient: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) ListAll() (*pkg.OpenShiftClusterDocuments, error) {
|
||||||
|
return c.all(c.List())
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) Get(partitionkey, openShiftClusterDocumentid string) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
||||||
|
headers := http.Header{}
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodGet, c.path+"/docs/"+openShiftClusterDocumentid, "docs", c.path+"/docs/"+openShiftClusterDocumentid, http.StatusOK, nil, &openShiftClusterDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) Replace(partitionkey string, newopenShiftClusterDocument *pkg.OpenShiftClusterDocument) (openShiftClusterDocument *pkg.OpenShiftClusterDocument, err error) {
|
||||||
|
if newopenShiftClusterDocument.ETag == "" {
|
||||||
|
return nil, ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", newopenShiftClusterDocument.ETag)
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
err = c.do(http.MethodPut, c.path+"/docs/"+newopenShiftClusterDocument.ID, "docs", c.path+"/docs/"+newopenShiftClusterDocument.ID, http.StatusOK, &newopenShiftClusterDocument, &openShiftClusterDocument, headers)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) Delete(partitionkey string, openShiftClusterDocument *pkg.OpenShiftClusterDocument) error {
|
||||||
|
if openShiftClusterDocument.ETag == "" {
|
||||||
|
return ErrETagRequired
|
||||||
|
}
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("If-Match", openShiftClusterDocument.ETag)
|
||||||
|
if partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+partitionkey+`"]`)
|
||||||
|
}
|
||||||
|
return c.do(http.MethodDelete, c.path+"/docs/"+openShiftClusterDocument.ID, "docs", c.path+"/docs/"+openShiftClusterDocument.ID, http.StatusNoContent, nil, nil, headers)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) Query(partitionkey string, query *Query) OpenShiftClusterDocumentIterator {
|
||||||
|
return &openShiftClusterDocumentQueryIterator{openShiftClusterDocumentClient: c, partitionkey: partitionkey, query: query}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusterDocumentClient) QueryAll(partitionkey string, query *Query) (*pkg.OpenShiftClusterDocuments, error) {
|
||||||
|
return c.all(c.Query(partitionkey, query))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *openShiftClusterDocumentListIterator) Next() (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodGet, i.path+"/docs", "docs", i.path, http.StatusOK, nil, &openShiftClusterDocuments, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (i *openShiftClusterDocumentQueryIterator) Next() (openShiftClusterDocuments *pkg.OpenShiftClusterDocuments, err error) {
|
||||||
|
if i.done {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
headers := http.Header{}
|
||||||
|
headers.Set("X-Ms-Documentdb-Isquery", "True")
|
||||||
|
headers.Set("Content-Type", "application/query+json")
|
||||||
|
if i.partitionkey != "" {
|
||||||
|
headers.Set("X-Ms-Documentdb-Partitionkey", `["`+i.partitionkey+`"]`)
|
||||||
|
} else {
|
||||||
|
headers.Set("X-Ms-Documentdb-Query-Enablecrosspartition", "True")
|
||||||
|
}
|
||||||
|
if i.continuation != "" {
|
||||||
|
headers.Set("X-Ms-Continuation", i.continuation)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = i.do(http.MethodPost, i.path+"/docs", "docs", i.path, http.StatusOK, &i.query, &openShiftClusterDocuments, headers)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
i.continuation = headers.Get("X-Ms-Continuation")
|
||||||
|
i.done = i.continuation == ""
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
|
@ -0,0 +1,142 @@
|
||||||
|
package database
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database/cosmosdb"
|
||||||
|
"github.com/jim-minter/rp/pkg/util/resource"
|
||||||
|
)
|
||||||
|
|
||||||
|
type openShiftClusters struct {
|
||||||
|
c cosmosdb.OpenShiftClusterDocumentClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// OpenShiftClusters is the database interface for OpenShiftClusterDocuments
|
||||||
|
type OpenShiftClusters interface {
|
||||||
|
Create(*api.OpenShiftClusterDocument) (*api.OpenShiftClusterDocument, error)
|
||||||
|
Get(string) (*api.OpenShiftClusterDocument, error)
|
||||||
|
Patch(string, func(*api.OpenShiftClusterDocument) error) (*api.OpenShiftClusterDocument, error)
|
||||||
|
Update(*api.OpenShiftClusterDocument) (*api.OpenShiftClusterDocument, error)
|
||||||
|
Delete(string) error
|
||||||
|
ListUnqueued() cosmosdb.OpenShiftClusterDocumentIterator
|
||||||
|
ListByPrefix(string, string) cosmosdb.OpenShiftClusterDocumentIterator
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewOpenShiftClusters returns a new OpenShiftClusters
|
||||||
|
func NewOpenShiftClusters(dbc cosmosdb.DatabaseClient, dbid, collid string) OpenShiftClusters {
|
||||||
|
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
||||||
|
|
||||||
|
return &openShiftClusters{
|
||||||
|
c: cosmosdb.NewOpenShiftClusterDocumentClient(collc, collid),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) Create(doc *api.OpenShiftClusterDocument) (*api.OpenShiftClusterDocument, error) {
|
||||||
|
var err error
|
||||||
|
doc.SubscriptionID, err = resource.SubscriptionID(doc.OpenShiftCluster.ID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.ID = strings.ToLower(doc.OpenShiftCluster.ID)
|
||||||
|
doc.OpenShiftCluster.Name = strings.ToLower(doc.OpenShiftCluster.Name)
|
||||||
|
doc.OpenShiftCluster.Type = strings.ToLower(doc.OpenShiftCluster.Type)
|
||||||
|
|
||||||
|
doc, err = c.c.Create(doc.SubscriptionID, doc)
|
||||||
|
|
||||||
|
if err, ok := err.(cosmosdb.Error); ok && err.StatusCode == http.StatusConflict {
|
||||||
|
err.StatusCode = http.StatusPreconditionFailed
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) Get(resourceID string) (*api.OpenShiftClusterDocument, error) {
|
||||||
|
subscriptionID, err := resource.SubscriptionID(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
docs, err := c.c.QueryAll(subscriptionID, &cosmosdb.Query{
|
||||||
|
Query: "SELECT * FROM OpenshiftClusterDocuments doc WHERE doc.openShiftCluster.id = @id",
|
||||||
|
Parameters: []cosmosdb.Parameter{
|
||||||
|
{
|
||||||
|
Name: "@id",
|
||||||
|
Value: strings.ToLower(resourceID),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(docs.OpenShiftClusterDocuments) > 1:
|
||||||
|
return nil, fmt.Errorf("read %d documents, expected <= 1", len(docs.OpenShiftClusterDocuments))
|
||||||
|
case len(docs.OpenShiftClusterDocuments) == 1:
|
||||||
|
return docs.OpenShiftClusterDocuments[0], nil
|
||||||
|
default:
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) Patch(resourceID string, f func(*api.OpenShiftClusterDocument) error) (*api.OpenShiftClusterDocument, error) {
|
||||||
|
var doc *api.OpenShiftClusterDocument
|
||||||
|
|
||||||
|
err := cosmosdb.RetryOnPreconditionFailed(func() (err error) {
|
||||||
|
doc, err = c.Get(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err = f(doc)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err = c.Update(doc)
|
||||||
|
return
|
||||||
|
})
|
||||||
|
|
||||||
|
return doc, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) Update(doc *api.OpenShiftClusterDocument) (*api.OpenShiftClusterDocument, error) {
|
||||||
|
doc.OpenShiftCluster.ID = strings.ToLower(doc.OpenShiftCluster.ID)
|
||||||
|
doc.OpenShiftCluster.Name = strings.ToLower(doc.OpenShiftCluster.Name)
|
||||||
|
doc.OpenShiftCluster.Type = strings.ToLower(doc.OpenShiftCluster.Type)
|
||||||
|
|
||||||
|
return c.c.Replace(doc.SubscriptionID, doc)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) Delete(resourceID string) error {
|
||||||
|
return cosmosdb.RetryOnPreconditionFailed(func() (err error) {
|
||||||
|
doc, err := c.Get(resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return c.c.Delete(doc.SubscriptionID, doc)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) ListUnqueued() cosmosdb.OpenShiftClusterDocumentIterator {
|
||||||
|
return c.c.Query("", &cosmosdb.Query{
|
||||||
|
Query: "SELECT * FROM OpenshiftClusterDocuments doc WHERE doc.unqueued = true",
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *openShiftClusters) ListByPrefix(subscriptionID, prefix string) cosmosdb.OpenShiftClusterDocumentIterator {
|
||||||
|
return c.c.Query(subscriptionID, &cosmosdb.Query{
|
||||||
|
Query: "SELECT * FROM OpenshiftClusterDocuments doc WHERE STARTSWITH(doc.openShiftCluster.id, @prefix)",
|
||||||
|
Parameters: []cosmosdb.Parameter{
|
||||||
|
{
|
||||||
|
Name: "@prefix",
|
||||||
|
Value: strings.ToLower(prefix),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -0,0 +1,224 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/msi/mgmt/2018-11-30/msi"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage"
|
||||||
|
azstorage "github.com/Azure/azure-sdk-for-go/storage"
|
||||||
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
|
"github.com/openshift/installer/data"
|
||||||
|
"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/manifests"
|
||||||
|
"github.com/openshift/installer/pkg/asset/rhcos"
|
||||||
|
"github.com/openshift/installer/pkg/asset/targets"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *Deployer) deployStorage(ctx context.Context, doc *api.OpenShiftClusterDocument, installConfig *installconfig.InstallConfig) error {
|
||||||
|
if doc.OpenShiftCluster.Properties.ResourceGroup != "" {
|
||||||
|
resp, err := d.groups.CheckExistence(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode == http.StatusNoContent {
|
||||||
|
d.log.Printf("deleting stale resource group %s", doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
future, err := d.groups.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("waiting for stale resource group deletion")
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.groups.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
g := Graph{
|
||||||
|
reflect.TypeOf(installConfig): installConfig,
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: these need to be compiled in.
|
||||||
|
data.Assets = http.Dir(filepath.Join(os.Getenv("HOME"), "go/src/github.com/openshift/installer/data/data"))
|
||||||
|
|
||||||
|
for _, a := range targets.Cluster {
|
||||||
|
// TODO: some prerequisite assets call out to Azure, and they really
|
||||||
|
// should not.
|
||||||
|
_, err := g.resolve(a)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrap := g[reflect.TypeOf(&bootstrap.Bootstrap{})].(*bootstrap.Bootstrap)
|
||||||
|
cloudProviderConfig := g[reflect.TypeOf(&manifests.CloudProviderConfig{})].(*manifests.CloudProviderConfig)
|
||||||
|
clusterID := g[reflect.TypeOf(&installconfig.ClusterID{})].(*installconfig.ClusterID)
|
||||||
|
rhcosImage := g[reflect.TypeOf(new(rhcos.Image))].(*rhcos.Image)
|
||||||
|
|
||||||
|
var resourceGroup string
|
||||||
|
{
|
||||||
|
var s struct {
|
||||||
|
ResourceGroup string `json:"resourceGroup,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal([]byte(cloudProviderConfig.ConfigMap.Data["config"]), &s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
resourceGroup = s.ResourceGroup
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err := d.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) (err error) {
|
||||||
|
doc.OpenShiftCluster.Properties.StorageSuffix, err = randomLowerCaseAlphanumericString(5)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.Properties.Installation.Now = time.Now().UTC()
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.Properties.ResourceGroup = resourceGroup
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("creating resource group")
|
||||||
|
_, err = d.groups.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, resources.Group{
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
t := &Template{
|
||||||
|
Schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||||
|
ContentVersion: "1.0.0.0",
|
||||||
|
Resources: []Resource{
|
||||||
|
{
|
||||||
|
Resource: &msi.Identity{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-identity"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
Type: "Microsoft.ManagedIdentity/userAssignedIdentities",
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["msi"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &storage.Account{
|
||||||
|
Sku: &storage.Sku{
|
||||||
|
Name: "Standard_LRS",
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
Type: to.StringPtr("Microsoft.Storage/storageAccounts"),
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["storage"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &storage.BlobContainer{
|
||||||
|
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/vhd"),
|
||||||
|
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["storage"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &storage.BlobContainer{
|
||||||
|
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/ignition"),
|
||||||
|
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["storage"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &storage.BlobContainer{
|
||||||
|
Name: to.StringPtr("cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + "/default/aro"),
|
||||||
|
Type: to.StringPtr("Microsoft.Storage/storageAccounts/blobServices/containers"),
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["storage"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Storage/storageAccounts/cluster" + doc.OpenShiftCluster.Properties.StorageSuffix,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("deploying storage template")
|
||||||
|
future, err := d.deployments.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||||
|
Properties: &resources.DeploymentProperties{
|
||||||
|
Template: t,
|
||||||
|
Mode: resources.Incremental,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("waiting for storage template deployment")
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.deployments.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
blobService, err := d.getBlobService(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("copying rhcos blob")
|
||||||
|
rhcosVhd := blobService.GetContainerReference("vhd").GetBlobReference("rhcos" + doc.OpenShiftCluster.Properties.StorageSuffix + ".vhd")
|
||||||
|
err = rhcosVhd.Copy(string(*rhcosImage), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
rhcosVhd.Metadata = azstorage.BlobMetadata{
|
||||||
|
"source_uri": "var.azure_image_url",
|
||||||
|
}
|
||||||
|
|
||||||
|
err = rhcosVhd.SetMetadata(nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
bootstrapIgn := blobService.GetContainerReference("ignition").GetBlobReference("bootstrap.ign")
|
||||||
|
err = bootstrapIgn.CreateBlockBlobFromReader(bytes.NewReader(bootstrap.File.Data), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
graph := blobService.GetContainerReference("aro").GetBlobReference("graph")
|
||||||
|
b, err := json.MarshalIndent(g, "", " ")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = graph.CreateBlockBlobFromReader(bytes.NewReader(b), nil)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,754 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/base64"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-07-01/network"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
|
||||||
|
"github.com/Azure/go-autorest/autorest/to"
|
||||||
|
"github.com/apparentlymart/go-cidr/cidr"
|
||||||
|
"github.com/openshift/installer/pkg/asset/ignition/machine"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/kubeconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/machines"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
corev1client "k8s.io/client-go/kubernetes/typed/core/v1"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *Deployer) deployResources(ctx context.Context, doc *api.OpenShiftClusterDocument) error {
|
||||||
|
g, err := d.getGraph(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
adminClient := g[reflect.TypeOf(&kubeconfig.AdminClient{})].(*kubeconfig.AdminClient)
|
||||||
|
clusterID := g[reflect.TypeOf(&installconfig.ClusterID{})].(*installconfig.ClusterID)
|
||||||
|
installConfig := g[reflect.TypeOf(&installconfig.InstallConfig{})].(*installconfig.InstallConfig)
|
||||||
|
machinesMaster := g[reflect.TypeOf(&machines.Master{})].(*machines.Master)
|
||||||
|
machineMaster := g[reflect.TypeOf(&machine.Master{})].(*machine.Master)
|
||||||
|
|
||||||
|
masterSubnetCIDR, err := cidr.Subnet(&installConfig.Config.Networking.MachineCIDR.IPNet, 3, 0)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
workerSubnetCIDR, err := cidr.Subnet(&installConfig.Config.Networking.MachineCIDR.IPNet, 3, 1)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
var lbIP net.IP
|
||||||
|
{
|
||||||
|
_, last := cidr.AddressRange(masterSubnetCIDR)
|
||||||
|
lbIP = cidr.Dec(cidr.Dec(last))
|
||||||
|
}
|
||||||
|
|
||||||
|
srvRecords := make([]dns.SrvRecord, len(machinesMaster.MachineFiles))
|
||||||
|
for i := 0; i < len(machinesMaster.MachineFiles); i++ {
|
||||||
|
srvRecords[i] = dns.SrvRecord{
|
||||||
|
Priority: to.Int32Ptr(10),
|
||||||
|
Weight: to.Int32Ptr(10),
|
||||||
|
Port: to.Int32Ptr(2380),
|
||||||
|
Target: to.StringPtr(fmt.Sprintf("etcd-%d.%s", i, installConfig.Config.ObjectMeta.Name+"."+installConfig.Config.BaseDomain)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
t := &Template{
|
||||||
|
Schema: "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
|
||||||
|
ContentVersion: "1.0.0.0",
|
||||||
|
Parameters: map[string]Parameter{
|
||||||
|
"sas": {
|
||||||
|
Type: "object",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Resources: []Resource{
|
||||||
|
{
|
||||||
|
Resource: &authorization.RoleAssignment{
|
||||||
|
Name: to.StringPtr("[guid(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + clusterID.InfraID + "-identity'), 'contributor')]"),
|
||||||
|
Type: to.StringPtr("Microsoft.Authorization/roleAssignments"),
|
||||||
|
Properties: &authorization.RoleAssignmentPropertiesWithScope{
|
||||||
|
Scope: to.StringPtr("[resourceGroup().id]"),
|
||||||
|
RoleDefinitionID: to.StringPtr("[resourceId('Microsoft.Authorization/roleDefinitions', 'b24988ac-6180-42a0-ab88-20f7382dd24c')]"), // Contributor
|
||||||
|
PrincipalID: to.StringPtr("[reference(resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + clusterID.InfraID + "-identity'), '2018-11-30').principalId]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["authorization"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.SecurityGroup{
|
||||||
|
SecurityGroupPropertiesFormat: &network.SecurityGroupPropertiesFormat{
|
||||||
|
SecurityRules: &[]network.SecurityRule{
|
||||||
|
{
|
||||||
|
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
||||||
|
Protocol: network.SecurityRuleProtocolTCP,
|
||||||
|
SourcePortRange: to.StringPtr("*"),
|
||||||
|
DestinationPortRange: to.StringPtr("6443"),
|
||||||
|
SourceAddressPrefix: to.StringPtr("*"),
|
||||||
|
DestinationAddressPrefix: to.StringPtr("*"),
|
||||||
|
Access: network.SecurityRuleAccessAllow,
|
||||||
|
Priority: to.Int32Ptr(101),
|
||||||
|
Direction: network.SecurityRuleDirectionInbound,
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("apiserver_in"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
SecurityRulePropertiesFormat: &network.SecurityRulePropertiesFormat{
|
||||||
|
Protocol: network.SecurityRuleProtocolTCP,
|
||||||
|
SourcePortRange: to.StringPtr("*"),
|
||||||
|
DestinationPortRange: to.StringPtr("22"),
|
||||||
|
SourceAddressPrefix: to.StringPtr("*"),
|
||||||
|
DestinationAddressPrefix: to.StringPtr("*"),
|
||||||
|
Access: network.SecurityRuleAccessAllow,
|
||||||
|
Priority: to.Int32Ptr(103),
|
||||||
|
Direction: network.SecurityRuleDirectionInbound,
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("bootstrap_ssh_in"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-controlplane-nsg"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/networkSecurityGroups"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.SecurityGroup{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-node-nsg"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/networkSecurityGroups"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.VirtualNetwork{
|
||||||
|
VirtualNetworkPropertiesFormat: &network.VirtualNetworkPropertiesFormat{
|
||||||
|
AddressSpace: &network.AddressSpace{
|
||||||
|
AddressPrefixes: &[]string{
|
||||||
|
installConfig.Config.Networking.MachineCIDR.String(),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Subnets: &[]network.Subnet{
|
||||||
|
{
|
||||||
|
SubnetPropertiesFormat: &network.SubnetPropertiesFormat{
|
||||||
|
AddressPrefix: to.StringPtr(masterSubnetCIDR.String()),
|
||||||
|
NetworkSecurityGroup: &network.SecurityGroup{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/networkSecurityGroups', '" + clusterID.InfraID + "-controlplane-nsg')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-master-subnet"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
SubnetPropertiesFormat: &network.SubnetPropertiesFormat{
|
||||||
|
AddressPrefix: to.StringPtr(workerSubnetCIDR.String()),
|
||||||
|
NetworkSecurityGroup: &network.SecurityGroup{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/networkSecurityGroups', '" + clusterID.InfraID + "-node-nsg')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-worker-subnet"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-vnet"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/virtualNetworks"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-controlplane-nsg",
|
||||||
|
"Microsoft.Network/networkSecurityGroups/" + clusterID.InfraID + "-node-nsg",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &dns.Zone{
|
||||||
|
ZoneProperties: &dns.ZoneProperties{
|
||||||
|
ZoneType: dns.Private,
|
||||||
|
ResolutionVirtualNetworks: &[]dns.SubResource{
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/virtualNetworks', '" + clusterID.InfraID + "-vnet')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/dnszones"),
|
||||||
|
Location: to.StringPtr("global"),
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["dns"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/virtualNetworks/" + clusterID.InfraID + "-vnet",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &dns.RecordSet{
|
||||||
|
Name: to.StringPtr(installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/api-int"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/dnszones/a"),
|
||||||
|
RecordSetProperties: &dns.RecordSetProperties{
|
||||||
|
TTL: to.Int64Ptr(300),
|
||||||
|
ARecords: &[]dns.ARecord{
|
||||||
|
{
|
||||||
|
Ipv4Address: to.StringPtr(lbIP.String()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["dns"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &dns.RecordSet{
|
||||||
|
Name: to.StringPtr(installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/api"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/dnszones/a"),
|
||||||
|
RecordSetProperties: &dns.RecordSetProperties{
|
||||||
|
TTL: to.Int64Ptr(300),
|
||||||
|
ARecords: &[]dns.ARecord{
|
||||||
|
{
|
||||||
|
Ipv4Address: to.StringPtr(lbIP.String()),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["dns"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &dns.RecordSet{
|
||||||
|
Name: to.StringPtr(installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/_etcd-server-ssl._tcp"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/dnszones/srv"),
|
||||||
|
RecordSetProperties: &dns.RecordSetProperties{
|
||||||
|
TTL: to.Int64Ptr(60),
|
||||||
|
SrvRecords: &srvRecords,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["dns"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &dns.RecordSet{
|
||||||
|
Name: to.StringPtr("[concat('" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/etcd-', copyIndex())]"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/dnszones/a"),
|
||||||
|
RecordSetProperties: &dns.RecordSetProperties{
|
||||||
|
TTL: to.Int64Ptr(60),
|
||||||
|
ARecords: &[]dns.ARecord{
|
||||||
|
{
|
||||||
|
Ipv4Address: to.StringPtr("[reference(resourceId('Microsoft.Network/networkInterfaces', concat('" + clusterID.InfraID + "-master', copyIndex(), '-nic')), '2019-07-01').ipConfigurations[0].properties.privateIPAddress]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["dns"],
|
||||||
|
Copy: &Copy{
|
||||||
|
Name: "copy",
|
||||||
|
Count: len(machinesMaster.MachineFiles),
|
||||||
|
},
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
"[concat('Microsoft.Network/networkInterfaces/" + clusterID.InfraID + "-master', copyIndex(), '-nic')]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.RouteTable{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-node-routetable"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/routeTables"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.PublicIPAddress{
|
||||||
|
Sku: &network.PublicIPAddressSku{
|
||||||
|
Name: network.PublicIPAddressSkuNameStandard,
|
||||||
|
},
|
||||||
|
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
|
||||||
|
PublicIPAllocationMethod: network.Static,
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-bootstrap-pip"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/publicIPAddresses"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.PublicIPAddress{
|
||||||
|
Sku: &network.PublicIPAddressSku{
|
||||||
|
Name: network.PublicIPAddressSkuNameStandard,
|
||||||
|
},
|
||||||
|
PublicIPAddressPropertiesFormat: &network.PublicIPAddressPropertiesFormat{
|
||||||
|
PublicIPAllocationMethod: network.Static,
|
||||||
|
DNSSettings: &network.PublicIPAddressDNSSettings{
|
||||||
|
DomainNameLabel: &clusterID.InfraID,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-pip"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/publicIPAddresses"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.LoadBalancer{
|
||||||
|
Sku: &network.LoadBalancerSku{
|
||||||
|
Name: network.LoadBalancerSkuNameStandard,
|
||||||
|
},
|
||||||
|
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
|
||||||
|
FrontendIPConfigurations: &[]network.FrontendIPConfiguration{
|
||||||
|
{
|
||||||
|
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
|
||||||
|
PublicIPAddress: &network.PublicIPAddress{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + clusterID.InfraID + "-pip')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("public-lb-ip"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
BackendAddressPools: &[]network.BackendAddressPool{
|
||||||
|
{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-public-lb-control-plane"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
LoadBalancingRules: &[]network.LoadBalancingRule{
|
||||||
|
{
|
||||||
|
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||||
|
FrontendIPConfiguration: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + clusterID.InfraID + "-public-lb', 'public-lb-ip')]"),
|
||||||
|
},
|
||||||
|
BackendAddressPool: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-public-lb', '" + clusterID.InfraID + "-public-lb-control-plane')]"),
|
||||||
|
},
|
||||||
|
Probe: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + clusterID.InfraID + "-public-lb', 'api-internal-probe')]"),
|
||||||
|
},
|
||||||
|
Protocol: network.TransportProtocolTCP,
|
||||||
|
LoadDistribution: network.LoadDistributionDefault,
|
||||||
|
FrontendPort: to.Int32Ptr(6443),
|
||||||
|
BackendPort: to.Int32Ptr(6443),
|
||||||
|
IdleTimeoutInMinutes: to.Int32Ptr(30),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("api-internal"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Probes: &[]network.Probe{
|
||||||
|
{
|
||||||
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
|
Protocol: network.ProbeProtocolTCP,
|
||||||
|
Port: to.Int32Ptr(6443),
|
||||||
|
IntervalInSeconds: to.Int32Ptr(10),
|
||||||
|
NumberOfProbes: to.Int32Ptr(3),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("api-internal-probe"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/loadBalancers/probes"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-public-lb"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/publicIPAddresses/" + clusterID.InfraID + "-pip",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.LoadBalancer{
|
||||||
|
Sku: &network.LoadBalancerSku{
|
||||||
|
Name: network.LoadBalancerSkuNameStandard,
|
||||||
|
},
|
||||||
|
LoadBalancerPropertiesFormat: &network.LoadBalancerPropertiesFormat{
|
||||||
|
FrontendIPConfigurations: &[]network.FrontendIPConfiguration{
|
||||||
|
{
|
||||||
|
FrontendIPConfigurationPropertiesFormat: &network.FrontendIPConfigurationPropertiesFormat{
|
||||||
|
PrivateIPAddress: to.StringPtr(lbIP.String()),
|
||||||
|
PrivateIPAllocationMethod: network.Static,
|
||||||
|
Subnet: &network.Subnet{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/virtualNetworks/subnets', '" + clusterID.InfraID + "-vnet', '" + clusterID.InfraID + "-master-subnet')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("internal-lb-ip"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
BackendAddressPools: &[]network.BackendAddressPool{
|
||||||
|
{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-internal-controlplane"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
LoadBalancingRules: &[]network.LoadBalancingRule{
|
||||||
|
{
|
||||||
|
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||||
|
FrontendIPConfiguration: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + clusterID.InfraID + "-internal-lb', 'internal-lb-ip')]"),
|
||||||
|
},
|
||||||
|
BackendAddressPool: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-internal-lb', '" + clusterID.InfraID + "-internal-controlplane')]"),
|
||||||
|
},
|
||||||
|
Probe: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + clusterID.InfraID + "-internal-lb', 'api-internal-probe')]"),
|
||||||
|
},
|
||||||
|
Protocol: network.TransportProtocolTCP,
|
||||||
|
LoadDistribution: network.LoadDistributionDefault,
|
||||||
|
FrontendPort: to.Int32Ptr(6443),
|
||||||
|
BackendPort: to.Int32Ptr(6443),
|
||||||
|
IdleTimeoutInMinutes: to.Int32Ptr(30),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("api-internal"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
LoadBalancingRulePropertiesFormat: &network.LoadBalancingRulePropertiesFormat{
|
||||||
|
FrontendIPConfiguration: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/frontendIPConfigurations', '" + clusterID.InfraID + "-internal-lb', 'internal-lb-ip')]"),
|
||||||
|
},
|
||||||
|
BackendAddressPool: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-internal-lb', '" + clusterID.InfraID + "-internal-controlplane')]"),
|
||||||
|
},
|
||||||
|
Probe: &network.SubResource{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/probes', '" + clusterID.InfraID + "-internal-lb', 'sint-probe')]"),
|
||||||
|
},
|
||||||
|
Protocol: network.TransportProtocolTCP,
|
||||||
|
LoadDistribution: network.LoadDistributionDefault,
|
||||||
|
FrontendPort: to.Int32Ptr(22623),
|
||||||
|
BackendPort: to.Int32Ptr(22623),
|
||||||
|
IdleTimeoutInMinutes: to.Int32Ptr(30),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("sint"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Probes: &[]network.Probe{
|
||||||
|
{
|
||||||
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
|
Protocol: network.ProbeProtocolTCP,
|
||||||
|
Port: to.Int32Ptr(6443),
|
||||||
|
IntervalInSeconds: to.Int32Ptr(10),
|
||||||
|
NumberOfProbes: to.Int32Ptr(3),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("api-internal-probe"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ProbePropertiesFormat: &network.ProbePropertiesFormat{
|
||||||
|
Protocol: network.ProbeProtocolTCP,
|
||||||
|
Port: to.Int32Ptr(22623),
|
||||||
|
IntervalInSeconds: to.Int32Ptr(10),
|
||||||
|
NumberOfProbes: to.Int32Ptr(3),
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("sint-probe"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-internal-lb"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/loadBalancers"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.Interface{
|
||||||
|
InterfacePropertiesFormat: &network.InterfacePropertiesFormat{
|
||||||
|
IPConfigurations: &[]network.InterfaceIPConfiguration{
|
||||||
|
{
|
||||||
|
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
|
||||||
|
LoadBalancerBackendAddressPools: &[]network.BackendAddressPool{
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-public-lb', '" + clusterID.InfraID + "-public-lb-control-plane')]"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-internal-lb', '" + clusterID.InfraID + "-internal-controlplane')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Subnet: &network.Subnet{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/virtualNetworks/subnets', '" + clusterID.InfraID + "-vnet', '" + clusterID.InfraID + "-master-subnet')]"),
|
||||||
|
},
|
||||||
|
PublicIPAddress: &network.PublicIPAddress{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/publicIPAddresses', '" + clusterID.InfraID + "-bootstrap-pip')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("bootstrap-nic-ip"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-bootstrap-nic"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/networkInterfaces"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/publicIPAddresses/" + clusterID.InfraID + "-bootstrap-pip",
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
"Microsoft.Network/loadBalancers/" + clusterID.InfraID + "-internal-lb",
|
||||||
|
"Microsoft.Network/loadBalancers/" + clusterID.InfraID + "-public-lb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &network.Interface{
|
||||||
|
InterfacePropertiesFormat: &network.InterfacePropertiesFormat{
|
||||||
|
IPConfigurations: &[]network.InterfaceIPConfiguration{
|
||||||
|
{
|
||||||
|
InterfaceIPConfigurationPropertiesFormat: &network.InterfaceIPConfigurationPropertiesFormat{
|
||||||
|
LoadBalancerBackendAddressPools: &[]network.BackendAddressPool{
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-public-lb', '" + clusterID.InfraID + "-public-lb-control-plane')]"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/loadBalancers/backendAddressPools', '" + clusterID.InfraID + "-internal-lb', '" + clusterID.InfraID + "-internal-controlplane')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Subnet: &network.Subnet{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/virtualNetworks/subnets', '" + clusterID.InfraID + "-vnet', '" + clusterID.InfraID + "-master-subnet')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("pipConfig"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("[concat('" + clusterID.InfraID + "-master', copyIndex(), '-nic')]"),
|
||||||
|
Type: to.StringPtr("Microsoft.Network/networkInterfaces"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["network"],
|
||||||
|
Copy: &Copy{
|
||||||
|
Name: "copy",
|
||||||
|
Count: len(machinesMaster.MachineFiles),
|
||||||
|
},
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Network/dnszones/" + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain,
|
||||||
|
"Microsoft.Network/loadBalancers/" + clusterID.InfraID + "-internal-lb",
|
||||||
|
"Microsoft.Network/loadBalancers/" + clusterID.InfraID + "-public-lb",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &compute.Image{
|
||||||
|
ImageProperties: &compute.ImageProperties{
|
||||||
|
StorageProfile: &compute.ImageStorageProfile{
|
||||||
|
OsDisk: &compute.ImageOSDisk{
|
||||||
|
OsType: compute.Linux,
|
||||||
|
BlobURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/vhd/rhcos" + doc.OpenShiftCluster.Properties.StorageSuffix + ".vhd"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
HyperVGeneration: compute.HyperVGenerationTypesV1,
|
||||||
|
},
|
||||||
|
Name: &clusterID.InfraID,
|
||||||
|
Type: to.StringPtr("Microsoft.Compute/images"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["compute"],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &compute.VirtualMachine{
|
||||||
|
VirtualMachineProperties: &compute.VirtualMachineProperties{
|
||||||
|
HardwareProfile: &compute.HardwareProfile{
|
||||||
|
VMSize: compute.VirtualMachineSizeTypesStandardD4sV3,
|
||||||
|
},
|
||||||
|
StorageProfile: &compute.StorageProfile{
|
||||||
|
ImageReference: &compute.ImageReference{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + clusterID.InfraID + "')]"),
|
||||||
|
},
|
||||||
|
OsDisk: &compute.OSDisk{
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-bootstrap_OSDisk"),
|
||||||
|
Caching: compute.CachingTypesReadWrite,
|
||||||
|
CreateOption: compute.DiskCreateOptionTypesFromImage,
|
||||||
|
DiskSizeGB: to.Int32Ptr(100),
|
||||||
|
ManagedDisk: &compute.ManagedDiskParameters{
|
||||||
|
StorageAccountType: compute.StorageAccountTypesPremiumLRS,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: to.StringPtr(clusterID.InfraID + "-bootstrap-vm"),
|
||||||
|
AdminUsername: to.StringPtr("core"),
|
||||||
|
AdminPassword: to.StringPtr("NotActuallyApplied!"),
|
||||||
|
CustomData: to.StringPtr(`[base64(concat('{"ignition":{"version":"2.2.0","config":{"replace":{"source":"https://cluster` + doc.OpenShiftCluster.Properties.StorageSuffix + `.blob.core.windows.net/ignition/bootstrap.ign?', listAccountSas(resourceId('Microsoft.Storage/storageAccounts', 'cluster` + doc.OpenShiftCluster.Properties.StorageSuffix + `'), '2019-04-01', parameters('sas')).accountSasToken, '"}}}}'))]`),
|
||||||
|
LinuxConfiguration: &compute.LinuxConfiguration{
|
||||||
|
DisablePasswordAuthentication: to.BoolPtr(false),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', '" + clusterID.InfraID + "-bootstrap-nic')]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DiagnosticsProfile: &compute.DiagnosticsProfile{
|
||||||
|
BootDiagnostics: &compute.BootDiagnostics{
|
||||||
|
Enabled: to.BoolPtr(true),
|
||||||
|
StorageURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Identity: &compute.VirtualMachineIdentity{
|
||||||
|
Type: compute.ResourceIdentityTypeUserAssigned,
|
||||||
|
UserAssignedIdentities: map[string]*compute.VirtualMachineIdentityUserAssignedIdentitiesValue{
|
||||||
|
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + clusterID.InfraID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Name: to.StringPtr(clusterID.InfraID + "-bootstrap"),
|
||||||
|
Type: to.StringPtr("Microsoft.Compute/virtualMachines"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["compute"],
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Compute/images/" + clusterID.InfraID,
|
||||||
|
"Microsoft.Network/networkInterfaces/" + clusterID.InfraID + "-bootstrap-nic",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Resource: &compute.VirtualMachine{
|
||||||
|
VirtualMachineProperties: &compute.VirtualMachineProperties{
|
||||||
|
HardwareProfile: &compute.HardwareProfile{
|
||||||
|
VMSize: compute.VirtualMachineSizeTypes(installConfig.Config.ControlPlane.Platform.Azure.InstanceType),
|
||||||
|
},
|
||||||
|
StorageProfile: &compute.StorageProfile{
|
||||||
|
ImageReference: &compute.ImageReference{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Compute/images', '" + clusterID.InfraID + "')]"),
|
||||||
|
},
|
||||||
|
OsDisk: &compute.OSDisk{
|
||||||
|
Name: to.StringPtr("[concat('" + clusterID.InfraID + "-master-', copyIndex(), '_OSDisk')]"),
|
||||||
|
Caching: compute.CachingTypesReadOnly,
|
||||||
|
CreateOption: compute.DiskCreateOptionTypesFromImage,
|
||||||
|
DiskSizeGB: &installConfig.Config.ControlPlane.Platform.Azure.OSDisk.DiskSizeGB,
|
||||||
|
ManagedDisk: &compute.ManagedDiskParameters{
|
||||||
|
StorageAccountType: compute.StorageAccountTypesPremiumLRS,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
OsProfile: &compute.OSProfile{
|
||||||
|
ComputerName: to.StringPtr("[concat('" + clusterID.InfraID + "-master-', copyIndex())]"),
|
||||||
|
AdminUsername: to.StringPtr("core"),
|
||||||
|
AdminPassword: to.StringPtr("NotActuallyApplied!"),
|
||||||
|
CustomData: to.StringPtr(base64.StdEncoding.EncodeToString(machineMaster.File.Data)),
|
||||||
|
LinuxConfiguration: &compute.LinuxConfiguration{
|
||||||
|
DisablePasswordAuthentication: to.BoolPtr(false),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
NetworkProfile: &compute.NetworkProfile{
|
||||||
|
NetworkInterfaces: &[]compute.NetworkInterfaceReference{
|
||||||
|
{
|
||||||
|
ID: to.StringPtr("[resourceId('Microsoft.Network/networkInterfaces', concat('" + clusterID.InfraID + "-master', copyIndex(), '-nic'))]"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
DiagnosticsProfile: &compute.DiagnosticsProfile{
|
||||||
|
BootDiagnostics: &compute.BootDiagnostics{
|
||||||
|
Enabled: to.BoolPtr(true),
|
||||||
|
StorageURI: to.StringPtr("https://cluster" + doc.OpenShiftCluster.Properties.StorageSuffix + ".blob.core.windows.net/"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Identity: &compute.VirtualMachineIdentity{
|
||||||
|
Type: compute.ResourceIdentityTypeUserAssigned,
|
||||||
|
UserAssignedIdentities: map[string]*compute.VirtualMachineIdentityUserAssignedIdentitiesValue{
|
||||||
|
"[resourceId('Microsoft.ManagedIdentity/userAssignedIdentities', '" + clusterID.InfraID + "-identity')]": &compute.VirtualMachineIdentityUserAssignedIdentitiesValue{},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Zones: &[]string{
|
||||||
|
"[copyIndex(1)]",
|
||||||
|
},
|
||||||
|
Name: to.StringPtr("[concat('" + clusterID.InfraID + "-master-', copyIndex())]"),
|
||||||
|
Type: to.StringPtr("Microsoft.Compute/virtualMachines"),
|
||||||
|
Location: &installConfig.Config.Azure.Region,
|
||||||
|
},
|
||||||
|
APIVersion: apiVersions["compute"],
|
||||||
|
Copy: &Copy{
|
||||||
|
Name: "copy",
|
||||||
|
Count: len(machinesMaster.MachineFiles),
|
||||||
|
},
|
||||||
|
DependsOn: []string{
|
||||||
|
"Microsoft.Compute/images/" + clusterID.InfraID,
|
||||||
|
"[concat('Microsoft.Network/networkInterfaces/" + clusterID.InfraID + "-master', copyIndex(), '-nic')]",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("deploying resources template")
|
||||||
|
future, err := d.deployments.CreateOrUpdate(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, "azuredeploy", resources.Deployment{
|
||||||
|
Properties: &resources.DeploymentProperties{
|
||||||
|
Template: t,
|
||||||
|
Parameters: map[string]interface{}{
|
||||||
|
"sas": map[string]interface{}{
|
||||||
|
"value": map[string]interface{}{
|
||||||
|
"signedStart": doc.OpenShiftCluster.Properties.Installation.Now.UTC().Format(time.RFC3339),
|
||||||
|
"signedExpiry": doc.OpenShiftCluster.Properties.Installation.Now.Add(24 * time.Hour).Format(time.RFC3339),
|
||||||
|
"signedPermission": "rl",
|
||||||
|
"signedResourceTypes": "o",
|
||||||
|
"signedServices": "b",
|
||||||
|
"signedProtocol": "https",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
Mode: resources.Incremental,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("waiting for resources template deployment")
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.deployments.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
_, err = d.recordsets.CreateOrUpdate(ctx, installConfig.Config.Azure.BaseDomainResourceGroupName, installConfig.Config.BaseDomain, "api."+installConfig.Config.ObjectMeta.Name, dns.CNAME, dns.RecordSet{
|
||||||
|
RecordSetProperties: &dns.RecordSetProperties{
|
||||||
|
TTL: to.Int64Ptr(300),
|
||||||
|
CnameRecord: &dns.CnameRecord{
|
||||||
|
Cname: to.StringPtr(clusterID.InfraID + "." + installConfig.Config.Azure.Region + ".cloudapp.azure.com"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}, "", "")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
restConfig, err := restConfig(adminClient)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cli, err := corev1client.NewForConfig(restConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("waiting for bootstrap configmap")
|
||||||
|
now := time.Now()
|
||||||
|
t := time.NewTicker(10 * time.Second)
|
||||||
|
defer t.Stop()
|
||||||
|
for {
|
||||||
|
cm, err := cli.ConfigMaps("kube-system").Get("bootstrap", metav1.GetOptions{})
|
||||||
|
if err == nil && cm.Data["status"] == "complete" {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Now().Sub(now) > 30*time.Minute {
|
||||||
|
return fmt.Errorf("timed out waiting for bootstrap configmap")
|
||||||
|
}
|
||||||
|
|
||||||
|
<-t.C
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
configv1 "github.com/openshift/api/config/v1"
|
||||||
|
configv1client "github.com/openshift/client-go/config/clientset/versioned/typed/config/v1"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/kubeconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/password"
|
||||||
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (d *Deployer) removeBootstrap(ctx context.Context, doc *api.OpenShiftClusterDocument) error {
|
||||||
|
g, err := d.getGraph(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
adminClient := g[reflect.TypeOf(&kubeconfig.AdminClient{})].(*kubeconfig.AdminClient)
|
||||||
|
clusterID := g[reflect.TypeOf(&installconfig.ClusterID{})].(*installconfig.ClusterID)
|
||||||
|
installConfig := g[reflect.TypeOf(&installconfig.InstallConfig{})].(*installconfig.InstallConfig)
|
||||||
|
kubeadminPassword := g[reflect.TypeOf(&password.KubeadminPassword{})].(*password.KubeadminPassword)
|
||||||
|
|
||||||
|
{
|
||||||
|
future, err := d.virtualmachines.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, clusterID.InfraID+"-bootstrap")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.virtualmachines.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
future, err := d.disks.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, clusterID.InfraID+"-bootstrap_OSDisk")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.disks.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
future, err := d.interfaces.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, clusterID.InfraID+"-bootstrap-nic")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.interfaces.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
future, err := d.publicipaddresses.Delete(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, clusterID.InfraID+"-bootstrap-pip")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = future.WaitForCompletionRef(ctx, d.publicipaddresses.Client)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
restConfig, err := restConfig(adminClient)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
cli, err := configv1client.NewForConfig(restConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
d.log.Print("waiting for version clusterversion")
|
||||||
|
now := time.Now()
|
||||||
|
t := time.NewTicker(10 * time.Second)
|
||||||
|
defer t.Stop()
|
||||||
|
out:
|
||||||
|
for {
|
||||||
|
cv, err := cli.ClusterVersions().Get("version", metav1.GetOptions{})
|
||||||
|
if err == nil {
|
||||||
|
for _, cond := range cv.Status.Conditions {
|
||||||
|
if cond.Type == configv1.OperatorAvailable && cond.Status == configv1.ConditionTrue {
|
||||||
|
break out
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Now().Sub(now) > 30*time.Minute {
|
||||||
|
return fmt.Errorf("timed out waiting for version clusterversion")
|
||||||
|
}
|
||||||
|
|
||||||
|
<-t.C
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doc, err = d.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.APIServerURL = "https://api." + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + ":6443/"
|
||||||
|
doc.OpenShiftCluster.Properties.ConsoleURL = "https://console-openshift-console.apps." + installConfig.Config.ObjectMeta.Name + "." + installConfig.Config.BaseDomain + "/"
|
||||||
|
doc.OpenShiftCluster.Properties.KubeadminPassword = kubeadminPassword.Password
|
||||||
|
doc.OpenShiftCluster.Properties.AdminKubeconfig = adminClient.File.Data
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
}
|
|
@ -0,0 +1,225 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"math"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
var apiVersions = map[string]string{
|
||||||
|
"authorization": "2015-07-01",
|
||||||
|
"compute": "2019-03-01",
|
||||||
|
"dns": "2018-05-01",
|
||||||
|
"msi": "2018-11-30",
|
||||||
|
"network": "2019-07-01",
|
||||||
|
"storage": "2019-04-01",
|
||||||
|
}
|
||||||
|
|
||||||
|
type Template struct {
|
||||||
|
Schema string `json:"$schema,omitempty"`
|
||||||
|
APIProfile string `json:"apiProfile,omitempty"`
|
||||||
|
ContentVersion string `json:"contentVersion,omitempty"`
|
||||||
|
Variables map[string]interface{} `json:"variables,omitempty"`
|
||||||
|
Parameters map[string]Parameter `json:"parameters,omitempty"`
|
||||||
|
Functions []interface{} `json:"functions,omitempty"`
|
||||||
|
Resources []Resource `json:"resources,omitempty"`
|
||||||
|
Outputs map[string]interface{} `json:"outputs,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Parameter struct {
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
DefaultValue interface{} `json:"defaultValue,omitempty"`
|
||||||
|
AllowedValues []interface{} `json:"allowedValues,omitempty"`
|
||||||
|
Metadata map[string]interface{} `json:"metadata,omitempty"`
|
||||||
|
MinValue int `json:"minValue,omitempty"`
|
||||||
|
MaxValue int `json:"maxValue,omitempty"`
|
||||||
|
MinLength int `json:"minLength,omitempty"`
|
||||||
|
MaxLength int `json:"maxLength,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Resource struct {
|
||||||
|
Resource interface{}
|
||||||
|
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Type string `json:"type,omitempty"`
|
||||||
|
Condition bool `json:"condition,omitempty"`
|
||||||
|
APIVersion string `json:"apiVersion,omitempty"`
|
||||||
|
DependsOn []string `json:"dependsOn,omitempty"`
|
||||||
|
Location string `json:"location,omitempty"`
|
||||||
|
Tags map[string]interface{} `json:"tags,omitempty"`
|
||||||
|
Copy *Copy `json:"copy,omitempty"`
|
||||||
|
Comments string `json:"comments,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Copy struct {
|
||||||
|
Name string `json:"name,omitempty"`
|
||||||
|
Count int `json:"count,omitempty"`
|
||||||
|
Mode string `json:"mode,omitempty"`
|
||||||
|
BatchSize int `json:"batchSize,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// MarshalJSON marshals r.Resource ignoring any MarshalJSON() methods on its
|
||||||
|
// types. It then merges remaining fields of r over the result
|
||||||
|
func (r *Resource) MarshalJSON() ([]byte, error) {
|
||||||
|
b, err := json.Marshal(shadowCopy(r.Resource))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var m map[string]interface{}
|
||||||
|
|
||||||
|
err = json.Unmarshal(b, &m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
v := reflect.ValueOf(*r)
|
||||||
|
|
||||||
|
fields := make([]reflect.StructField, 0, v.NumField()-1)
|
||||||
|
for i := 0; i < v.NumField()-1; i++ {
|
||||||
|
fields = append(fields, v.Type().Field(i+1))
|
||||||
|
}
|
||||||
|
|
||||||
|
shadow := reflect.New(reflect.StructOf(fields)).Elem()
|
||||||
|
|
||||||
|
for i := 0; i < v.NumField()-1; i++ {
|
||||||
|
shadow.Field(i).Set(v.Field(i + 1))
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err = json.Marshal(shadow.Interface())
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(b, &m)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
var emptyInterfaceType = reflect.ValueOf([]interface{}(nil)).Type().Elem()
|
||||||
|
|
||||||
|
// shadowCopy returns a copy of the input object wherein all the struct types
|
||||||
|
// have been replaced with dynamically created ones. The idea is that the
|
||||||
|
// JSONMarshal() methods get dropped in the process and so the returned object
|
||||||
|
// marshals natively. Type cycles are permitted, but (as in encoding/json)
|
||||||
|
// value cycles are not. Golang reflect doesn't support dynamically creating
|
||||||
|
// named types; to get around this we go weakly typed
|
||||||
|
func shadowCopy(i interface{}) interface{} {
|
||||||
|
return _shadowCopy(reflect.ValueOf(i)).Interface()
|
||||||
|
}
|
||||||
|
|
||||||
|
func _shadowCopy(v reflect.Value) reflect.Value {
|
||||||
|
switch v.Kind() {
|
||||||
|
case reflect.Array:
|
||||||
|
a := reflect.New(reflect.ArrayOf(v.Len(), emptyInterfaceType)).Elem()
|
||||||
|
for i := 0; i < v.Len(); i++ {
|
||||||
|
a.Index(i).Set(_shadowCopy(v.Index(i)))
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
|
||||||
|
case reflect.Interface, reflect.Ptr:
|
||||||
|
t := emptyInterfaceType
|
||||||
|
if v.IsNil() {
|
||||||
|
return reflect.Zero(t)
|
||||||
|
}
|
||||||
|
i := reflect.New(t).Elem()
|
||||||
|
i.Set(_shadowCopy(v.Elem()))
|
||||||
|
return i
|
||||||
|
|
||||||
|
case reflect.Map:
|
||||||
|
// this is not fully generic but Go json marshaling requires
|
||||||
|
// map[string]interface{}
|
||||||
|
t := reflect.MapOf(reflect.TypeOf(""), emptyInterfaceType)
|
||||||
|
if v.IsNil() {
|
||||||
|
return reflect.Zero(t)
|
||||||
|
}
|
||||||
|
m := reflect.MakeMap(t)
|
||||||
|
iter := v.MapRange()
|
||||||
|
for iter.Next() {
|
||||||
|
m.SetMapIndex(iter.Key(), _shadowCopy(iter.Value()))
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
|
||||||
|
case reflect.Slice:
|
||||||
|
t := reflect.SliceOf(emptyInterfaceType)
|
||||||
|
if v.IsNil() {
|
||||||
|
return reflect.Zero(t)
|
||||||
|
}
|
||||||
|
s := reflect.MakeSlice(t, v.Len(), v.Len())
|
||||||
|
for i := 0; i < v.Len(); i++ {
|
||||||
|
s.Index(i).Set(_shadowCopy(v.Index(i)))
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
|
||||||
|
case reflect.Struct:
|
||||||
|
fields := make([]reflect.StructField, 0, v.Type().NumField())
|
||||||
|
for i := 0; i < v.Type().NumField(); i++ {
|
||||||
|
if v.Type().Field(i).PkgPath != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
field := v.Type().Field(i)
|
||||||
|
field.Type = emptyInterfaceType
|
||||||
|
fields = append(fields, field)
|
||||||
|
}
|
||||||
|
t := reflect.StructOf(fields)
|
||||||
|
|
||||||
|
s := reflect.New(t).Elem()
|
||||||
|
for i, j := 0, 0; i < v.NumField(); i++ {
|
||||||
|
if v.Type().Field(i).PkgPath != "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
f := _shadowCopy(v.Field(i))
|
||||||
|
if !isZero(f) {
|
||||||
|
s.Field(j).Set(f)
|
||||||
|
}
|
||||||
|
j++
|
||||||
|
}
|
||||||
|
return s
|
||||||
|
|
||||||
|
default:
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// isZero is a copy of `func (v reflect.Value) IsZero() bool`, which is built-in
|
||||||
|
// in from Go 1.13
|
||||||
|
func isZero(v reflect.Value) bool {
|
||||||
|
switch v.Kind() {
|
||||||
|
case reflect.Bool:
|
||||||
|
return !v.Bool()
|
||||||
|
case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
|
||||||
|
return v.Int() == 0
|
||||||
|
case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr:
|
||||||
|
return v.Uint() == 0
|
||||||
|
case reflect.Float32, reflect.Float64:
|
||||||
|
return math.Float64bits(v.Float()) == 0
|
||||||
|
case reflect.Complex64, reflect.Complex128:
|
||||||
|
c := v.Complex()
|
||||||
|
return math.Float64bits(real(c)) == 0 && math.Float64bits(imag(c)) == 0
|
||||||
|
case reflect.Array:
|
||||||
|
for i := 0; i < v.Len(); i++ {
|
||||||
|
if !isZero(v.Index(i)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
case reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.UnsafePointer:
|
||||||
|
return v.IsNil()
|
||||||
|
case reflect.String:
|
||||||
|
return v.Len() == 0
|
||||||
|
case reflect.Struct:
|
||||||
|
for i := 0; i < v.NumField(); i++ {
|
||||||
|
if !isZero(v.Field(i)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
default:
|
||||||
|
// This should never happen, but will act as a safeguard for
|
||||||
|
// later, as a default value doesn't makes sense here.
|
||||||
|
panic(&reflect.ValueError{Method: "reflect.Value.IsZero", Kind: v.Kind()})
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,177 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/rand"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"math/big"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/network/mgmt/2019-07-01/network"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-05-01/resources"
|
||||||
|
"github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-04-01/storage"
|
||||||
|
azstorage "github.com/Azure/azure-sdk-for-go/storage"
|
||||||
|
"github.com/Azure/go-autorest/autorest"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/kubeconfig"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"k8s.io/client-go/rest"
|
||||||
|
"k8s.io/client-go/tools/clientcmd"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Deployer struct {
|
||||||
|
log *logrus.Entry
|
||||||
|
db database.OpenShiftClusters
|
||||||
|
|
||||||
|
disks compute.DisksClient
|
||||||
|
virtualmachines compute.VirtualMachinesClient
|
||||||
|
recordsets dns.RecordSetsClient
|
||||||
|
interfaces network.InterfacesClient
|
||||||
|
publicipaddresses network.PublicIPAddressesClient
|
||||||
|
deployments resources.DeploymentsClient
|
||||||
|
groups resources.GroupsClient
|
||||||
|
resources resources.Client
|
||||||
|
accounts storage.AccountsClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewDeployer(log *logrus.Entry, db database.OpenShiftClusters, authorizer autorest.Authorizer, subscriptionID string) *Deployer {
|
||||||
|
d := &Deployer{
|
||||||
|
log: log,
|
||||||
|
db: db,
|
||||||
|
|
||||||
|
disks: compute.NewDisksClient(subscriptionID),
|
||||||
|
virtualmachines: compute.NewVirtualMachinesClient(subscriptionID),
|
||||||
|
recordsets: dns.NewRecordSetsClient(subscriptionID),
|
||||||
|
interfaces: network.NewInterfacesClient(subscriptionID),
|
||||||
|
publicipaddresses: network.NewPublicIPAddressesClient(subscriptionID),
|
||||||
|
deployments: resources.NewDeploymentsClient(subscriptionID),
|
||||||
|
groups: resources.NewGroupsClient(subscriptionID),
|
||||||
|
resources: resources.NewClient(subscriptionID),
|
||||||
|
accounts: storage.NewAccountsClient(subscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
d.disks.Authorizer = authorizer
|
||||||
|
d.virtualmachines.Authorizer = authorizer
|
||||||
|
d.recordsets.Authorizer = authorizer
|
||||||
|
d.interfaces.Authorizer = authorizer
|
||||||
|
d.publicipaddresses.Authorizer = authorizer
|
||||||
|
d.deployments.Authorizer = authorizer
|
||||||
|
d.groups.Authorizer = authorizer
|
||||||
|
d.resources.Authorizer = authorizer
|
||||||
|
d.accounts.Authorizer = authorizer
|
||||||
|
|
||||||
|
return d
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Deployer) Deploy(ctx context.Context, doc *api.OpenShiftClusterDocument, installConfig *installconfig.InstallConfig) error {
|
||||||
|
for {
|
||||||
|
d.log.Printf("starting phase %s", doc.OpenShiftCluster.Properties.Installation.Phase)
|
||||||
|
switch doc.OpenShiftCluster.Properties.Installation.Phase {
|
||||||
|
case api.InstallationPhaseDeployStorage:
|
||||||
|
err := d.deployStorage(ctx, doc, installConfig)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
case api.InstallationPhaseDeployResources:
|
||||||
|
err := d.deployResources(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
case api.InstallationPhaseRemoveBootstrap:
|
||||||
|
err := d.removeBootstrap(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = d.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.Installation = nil
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("unrecognised phase %s", doc.OpenShiftCluster.Properties.Installation.Phase)
|
||||||
|
}
|
||||||
|
|
||||||
|
var err error
|
||||||
|
doc, err = d.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
doc.OpenShiftCluster.Properties.Installation.Phase++
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Deployer) getBlobService(ctx context.Context, doc *api.OpenShiftClusterDocument) (azstorage.BlobStorageClient, error) {
|
||||||
|
keys, err := d.accounts.ListKeys(ctx, doc.OpenShiftCluster.Properties.ResourceGroup, "cluster"+doc.OpenShiftCluster.Properties.StorageSuffix)
|
||||||
|
if err != nil {
|
||||||
|
return azstorage.BlobStorageClient{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
storage, err := azstorage.NewClient("cluster"+doc.OpenShiftCluster.Properties.StorageSuffix, *(*keys.Keys)[0].Value, azstorage.DefaultBaseURL, azstorage.DefaultAPIVersion, true)
|
||||||
|
if err != nil {
|
||||||
|
return azstorage.BlobStorageClient{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return storage.GetBlobService(), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Deployer) getGraph(ctx context.Context, doc *api.OpenShiftClusterDocument) (Graph, error) {
|
||||||
|
d.log.Print("retrieving graph")
|
||||||
|
|
||||||
|
blobService, err := d.getBlobService(ctx, doc)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
aro := blobService.GetContainerReference("aro")
|
||||||
|
cluster := aro.GetBlobReference("graph")
|
||||||
|
rc, err := cluster.Get(nil)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
defer rc.Close()
|
||||||
|
|
||||||
|
var g Graph
|
||||||
|
err = json.NewDecoder(rc).Decode(&g)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return g, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func randomLowerCaseAlphanumericString(n int) (string, error) {
|
||||||
|
return randomString("abcdefghijklmnopqrstuvwxyz0123456789", n)
|
||||||
|
}
|
||||||
|
|
||||||
|
func randomString(letterBytes string, n int) (string, error) {
|
||||||
|
b := make([]byte, n)
|
||||||
|
for i := range b {
|
||||||
|
o, err := rand.Int(rand.Reader, big.NewInt(int64(len(letterBytes))))
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
b[i] = letterBytes[o.Int64()]
|
||||||
|
}
|
||||||
|
|
||||||
|
return string(b), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func restConfig(adminClient *kubeconfig.AdminClient) (*rest.Config, error) {
|
||||||
|
config, err := clientcmd.Load(adminClient.File.Data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return clientcmd.NewDefaultClientConfig(*config, &clientcmd.ConfigOverrides{}).ClientConfig()
|
||||||
|
}
|
|
@ -0,0 +1,175 @@
|
||||||
|
package deploy
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"reflect"
|
||||||
|
|
||||||
|
"github.com/openshift/installer/pkg/asset"
|
||||||
|
"github.com/openshift/installer/pkg/asset/ignition/bootstrap"
|
||||||
|
"github.com/openshift/installer/pkg/asset/ignition/machine"
|
||||||
|
"github.com/openshift/installer/pkg/asset/installconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/kubeconfig"
|
||||||
|
"github.com/openshift/installer/pkg/asset/machines"
|
||||||
|
"github.com/openshift/installer/pkg/asset/manifests"
|
||||||
|
"github.com/openshift/installer/pkg/asset/password"
|
||||||
|
"github.com/openshift/installer/pkg/asset/releaseimage"
|
||||||
|
"github.com/openshift/installer/pkg/asset/rhcos"
|
||||||
|
"github.com/openshift/installer/pkg/asset/templates/content/bootkube"
|
||||||
|
"github.com/openshift/installer/pkg/asset/templates/content/openshift"
|
||||||
|
"github.com/openshift/installer/pkg/asset/tls"
|
||||||
|
)
|
||||||
|
|
||||||
|
var registeredTypes = map[string]asset.Asset{
|
||||||
|
"*bootkube.CVOOverrides": &bootkube.CVOOverrides{},
|
||||||
|
"*bootkube.EtcdCAConfigMap": &bootkube.EtcdCAConfigMap{},
|
||||||
|
"*bootkube.EtcdClientSecret": &bootkube.EtcdClientSecret{},
|
||||||
|
"*bootkube.EtcdHostService": &bootkube.EtcdHostService{},
|
||||||
|
"*bootkube.EtcdHostServiceEndpoints": &bootkube.EtcdHostServiceEndpoints{},
|
||||||
|
"*bootkube.EtcdMetricClientSecret": &bootkube.EtcdMetricClientSecret{},
|
||||||
|
"*bootkube.EtcdMetricServingCAConfigMap": &bootkube.EtcdMetricServingCAConfigMap{},
|
||||||
|
"*bootkube.EtcdMetricSignerSecret": &bootkube.EtcdMetricSignerSecret{},
|
||||||
|
"*bootkube.EtcdNamespace": &bootkube.EtcdNamespace{},
|
||||||
|
"*bootkube.EtcdService": &bootkube.EtcdService{},
|
||||||
|
"*bootkube.EtcdServingCAConfigMap": &bootkube.EtcdServingCAConfigMap{},
|
||||||
|
"*bootkube.EtcdSignerSecret": &bootkube.EtcdSignerSecret{},
|
||||||
|
"*bootkube.KubeCloudConfig": &bootkube.KubeCloudConfig{},
|
||||||
|
"*bootkube.KubeSystemConfigmapRootCA": &bootkube.KubeSystemConfigmapRootCA{},
|
||||||
|
"*bootkube.MachineConfigServerTLSSecret": &bootkube.MachineConfigServerTLSSecret{},
|
||||||
|
"*bootkube.OpenshiftConfigSecretPullSecret": &bootkube.OpenshiftConfigSecretPullSecret{},
|
||||||
|
"*bootkube.OpenshiftMachineConfigOperator": &bootkube.OpenshiftMachineConfigOperator{},
|
||||||
|
"*bootstrap.Bootstrap": &bootstrap.Bootstrap{},
|
||||||
|
"*installconfig.ClusterID": &installconfig.ClusterID{},
|
||||||
|
"*installconfig.InstallConfig": &installconfig.InstallConfig{},
|
||||||
|
"*installconfig.PlatformCredsCheck": &installconfig.PlatformCredsCheck{},
|
||||||
|
"*kubeconfig.AdminClient": &kubeconfig.AdminClient{},
|
||||||
|
"*kubeconfig.Kubelet": &kubeconfig.Kubelet{},
|
||||||
|
"*kubeconfig.LoopbackClient": &kubeconfig.LoopbackClient{},
|
||||||
|
"*machine.Master": &machine.Master{},
|
||||||
|
"*machine.Worker": &machine.Worker{},
|
||||||
|
"*machines.Master": &machines.Master{},
|
||||||
|
"*machines.Worker": &machines.Worker{},
|
||||||
|
"*manifests.AdditionalTrustBundleConfig": &manifests.AdditionalTrustBundleConfig{},
|
||||||
|
"*manifests.CloudProviderConfig": &manifests.CloudProviderConfig{},
|
||||||
|
"*manifests.DNS": &manifests.DNS{},
|
||||||
|
"*manifests.ImageContentSourcePolicy": &manifests.ImageContentSourcePolicy{},
|
||||||
|
"*manifests.Infrastructure": &manifests.Infrastructure{},
|
||||||
|
"*manifests.Ingress": &manifests.Ingress{},
|
||||||
|
"*manifests.Manifests": &manifests.Manifests{},
|
||||||
|
"*manifests.Networking": &manifests.Networking{},
|
||||||
|
"*manifests.Openshift": &manifests.Openshift{},
|
||||||
|
"*manifests.Proxy": &manifests.Proxy{},
|
||||||
|
"*manifests.Scheduler": &manifests.Scheduler{},
|
||||||
|
"*openshift.CloudCredsSecret": &openshift.CloudCredsSecret{},
|
||||||
|
"*openshift.KubeadminPasswordSecret": &openshift.KubeadminPasswordSecret{},
|
||||||
|
"*openshift.NetworkCRDs": &openshift.NetworkCRDs{},
|
||||||
|
"*openshift.RoleBindingCloudCredsSecretReader": &openshift.RoleBindingCloudCredsSecretReader{},
|
||||||
|
"*openshift.RoleCloudCredsSecretReader": &openshift.RoleCloudCredsSecretReader{},
|
||||||
|
"*password.KubeadminPassword": &password.KubeadminPassword{},
|
||||||
|
"*releaseimage.Image": &releaseimage.Image{},
|
||||||
|
"*rhcos.BootstrapImage": new(rhcos.BootstrapImage),
|
||||||
|
"*rhcos.Image": new(rhcos.Image),
|
||||||
|
"*tls.AdminKubeConfigCABundle": &tls.AdminKubeConfigCABundle{},
|
||||||
|
"*tls.AdminKubeConfigClientCertKey": &tls.AdminKubeConfigClientCertKey{},
|
||||||
|
"*tls.AdminKubeConfigSignerCertKey": &tls.AdminKubeConfigSignerCertKey{},
|
||||||
|
"*tls.AggregatorCA": &tls.AggregatorCA{},
|
||||||
|
"*tls.AggregatorCABundle": &tls.AggregatorCABundle{},
|
||||||
|
"*tls.AggregatorClientCertKey": &tls.AggregatorClientCertKey{},
|
||||||
|
"*tls.AggregatorSignerCertKey": &tls.AggregatorSignerCertKey{},
|
||||||
|
"*tls.APIServerProxyCertKey": &tls.APIServerProxyCertKey{},
|
||||||
|
"*tls.EtcdCABundle": &tls.EtcdCABundle{},
|
||||||
|
"*tls.EtcdMetricCABundle": &tls.EtcdMetricCABundle{},
|
||||||
|
"*tls.EtcdMetricSignerCertKey": &tls.EtcdMetricSignerCertKey{},
|
||||||
|
"*tls.EtcdMetricSignerClientCertKey": &tls.EtcdMetricSignerClientCertKey{},
|
||||||
|
"*tls.EtcdSignerCertKey": &tls.EtcdSignerCertKey{},
|
||||||
|
"*tls.EtcdSignerClientCertKey": &tls.EtcdSignerClientCertKey{},
|
||||||
|
"*tls.JournalCertKey": &tls.JournalCertKey{},
|
||||||
|
"*tls.KubeAPIServerCompleteCABundle": &tls.KubeAPIServerCompleteCABundle{},
|
||||||
|
"*tls.KubeAPIServerCompleteClientCABundle": &tls.KubeAPIServerCompleteClientCABundle{},
|
||||||
|
"*tls.KubeAPIServerExternalLBServerCertKey": &tls.KubeAPIServerExternalLBServerCertKey{},
|
||||||
|
"*tls.KubeAPIServerInternalLBServerCertKey": &tls.KubeAPIServerInternalLBServerCertKey{},
|
||||||
|
"*tls.KubeAPIServerLBCABundle": &tls.KubeAPIServerLBCABundle{},
|
||||||
|
"*tls.KubeAPIServerLBSignerCertKey": &tls.KubeAPIServerLBSignerCertKey{},
|
||||||
|
"*tls.KubeAPIServerLocalhostCABundle": &tls.KubeAPIServerLocalhostCABundle{},
|
||||||
|
"*tls.KubeAPIServerLocalhostServerCertKey": &tls.KubeAPIServerLocalhostServerCertKey{},
|
||||||
|
"*tls.KubeAPIServerLocalhostSignerCertKey": &tls.KubeAPIServerLocalhostSignerCertKey{},
|
||||||
|
"*tls.KubeAPIServerServiceNetworkCABundle": &tls.KubeAPIServerServiceNetworkCABundle{},
|
||||||
|
"*tls.KubeAPIServerServiceNetworkServerCertKey": &tls.KubeAPIServerServiceNetworkServerCertKey{},
|
||||||
|
"*tls.KubeAPIServerServiceNetworkSignerCertKey": &tls.KubeAPIServerServiceNetworkSignerCertKey{},
|
||||||
|
"*tls.KubeAPIServerToKubeletCABundle": &tls.KubeAPIServerToKubeletCABundle{},
|
||||||
|
"*tls.KubeAPIServerToKubeletClientCertKey": &tls.KubeAPIServerToKubeletClientCertKey{},
|
||||||
|
"*tls.KubeAPIServerToKubeletSignerCertKey": &tls.KubeAPIServerToKubeletSignerCertKey{},
|
||||||
|
"*tls.KubeControlPlaneCABundle": &tls.KubeControlPlaneCABundle{},
|
||||||
|
"*tls.KubeControlPlaneKubeControllerManagerClientCertKey": &tls.KubeControlPlaneKubeControllerManagerClientCertKey{},
|
||||||
|
"*tls.KubeControlPlaneKubeSchedulerClientCertKey": &tls.KubeControlPlaneKubeSchedulerClientCertKey{},
|
||||||
|
"*tls.KubeControlPlaneSignerCertKey": &tls.KubeControlPlaneSignerCertKey{},
|
||||||
|
"*tls.KubeletBootstrapCABundle": &tls.KubeletBootstrapCABundle{},
|
||||||
|
"*tls.KubeletBootstrapCertSigner": &tls.KubeletBootstrapCertSigner{},
|
||||||
|
"*tls.KubeletClientCABundle": &tls.KubeletClientCABundle{},
|
||||||
|
"*tls.KubeletClientCertKey": &tls.KubeletClientCertKey{},
|
||||||
|
"*tls.KubeletCSRSignerCertKey": &tls.KubeletCSRSignerCertKey{},
|
||||||
|
"*tls.KubeletServingCABundle": &tls.KubeletServingCABundle{},
|
||||||
|
"*tls.MCSCertKey": &tls.MCSCertKey{},
|
||||||
|
"*tls.RootCA": &tls.RootCA{},
|
||||||
|
"*tls.ServiceAccountKeyPair": &tls.ServiceAccountKeyPair{},
|
||||||
|
}
|
||||||
|
|
||||||
|
type Graph map[reflect.Type]asset.Asset
|
||||||
|
|
||||||
|
func (g Graph) resolve(a asset.Asset) (asset.Asset, error) {
|
||||||
|
for _, dep := range a.Dependencies() {
|
||||||
|
if _, found := g[reflect.TypeOf(dep)]; found {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
dep, err := g.resolve(dep)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
g[reflect.TypeOf(dep)] = dep
|
||||||
|
}
|
||||||
|
|
||||||
|
err := a.Generate(asset.Parents(g))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return a, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g Graph) MarshalJSON() ([]byte, error) {
|
||||||
|
m := map[string]asset.Asset{}
|
||||||
|
for t, a := range g {
|
||||||
|
m[t.String()] = a
|
||||||
|
}
|
||||||
|
return json.Marshal(m)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (g *Graph) UnmarshalJSON(b []byte) error {
|
||||||
|
if *g == nil {
|
||||||
|
*g = Graph{}
|
||||||
|
}
|
||||||
|
|
||||||
|
var m map[string]json.RawMessage
|
||||||
|
err := json.Unmarshal(b, &m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
for n, b := range m {
|
||||||
|
t, found := registeredTypes[n]
|
||||||
|
if !found {
|
||||||
|
return fmt.Errorf("unregistered type %q", n)
|
||||||
|
}
|
||||||
|
|
||||||
|
a := reflect.New(reflect.TypeOf(t).Elem()).Interface().(asset.Asset)
|
||||||
|
err = json.Unmarshal(b, a)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
(*g)[reflect.TypeOf(a)] = a
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
type noContent struct{}
|
||||||
|
|
||||||
|
func (noContent) Error() string { return "" }
|
||||||
|
|
||||||
|
func (f *frontend) deleteOpenShiftCluster(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := r.Context().Value(contextKeyLog).(*logrus.Entry)
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
_, found := api.APIs[api.APIVersionType{APIVersion: r.URL.Query().Get("api-version"), Type: "OpenShiftCluster"}]
|
||||||
|
if !found {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "", "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err := f.db.Patch(r.URL.Path, func(doc *api.OpenShiftClusterDocument) error {
|
||||||
|
return f._deleteOpenShiftCluster(&request{
|
||||||
|
resourceID: r.URL.Path,
|
||||||
|
}, doc)
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *api.CloudError:
|
||||||
|
f.cloudError(w, err)
|
||||||
|
case *noContent:
|
||||||
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
default:
|
||||||
|
log.Error(err)
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) _deleteOpenShiftCluster(r *request, doc *api.OpenShiftClusterDocument) error {
|
||||||
|
if doc == nil {
|
||||||
|
return &noContent{}
|
||||||
|
}
|
||||||
|
|
||||||
|
err := validateProvisioningState(doc.OpenShiftCluster.Properties.ProvisioningState, api.ProvisioningStateSucceeded, api.ProvisioningStateFailed)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.Unqueued = true
|
||||||
|
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateDeleting
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,128 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"sync/atomic"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
resourceProviderNamespace = "RedHat.OpenShift"
|
||||||
|
resourceType = "OpenShiftClusters"
|
||||||
|
)
|
||||||
|
|
||||||
|
type request struct {
|
||||||
|
method string
|
||||||
|
subscriptionID string
|
||||||
|
resourceID string
|
||||||
|
resourceGroupName string
|
||||||
|
resourceName string
|
||||||
|
resourceType string
|
||||||
|
body []byte
|
||||||
|
toExternal func(*api.OpenShiftCluster) api.External
|
||||||
|
}
|
||||||
|
|
||||||
|
func validateProvisioningState(state api.ProvisioningState, allowedStates ...api.ProvisioningState) error {
|
||||||
|
for _, allowedState := range allowedStates {
|
||||||
|
if state == allowedState {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeRequestNotAllowed, "", "Request is not allowed in provisioningState '%s'.", state)
|
||||||
|
}
|
||||||
|
|
||||||
|
type frontend struct {
|
||||||
|
baseLog *logrus.Entry
|
||||||
|
|
||||||
|
db database.OpenShiftClusters
|
||||||
|
apis map[api.APIVersionType]func(*api.OpenShiftCluster) api.External
|
||||||
|
|
||||||
|
l net.Listener
|
||||||
|
|
||||||
|
healthy atomic.Value
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runnable represents a runnable object
|
||||||
|
type Runnable interface {
|
||||||
|
Run(stop <-chan struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewFrontend returns a new runnable frontend
|
||||||
|
func NewFrontend(baseLog *logrus.Entry, l net.Listener, db database.OpenShiftClusters, apis map[api.APIVersionType]func(*api.OpenShiftCluster) api.External) Runnable {
|
||||||
|
f := &frontend{
|
||||||
|
baseLog: baseLog,
|
||||||
|
db: db,
|
||||||
|
apis: apis,
|
||||||
|
|
||||||
|
l: l,
|
||||||
|
}
|
||||||
|
|
||||||
|
f.healthy.Store(true)
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) health(w http.ResponseWriter, r *http.Request) {
|
||||||
|
if f.healthy.Load().(bool) {
|
||||||
|
http.Error(w, "", http.StatusOK)
|
||||||
|
} else {
|
||||||
|
http.Error(w, "", http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) Run(stop <-chan struct{}) {
|
||||||
|
r := mux.NewRouter()
|
||||||
|
r.PathPrefix("/debug/pprof/").Handler(http.DefaultServeMux)
|
||||||
|
r.Path("/health").Methods(http.MethodGet).HandlerFunc(f.health)
|
||||||
|
|
||||||
|
s := r.
|
||||||
|
Path("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}").
|
||||||
|
Queries("api-version", "").
|
||||||
|
Subrouter()
|
||||||
|
|
||||||
|
s.Use(f.middleware)
|
||||||
|
s.Methods(http.MethodDelete).HandlerFunc(f.deleteOpenShiftCluster)
|
||||||
|
s.Methods(http.MethodGet).HandlerFunc(f.getOpenShiftCluster)
|
||||||
|
s.Methods(http.MethodPatch).HandlerFunc(f.putOrPatchOpenShiftCluster)
|
||||||
|
s.Methods(http.MethodPut).HandlerFunc(f.putOrPatchOpenShiftCluster)
|
||||||
|
|
||||||
|
s = r.
|
||||||
|
Path("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}").
|
||||||
|
Queries("api-version", "").
|
||||||
|
Subrouter()
|
||||||
|
|
||||||
|
s.Use(f.middleware)
|
||||||
|
s.Methods(http.MethodGet).HandlerFunc(f.getOpenShiftClusters)
|
||||||
|
|
||||||
|
s = r.
|
||||||
|
Path("/subscriptions/{subscriptionId}/providers/{resourceProviderNamespace}/{resourceType}").
|
||||||
|
Queries("api-version", "").
|
||||||
|
Subrouter()
|
||||||
|
|
||||||
|
s.Use(f.middleware)
|
||||||
|
s.Methods(http.MethodGet).HandlerFunc(f.getOpenShiftClusters)
|
||||||
|
|
||||||
|
s = r.
|
||||||
|
Path("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}/credentials").
|
||||||
|
Queries("api-version", "").
|
||||||
|
Subrouter()
|
||||||
|
|
||||||
|
s.Use(f.middleware)
|
||||||
|
s.Methods(http.MethodGet).HandlerFunc(f.getOpenShiftClusterCredentials)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
<-stop
|
||||||
|
f.baseLog.Println("marking frontend unhealthy")
|
||||||
|
f.healthy.Store(false)
|
||||||
|
}()
|
||||||
|
|
||||||
|
err := http.Serve(f.l, r)
|
||||||
|
f.baseLog.Error(err)
|
||||||
|
}
|
|
@ -0,0 +1,166 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"net/http"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (f *frontend) getOpenShiftCluster(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := r.Context().Value(contextKeyLog).(*logrus.Entry)
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
toExternal, found := api.APIs[api.APIVersionType{APIVersion: r.URL.Query().Get("api-version"), Type: "OpenShiftCluster"}]
|
||||||
|
if !found {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "", "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := f._getOpenShiftCluster(&request{
|
||||||
|
resourceID: r.URL.Path,
|
||||||
|
resourceGroupName: vars["resourceGroupName"],
|
||||||
|
resourceName: vars["resourceName"],
|
||||||
|
resourceType: vars["resourceProviderNamespace"] + "/" + vars["resourceType"],
|
||||||
|
toExternal: toExternal,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *api.CloudError:
|
||||||
|
f.cloudError(w, err)
|
||||||
|
default:
|
||||||
|
log.Error(err)
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(b)
|
||||||
|
w.Write([]byte{'\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) _getOpenShiftCluster(r *request) ([]byte, error) {
|
||||||
|
doc, err := f.db.Get(r.resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if doc == nil {
|
||||||
|
return nil, api.NewCloudError(http.StatusNotFound, api.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s' under resource group '%s' was not found.", r.resourceType, r.resourceName, r.resourceGroupName)
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.ID = r.resourceID
|
||||||
|
doc.OpenShiftCluster.Name = r.resourceName
|
||||||
|
doc.OpenShiftCluster.Type = r.resourceType
|
||||||
|
doc.OpenShiftCluster.Properties.PullSecret = nil
|
||||||
|
|
||||||
|
return json.MarshalIndent(r.toExternal(doc.OpenShiftCluster), "", " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) getOpenShiftClusters(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := r.Context().Value(contextKeyLog).(*logrus.Entry)
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
toExternal, found := api.APIs[api.APIVersionType{APIVersion: r.URL.Query().Get("api-version"), Type: "OpenShiftCluster"}]
|
||||||
|
if !found {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "", "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := f._getOpenShiftClusters(&request{
|
||||||
|
subscriptionID: vars["subscriptionId"],
|
||||||
|
resourceGroupName: vars["resourceGroupName"],
|
||||||
|
resourceType: vars["resourceProviderNamespace"] + "/" + vars["resourceType"],
|
||||||
|
toExternal: toExternal,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *api.CloudError:
|
||||||
|
f.cloudError(w, err)
|
||||||
|
default:
|
||||||
|
log.Error(err)
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(b)
|
||||||
|
w.Write([]byte{'\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) _getOpenShiftClusters(r *request) ([]byte, error) {
|
||||||
|
prefix := "/subscriptions/" + r.subscriptionID + "/"
|
||||||
|
if r.resourceGroupName != "" {
|
||||||
|
prefix += "resourceGroups/" + r.resourceGroupName + "/"
|
||||||
|
}
|
||||||
|
i := f.db.ListByPrefix(r.subscriptionID, prefix)
|
||||||
|
|
||||||
|
var rv struct {
|
||||||
|
Value []api.External `json:"value"`
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
docs, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if docs == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, doc := range docs.OpenShiftClusterDocuments {
|
||||||
|
doc.OpenShiftCluster.Type = r.resourceType
|
||||||
|
doc.OpenShiftCluster.Properties.PullSecret = nil
|
||||||
|
rv.Value = append(rv.Value, r.toExternal(doc.OpenShiftCluster))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.MarshalIndent(rv, "", " ")
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) getOpenShiftClusterCredentials(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := r.Context().Value(contextKeyLog).(*logrus.Entry)
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
toExternal, found := api.APIs[api.APIVersionType{APIVersion: r.URL.Query().Get("api-version"), Type: "OpenShiftClusterCredentials"}]
|
||||||
|
if !found {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
b, err := f._getOpenShiftClusterCredentials(&request{
|
||||||
|
resourceID: filepath.Dir(r.URL.Path),
|
||||||
|
resourceGroupName: vars["resourceGroupName"],
|
||||||
|
toExternal: toExternal,
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *api.CloudError:
|
||||||
|
f.cloudError(w, err)
|
||||||
|
default:
|
||||||
|
log.Error(err)
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(b)
|
||||||
|
w.Write([]byte{'\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) _getOpenShiftClusterCredentials(r *request) ([]byte, error) {
|
||||||
|
doc, err := f.db.Get(r.resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if doc == nil {
|
||||||
|
return nil, api.NewCloudError(http.StatusNotFound, api.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s/credentials' under resource group '%s' was not found.", r.resourceType, r.resourceName, r.resourceGroupName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.MarshalIndent(r.toExternal(doc.OpenShiftCluster), "", " ")
|
||||||
|
}
|
|
@ -0,0 +1,109 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"io"
|
||||||
|
"net/http"
|
||||||
|
"runtime/debug"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
type contextKey int
|
||||||
|
|
||||||
|
const (
|
||||||
|
contextKeyLog contextKey = iota
|
||||||
|
)
|
||||||
|
|
||||||
|
type statsResponseWriter struct {
|
||||||
|
statusCode int
|
||||||
|
bytes int
|
||||||
|
|
||||||
|
http.ResponseWriter
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *statsResponseWriter) Write(b []byte) (int, error) {
|
||||||
|
n, err := w.ResponseWriter.Write(b)
|
||||||
|
w.bytes += n
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (w *statsResponseWriter) WriteHeader(statusCode int) {
|
||||||
|
w.ResponseWriter.WriteHeader(statusCode)
|
||||||
|
w.statusCode = statusCode
|
||||||
|
}
|
||||||
|
|
||||||
|
type statsReadCloser struct {
|
||||||
|
bytes int
|
||||||
|
|
||||||
|
io.ReadCloser
|
||||||
|
}
|
||||||
|
|
||||||
|
func (rc *statsReadCloser) Read(b []byte) (int, error) {
|
||||||
|
n, err := rc.ReadCloser.Read(b)
|
||||||
|
rc.bytes += n
|
||||||
|
return n, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) middleware(h http.Handler) http.Handler {
|
||||||
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
t := time.Now()
|
||||||
|
b := &statsReadCloser{ReadCloser: r.Body}
|
||||||
|
r.Body = b
|
||||||
|
w = &statsResponseWriter{ResponseWriter: w}
|
||||||
|
|
||||||
|
correlationID := r.Header.Get("X-Ms-Correlation-Request-Id")
|
||||||
|
requestID := uuid.NewV4().String()
|
||||||
|
log := f.baseLog.WithFields(logrus.Fields{"correlation-id": correlationID, "request-id": requestID})
|
||||||
|
r = r.WithContext(context.WithValue(r.Context(), contextKeyLog, log))
|
||||||
|
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
|
w.Header().Set("X-Ms-Request-Id", requestID)
|
||||||
|
|
||||||
|
defer func() {
|
||||||
|
if e := recover(); e != nil {
|
||||||
|
log.Errorf("panic: %#v\n%s\n", e, string(debug.Stack()))
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
log.WithFields(logrus.Fields{
|
||||||
|
"access": true,
|
||||||
|
"bodyReceivedBytes": b.bytes,
|
||||||
|
"bodySentBytes": w.(*statsResponseWriter).bytes,
|
||||||
|
"requestDurationMs": int(time.Now().Sub(t) / time.Millisecond),
|
||||||
|
"requestMethod": r.Method,
|
||||||
|
"requestPath": r.URL.Path,
|
||||||
|
"requestProto": r.Proto,
|
||||||
|
"requestRemoteAddr": r.RemoteAddr,
|
||||||
|
"requestUserAgent": r.UserAgent(),
|
||||||
|
"responseStatusCode": w.(*statsResponseWriter).statusCode,
|
||||||
|
}).Print()
|
||||||
|
}()
|
||||||
|
|
||||||
|
if !f.isValidRequestPath(w, r) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if strings.EqualFold(r.Header.Get("X-Ms-Return-Client-Request-Id"), "true") {
|
||||||
|
w.Header().Set("X-Ms-Client-Request-Id", r.Header.Get("X-Ms-Client-Request-Id"))
|
||||||
|
}
|
||||||
|
|
||||||
|
h.ServeHTTP(w, r)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) error(w http.ResponseWriter, statusCode int, code, target, message string, a ...interface{}) {
|
||||||
|
f.cloudError(w, api.NewCloudError(statusCode, code, target, message, a...))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) cloudError(w http.ResponseWriter, err *api.CloudError) {
|
||||||
|
w.WriteHeader(err.StatusCode)
|
||||||
|
e := json.NewEncoder(w)
|
||||||
|
e.SetIndent("", " ")
|
||||||
|
e.Encode(err)
|
||||||
|
}
|
|
@ -0,0 +1,164 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database/cosmosdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (f *frontend) putOrPatchOpenShiftCluster(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log := r.Context().Value(contextKeyLog).(*logrus.Entry)
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
toExternal, found := api.APIs[api.APIVersionType{APIVersion: r.URL.Query().Get("api-version"), Type: "OpenShiftCluster"}]
|
||||||
|
if !found {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "", "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if r.Header.Get("Content-Type") != "application/json" {
|
||||||
|
f.error(w, http.StatusUnsupportedMediaType, api.CloudErrorCodeUnsupportedMediaType, "", "The content media type '%s' is not supported. Only 'application/json' is supported.", r.Header.Get("Content-Type"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
body, err := ioutil.ReadAll(http.MaxBytesReader(w, r.Body, 1048576))
|
||||||
|
if err != nil {
|
||||||
|
f.error(w, http.StatusUnsupportedMediaType, api.CloudErrorCodeInvalidResource, "", "The resource definition is invalid.")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var b []byte
|
||||||
|
err = cosmosdb.RetryOnPreconditionFailed(func() error {
|
||||||
|
b, err = f._putOrPatchOpenShiftCluster(&request{
|
||||||
|
method: r.Method,
|
||||||
|
resourceID: r.URL.Path,
|
||||||
|
resourceName: vars["resourceName"],
|
||||||
|
resourceType: vars["resourceProviderNamespace"] + "/" + vars["resourceType"],
|
||||||
|
body: body,
|
||||||
|
toExternal: toExternal,
|
||||||
|
})
|
||||||
|
return err
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
switch err := err.(type) {
|
||||||
|
case *api.CloudError:
|
||||||
|
f.cloudError(w, err)
|
||||||
|
default:
|
||||||
|
log.Error(err)
|
||||||
|
f.error(w, http.StatusInternalServerError, api.CloudErrorCodeInternalServerError, "", "Internal server error.")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
w.Write(b)
|
||||||
|
w.Write([]byte{'\n'})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *frontend) _putOrPatchOpenShiftCluster(r *request) ([]byte, error) {
|
||||||
|
doc, err := f.db.Get(r.resourceID)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
isCreate := doc == nil
|
||||||
|
|
||||||
|
var external api.External
|
||||||
|
if isCreate {
|
||||||
|
doc = &api.OpenShiftClusterDocument{
|
||||||
|
ID: uuid.NewV4().String(),
|
||||||
|
}
|
||||||
|
|
||||||
|
external = r.toExternal(&api.OpenShiftCluster{
|
||||||
|
ID: r.resourceID,
|
||||||
|
Name: r.resourceName,
|
||||||
|
Type: r.resourceType,
|
||||||
|
Properties: api.Properties{
|
||||||
|
ProvisioningState: api.ProvisioningStateSucceeded,
|
||||||
|
NetworkProfile: api.NetworkProfile{
|
||||||
|
VNetCIDR: "10.0.0.0/16",
|
||||||
|
PodCIDR: "10.128.0.0/14",
|
||||||
|
ServiceCIDR: "172.30.0.0/16",
|
||||||
|
},
|
||||||
|
MasterProfile: api.MasterProfile{
|
||||||
|
VMSize: api.VMSizeStandardD8sV3,
|
||||||
|
},
|
||||||
|
WorkerProfiles: []api.WorkerProfile{
|
||||||
|
{
|
||||||
|
Name: "worker",
|
||||||
|
VMSize: api.VMSizeStandardD2sV3,
|
||||||
|
DiskSizeGB: 128,
|
||||||
|
Count: 3,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
} else {
|
||||||
|
err = validateProvisioningState(doc.OpenShiftCluster.Properties.ProvisioningState, api.ProvisioningStateSucceeded)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch r.method {
|
||||||
|
case http.MethodPut:
|
||||||
|
external = r.toExternal(&api.OpenShiftCluster{
|
||||||
|
ID: r.resourceID,
|
||||||
|
Name: r.resourceName,
|
||||||
|
Type: r.resourceType,
|
||||||
|
Properties: api.Properties{
|
||||||
|
ProvisioningState: doc.OpenShiftCluster.Properties.ProvisioningState,
|
||||||
|
PullSecret: doc.OpenShiftCluster.Properties.PullSecret,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
case http.MethodPatch:
|
||||||
|
external = r.toExternal(doc.OpenShiftCluster)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(r.body, &external)
|
||||||
|
if err != nil {
|
||||||
|
return nil, api.NewCloudError(http.StatusBadRequest, api.CloudErrorCodeInvalidRequestContent, "", "The request content was invalid and could not be deserialized: %q.", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = external.Validate(r.resourceID, doc.OpenShiftCluster)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if doc.OpenShiftCluster == nil {
|
||||||
|
doc.OpenShiftCluster = &api.OpenShiftCluster{
|
||||||
|
Properties: api.Properties{
|
||||||
|
Installation: &api.Installation{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
external.ToInternal(doc.OpenShiftCluster)
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.Properties.ProvisioningState = api.ProvisioningStateUpdating
|
||||||
|
doc.Unqueued = true
|
||||||
|
|
||||||
|
if isCreate {
|
||||||
|
doc, err = f.db.Create(doc)
|
||||||
|
} else {
|
||||||
|
doc, err = f.db.Update(doc)
|
||||||
|
}
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.OpenShiftCluster.ID = r.resourceID
|
||||||
|
doc.OpenShiftCluster.Name = r.resourceName
|
||||||
|
doc.OpenShiftCluster.Type = r.resourceType
|
||||||
|
doc.OpenShiftCluster.Properties.PullSecret = nil
|
||||||
|
|
||||||
|
return json.MarshalIndent(r.toExternal(doc.OpenShiftCluster), "", " ")
|
||||||
|
}
|
|
@ -0,0 +1,49 @@
|
||||||
|
package frontend
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"regexp"
|
||||||
|
|
||||||
|
"github.com/gorilla/mux"
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
)
|
||||||
|
|
||||||
|
var rxResourceGroupName = regexp.MustCompile(`(?i)^[-a-z0-9_().]{0,89}[-a-z0-9_()]$`)
|
||||||
|
|
||||||
|
func (f *frontend) isValidRequestPath(w http.ResponseWriter, r *http.Request) bool {
|
||||||
|
vars := mux.Vars(r)
|
||||||
|
|
||||||
|
_, err := uuid.FromString(vars["subscriptionId"])
|
||||||
|
if err != nil {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidSubscriptionID, "", "The provided subscription identifier '%s' is malformed or invalid.", vars["subscriptionId"])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, found := vars["resourceGroupName"]; found {
|
||||||
|
if !rxResourceGroupName.MatchString(vars["resourceGroupName"]) {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeResourceGroupNotFound, "", "Resource group '%s' could not be found.", vars["resourceGroupName"])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars["resourceProviderNamespace"] != resourceProviderNamespace {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceNamespace, "", "The resource namespace '%s' is invalid.", vars["resourceProviderNamespace"])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if vars["resourceType"] != resourceType {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeInvalidResourceType, "", "The resource type '%s' could not be found in the namespace '%s' for api version '%s'.", vars["resourceType"], vars["resourceProviderNamespace"], r.URL.Query().Get("api-version"))
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, found := vars["resourceName"]; found {
|
||||||
|
if !rxResourceGroupName.MatchString(vars["resourceName"]) {
|
||||||
|
f.error(w, http.StatusNotFound, api.CloudErrorCodeResourceNotFound, "", "The Resource '%s/%s/%s' under resource group '%s' was not found.", vars["resourceProviderNamespace"], vars["resourceType"], vars["resourceName"], vars["resourceGroupName"])
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package forwarder
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database"
|
||||||
|
"github.com/jim-minter/rp/pkg/queue"
|
||||||
|
"github.com/jim-minter/rp/pkg/queue/leaser"
|
||||||
|
)
|
||||||
|
|
||||||
|
type forwarder struct {
|
||||||
|
baseLog *logrus.Entry
|
||||||
|
q queue.Queue
|
||||||
|
db database.OpenShiftClusters
|
||||||
|
l leaser.Leaser
|
||||||
|
}
|
||||||
|
|
||||||
|
// Runnable represents a runnable object
|
||||||
|
type Runnable interface {
|
||||||
|
Run(stop <-chan struct{})
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForwarder returns a new runnable forwarder
|
||||||
|
func NewForwarder(log *logrus.Entry, q queue.Queue, db database.OpenShiftClusters, l leaser.Leaser) Runnable {
|
||||||
|
return &forwarder{
|
||||||
|
baseLog: log,
|
||||||
|
q: q,
|
||||||
|
db: db,
|
||||||
|
l: l,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *forwarder) Run(stop <-chan struct{}) {
|
||||||
|
t := time.NewTicker(time.Second)
|
||||||
|
defer t.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
if f.l.HoldLease() {
|
||||||
|
err := f.runOnce()
|
||||||
|
if err != nil {
|
||||||
|
f.baseLog.Error(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-t.C:
|
||||||
|
case <-stop:
|
||||||
|
f.baseLog.Print("stopping")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (f *forwarder) runOnce() error {
|
||||||
|
i := f.db.ListUnqueued()
|
||||||
|
|
||||||
|
for {
|
||||||
|
docs, err := i.Next()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if docs == nil {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, doc := range docs.OpenShiftClusterDocuments {
|
||||||
|
log := f.baseLog.WithField("resource", doc.OpenShiftCluster.ID)
|
||||||
|
err = f.q.Put(doc.OpenShiftCluster.ID)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Print("enqueued")
|
||||||
|
|
||||||
|
doc, err = f.db.Patch(doc.OpenShiftCluster.ID, func(doc *api.OpenShiftClusterDocument) (err error) {
|
||||||
|
doc.Unqueued = false
|
||||||
|
return nil
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
|
@ -0,0 +1,112 @@
|
||||||
|
package leaser
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
|
||||||
|
uuid "github.com/satori/go.uuid"
|
||||||
|
|
||||||
|
"github.com/jim-minter/rp/pkg/api"
|
||||||
|
"github.com/jim-minter/rp/pkg/database/cosmosdb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Leaser interface {
|
||||||
|
HoldLease() bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type leaser struct {
|
||||||
|
log *logrus.Entry
|
||||||
|
lc cosmosdb.LeaseDocumentClient
|
||||||
|
|
||||||
|
uuid uuid.UUID
|
||||||
|
leaseid string
|
||||||
|
holdLease bool
|
||||||
|
|
||||||
|
ticker *time.Ticker
|
||||||
|
|
||||||
|
leaseLength time.Duration
|
||||||
|
validUntil time.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewLeaser(log *logrus.Entry, dbc cosmosdb.DatabaseClient, dbid, collid, leaseid string, refresh, leaseLength time.Duration) Leaser {
|
||||||
|
collc := cosmosdb.NewCollectionClient(dbc, dbid)
|
||||||
|
|
||||||
|
return &leaser{
|
||||||
|
log: log,
|
||||||
|
lc: cosmosdb.NewLeaseDocumentClient(collc, collid),
|
||||||
|
uuid: uuid.NewV4(),
|
||||||
|
leaseid: leaseid,
|
||||||
|
ticker: time.NewTicker(refresh),
|
||||||
|
leaseLength: leaseLength,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *leaser) refresh() error {
|
||||||
|
doc, err := l.lc.Get(l.leaseid, l.leaseid)
|
||||||
|
if err != nil && !cosmosdb.IsErrorStatusCode(err, http.StatusNotFound) {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
validUntil := time.Now().Add(l.leaseLength)
|
||||||
|
|
||||||
|
if doc != nil && uuid.Equal(doc.Holder, l.uuid) {
|
||||||
|
_, err = l.lc.Replace(l.leaseid, doc)
|
||||||
|
switch {
|
||||||
|
case cosmosdb.IsErrorStatusCode(err, http.StatusNotFound):
|
||||||
|
doc = nil
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
l.validUntil = validUntil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if doc == nil {
|
||||||
|
_, err = l.lc.Create(l.leaseid, &api.LeaseDocument{
|
||||||
|
ID: l.leaseid,
|
||||||
|
TTL: int(l.leaseLength / time.Second),
|
||||||
|
Holder: l.uuid,
|
||||||
|
})
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case cosmosdb.IsErrorStatusCode(err, http.StatusConflict):
|
||||||
|
return nil
|
||||||
|
case err != nil:
|
||||||
|
return err
|
||||||
|
default:
|
||||||
|
l.validUntil = validUntil
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *leaser) HoldLease() bool {
|
||||||
|
oldHoldLease := l.holdLease
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-l.ticker.C:
|
||||||
|
err := l.refresh()
|
||||||
|
if err != nil {
|
||||||
|
l.log.Error(err)
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
|
||||||
|
l.holdLease = time.Now().Before(l.validUntil)
|
||||||
|
|
||||||
|
if oldHoldLease != l.holdLease {
|
||||||
|
if oldHoldLease {
|
||||||
|
l.log.Printf("lost %s lease", l.leaseid)
|
||||||
|
} else {
|
||||||
|
l.log.Printf("gained %s lease", l.leaseid)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return l.holdLease
|
||||||
|
}
|
|
@ -0,0 +1,143 @@
|
||||||
|
package queue
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Azure/azure-sdk-for-go/storage"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
messageVisibilityTimeout = 60 // seconds
|
||||||
|
messageHeartbeat = 10 * time.Second
|
||||||
|
)
|
||||||
|
|
||||||
|
type queue struct {
|
||||||
|
log *logrus.Entry
|
||||||
|
q *storage.Queue
|
||||||
|
}
|
||||||
|
|
||||||
|
// Queue represents a queue
|
||||||
|
type Queue interface {
|
||||||
|
Get() (Message, error)
|
||||||
|
Put(string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type message struct {
|
||||||
|
log *logrus.Entry
|
||||||
|
m *storage.Message
|
||||||
|
stop chan struct{}
|
||||||
|
done chan struct{}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Message represents a message
|
||||||
|
type Message interface {
|
||||||
|
ID() string
|
||||||
|
Done(error) error
|
||||||
|
DequeueCount() int
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewQueue returns a new queue
|
||||||
|
func NewQueue(log *logrus.Entry, storageAccount, storageKey, queueName string) (Queue, error) {
|
||||||
|
cli, err := storage.NewClient(storageAccount, storageKey, azure.PublicCloud.StorageEndpointSuffix, storage.DefaultAPIVersion, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
qsc := cli.GetQueueService()
|
||||||
|
|
||||||
|
q := qsc.GetQueueReference(queueName)
|
||||||
|
|
||||||
|
exists, err := q.Exists()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if !exists {
|
||||||
|
err = q.Create(nil) // can't do this via ARM template, unfortunately
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return &queue{log: log, q: q}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *queue) Get() (Message, error) {
|
||||||
|
ms, err := q.q.GetMessages(&storage.GetMessagesOptions{NumOfMessages: 1, VisibilityTimeout: messageVisibilityTimeout})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch {
|
||||||
|
case len(ms) > 1:
|
||||||
|
return nil, fmt.Errorf("read %d documents, expected <= 1", len(ms))
|
||||||
|
case len(ms) == 0:
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return q.newMessage(&ms[0]), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *queue) Put(id string) error {
|
||||||
|
m := &storage.Message{
|
||||||
|
Queue: q.q,
|
||||||
|
Text: id,
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.Put(&storage.PutMessageOptions{MessageTTL: -1})
|
||||||
|
}
|
||||||
|
|
||||||
|
func (q *queue) newMessage(sm *storage.Message) Message {
|
||||||
|
m := &message{
|
||||||
|
log: q.log,
|
||||||
|
m: sm,
|
||||||
|
stop: make(chan struct{}),
|
||||||
|
done: make(chan struct{}),
|
||||||
|
}
|
||||||
|
|
||||||
|
go m.heartbeat()
|
||||||
|
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *message) heartbeat() {
|
||||||
|
defer close(m.done)
|
||||||
|
|
||||||
|
t := time.NewTicker(messageHeartbeat)
|
||||||
|
defer t.Stop()
|
||||||
|
|
||||||
|
for {
|
||||||
|
err := m.m.Update(&storage.UpdateMessageOptions{VisibilityTimeout: messageVisibilityTimeout})
|
||||||
|
if err != nil {
|
||||||
|
m.log.Error(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-t.C:
|
||||||
|
case <-m.stop:
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *message) ID() string {
|
||||||
|
return m.m.Text
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *message) Done(err error) error {
|
||||||
|
close(m.stop)
|
||||||
|
<-m.done
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return m.m.Delete(nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *message) DequeueCount() int {
|
||||||
|
return m.m.DequeueCount
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package resource
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResourceName returns the resource name of a resource ID
|
||||||
|
func ResourceName(resourceID string) (string, error) {
|
||||||
|
r, err := azure.ParseResourceID(resourceID)
|
||||||
|
return r.ResourceName, err
|
||||||
|
}
|
||||||
|
|
||||||
|
// SubscriptionID returns the subscription ID of a resource ID
|
||||||
|
func SubscriptionID(resourceID string) (string, error) {
|
||||||
|
r, err := azure.ParseResourceID(resourceID)
|
||||||
|
return r.SubscriptionID, err
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
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.
|
12
vendor/cloud.google.com/go/compute/metadata/.repo-metadata.json
сгенерированный
поставляемый
Normal file
12
vendor/cloud.google.com/go/compute/metadata/.repo-metadata.json
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
{
|
||||||
|
"name": "metadata",
|
||||||
|
"name_pretty": "Google Compute Engine Metadata API",
|
||||||
|
"product_documentation": "https://cloud.google.com/compute/docs/storing-retrieving-metadata",
|
||||||
|
"client_documentation": "https://godoc.org/cloud.google.com/go/compute/metadata",
|
||||||
|
"release_level": "ga",
|
||||||
|
"language": "go",
|
||||||
|
"repo": "googleapis/google-cloud-go",
|
||||||
|
"distribution_name": "cloud.google.com/go/compute/metadata",
|
||||||
|
"api_id": "compute:metadata",
|
||||||
|
"requires_billing": false
|
||||||
|
}
|
526
vendor/cloud.google.com/go/compute/metadata/metadata.go
сгенерированный
поставляемый
Normal file
526
vendor/cloud.google.com/go/compute/metadata/metadata.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,526 @@
|
||||||
|
// Copyright 2014 Google LLC
|
||||||
|
//
|
||||||
|
// 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 metadata provides access to Google Compute Engine (GCE)
|
||||||
|
// metadata and API service accounts.
|
||||||
|
//
|
||||||
|
// This package is a wrapper around the GCE metadata service,
|
||||||
|
// as documented at https://developers.google.com/compute/docs/metadata.
|
||||||
|
package metadata // import "cloud.google.com/go/compute/metadata"
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"os"
|
||||||
|
"runtime"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
// metadataIP is the documented metadata server IP address.
|
||||||
|
metadataIP = "169.254.169.254"
|
||||||
|
|
||||||
|
// metadataHostEnv is the environment variable specifying the
|
||||||
|
// GCE metadata hostname. If empty, the default value of
|
||||||
|
// metadataIP ("169.254.169.254") is used instead.
|
||||||
|
// This is variable name is not defined by any spec, as far as
|
||||||
|
// I know; it was made up for the Go package.
|
||||||
|
metadataHostEnv = "GCE_METADATA_HOST"
|
||||||
|
|
||||||
|
userAgent = "gcloud-golang/0.1"
|
||||||
|
)
|
||||||
|
|
||||||
|
type cachedValue struct {
|
||||||
|
k string
|
||||||
|
trim bool
|
||||||
|
mu sync.Mutex
|
||||||
|
v string
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
projID = &cachedValue{k: "project/project-id", trim: true}
|
||||||
|
projNum = &cachedValue{k: "project/numeric-project-id", trim: true}
|
||||||
|
instID = &cachedValue{k: "instance/id", trim: true}
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
defaultClient = &Client{hc: &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 2 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
ResponseHeaderTimeout: 2 * time.Second,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
subscribeClient = &Client{hc: &http.Client{
|
||||||
|
Transport: &http.Transport{
|
||||||
|
Dial: (&net.Dialer{
|
||||||
|
Timeout: 2 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).Dial,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
)
|
||||||
|
|
||||||
|
// NotDefinedError is returned when requested metadata is not defined.
|
||||||
|
//
|
||||||
|
// The underlying string is the suffix after "/computeMetadata/v1/".
|
||||||
|
//
|
||||||
|
// This error is not returned if the value is defined to be the empty
|
||||||
|
// string.
|
||||||
|
type NotDefinedError string
|
||||||
|
|
||||||
|
func (suffix NotDefinedError) Error() string {
|
||||||
|
return fmt.Sprintf("metadata: GCE metadata %q not defined", string(suffix))
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *cachedValue) get(cl *Client) (v string, err error) {
|
||||||
|
defer c.mu.Unlock()
|
||||||
|
c.mu.Lock()
|
||||||
|
if c.v != "" {
|
||||||
|
return c.v, nil
|
||||||
|
}
|
||||||
|
if c.trim {
|
||||||
|
v, err = cl.getTrimmed(c.k)
|
||||||
|
} else {
|
||||||
|
v, err = cl.Get(c.k)
|
||||||
|
}
|
||||||
|
if err == nil {
|
||||||
|
c.v = v
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
onGCEOnce sync.Once
|
||||||
|
onGCE bool
|
||||||
|
)
|
||||||
|
|
||||||
|
// OnGCE reports whether this process is running on Google Compute Engine.
|
||||||
|
func OnGCE() bool {
|
||||||
|
onGCEOnce.Do(initOnGCE)
|
||||||
|
return onGCE
|
||||||
|
}
|
||||||
|
|
||||||
|
func initOnGCE() {
|
||||||
|
onGCE = testOnGCE()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testOnGCE() bool {
|
||||||
|
// The user explicitly said they're on GCE, so trust them.
|
||||||
|
if os.Getenv(metadataHostEnv) != "" {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
resc := make(chan bool, 2)
|
||||||
|
|
||||||
|
// Try two strategies in parallel.
|
||||||
|
// See https://github.com/googleapis/google-cloud-go/issues/194
|
||||||
|
go func() {
|
||||||
|
req, _ := http.NewRequest("GET", "http://"+metadataIP, nil)
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
res, err := defaultClient.hc.Do(req.WithContext(ctx))
|
||||||
|
if err != nil {
|
||||||
|
resc <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
resc <- res.Header.Get("Metadata-Flavor") == "Google"
|
||||||
|
}()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
addrs, err := net.LookupHost("metadata.google.internal")
|
||||||
|
if err != nil || len(addrs) == 0 {
|
||||||
|
resc <- false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resc <- strsContains(addrs, metadataIP)
|
||||||
|
}()
|
||||||
|
|
||||||
|
tryHarder := systemInfoSuggestsGCE()
|
||||||
|
if tryHarder {
|
||||||
|
res := <-resc
|
||||||
|
if res {
|
||||||
|
// The first strategy succeeded, so let's use it.
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
// Wait for either the DNS or metadata server probe to
|
||||||
|
// contradict the other one and say we are running on
|
||||||
|
// GCE. Give it a lot of time to do so, since the system
|
||||||
|
// info already suggests we're running on a GCE BIOS.
|
||||||
|
timer := time.NewTimer(5 * time.Second)
|
||||||
|
defer timer.Stop()
|
||||||
|
select {
|
||||||
|
case res = <-resc:
|
||||||
|
return res
|
||||||
|
case <-timer.C:
|
||||||
|
// Too slow. Who knows what this system is.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// There's no hint from the system info that we're running on
|
||||||
|
// GCE, so use the first probe's result as truth, whether it's
|
||||||
|
// true or false. The goal here is to optimize for speed for
|
||||||
|
// users who are NOT running on GCE. We can't assume that
|
||||||
|
// either a DNS lookup or an HTTP request to a blackholed IP
|
||||||
|
// address is fast. Worst case this should return when the
|
||||||
|
// metaClient's Transport.ResponseHeaderTimeout or
|
||||||
|
// Transport.Dial.Timeout fires (in two seconds).
|
||||||
|
return <-resc
|
||||||
|
}
|
||||||
|
|
||||||
|
// systemInfoSuggestsGCE reports whether the local system (without
|
||||||
|
// doing network requests) suggests that we're running on GCE. If this
|
||||||
|
// returns true, testOnGCE tries a bit harder to reach its metadata
|
||||||
|
// server.
|
||||||
|
func systemInfoSuggestsGCE() bool {
|
||||||
|
if runtime.GOOS != "linux" {
|
||||||
|
// We don't have any non-Linux clues available, at least yet.
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
slurp, _ := ioutil.ReadFile("/sys/class/dmi/id/product_name")
|
||||||
|
name := strings.TrimSpace(string(slurp))
|
||||||
|
return name == "Google" || name == "Google Compute Engine"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe calls Client.Subscribe on a client designed for subscribing (one with no
|
||||||
|
// ResponseHeaderTimeout).
|
||||||
|
func Subscribe(suffix string, fn func(v string, ok bool) error) error {
|
||||||
|
return subscribeClient.Subscribe(suffix, fn)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get calls Client.Get on the default client.
|
||||||
|
func Get(suffix string) (string, error) { return defaultClient.Get(suffix) }
|
||||||
|
|
||||||
|
// ProjectID returns the current instance's project ID string.
|
||||||
|
func ProjectID() (string, error) { return defaultClient.ProjectID() }
|
||||||
|
|
||||||
|
// NumericProjectID returns the current instance's numeric project ID.
|
||||||
|
func NumericProjectID() (string, error) { return defaultClient.NumericProjectID() }
|
||||||
|
|
||||||
|
// InternalIP returns the instance's primary internal IP address.
|
||||||
|
func InternalIP() (string, error) { return defaultClient.InternalIP() }
|
||||||
|
|
||||||
|
// ExternalIP returns the instance's primary external (public) IP address.
|
||||||
|
func ExternalIP() (string, error) { return defaultClient.ExternalIP() }
|
||||||
|
|
||||||
|
// Email calls Client.Email on the default client.
|
||||||
|
func Email(serviceAccount string) (string, error) { return defaultClient.Email(serviceAccount) }
|
||||||
|
|
||||||
|
// Hostname returns the instance's hostname. This will be of the form
|
||||||
|
// "<instanceID>.c.<projID>.internal".
|
||||||
|
func Hostname() (string, error) { return defaultClient.Hostname() }
|
||||||
|
|
||||||
|
// InstanceTags returns the list of user-defined instance tags,
|
||||||
|
// assigned when initially creating a GCE instance.
|
||||||
|
func InstanceTags() ([]string, error) { return defaultClient.InstanceTags() }
|
||||||
|
|
||||||
|
// InstanceID returns the current VM's numeric instance ID.
|
||||||
|
func InstanceID() (string, error) { return defaultClient.InstanceID() }
|
||||||
|
|
||||||
|
// InstanceName returns the current VM's instance ID string.
|
||||||
|
func InstanceName() (string, error) { return defaultClient.InstanceName() }
|
||||||
|
|
||||||
|
// Zone returns the current VM's zone, such as "us-central1-b".
|
||||||
|
func Zone() (string, error) { return defaultClient.Zone() }
|
||||||
|
|
||||||
|
// InstanceAttributes calls Client.InstanceAttributes on the default client.
|
||||||
|
func InstanceAttributes() ([]string, error) { return defaultClient.InstanceAttributes() }
|
||||||
|
|
||||||
|
// ProjectAttributes calls Client.ProjectAttributes on the default client.
|
||||||
|
func ProjectAttributes() ([]string, error) { return defaultClient.ProjectAttributes() }
|
||||||
|
|
||||||
|
// InstanceAttributeValue calls Client.InstanceAttributeValue on the default client.
|
||||||
|
func InstanceAttributeValue(attr string) (string, error) {
|
||||||
|
return defaultClient.InstanceAttributeValue(attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectAttributeValue calls Client.ProjectAttributeValue on the default client.
|
||||||
|
func ProjectAttributeValue(attr string) (string, error) {
|
||||||
|
return defaultClient.ProjectAttributeValue(attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scopes calls Client.Scopes on the default client.
|
||||||
|
func Scopes(serviceAccount string) ([]string, error) { return defaultClient.Scopes(serviceAccount) }
|
||||||
|
|
||||||
|
func strsContains(ss []string, s string) bool {
|
||||||
|
for _, v := range ss {
|
||||||
|
if v == s {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// A Client provides metadata.
|
||||||
|
type Client struct {
|
||||||
|
hc *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClient returns a Client that can be used to fetch metadata. All HTTP requests
|
||||||
|
// will use the given http.Client instead of the default client.
|
||||||
|
func NewClient(c *http.Client) *Client {
|
||||||
|
return &Client{hc: c}
|
||||||
|
}
|
||||||
|
|
||||||
|
// getETag returns a value from the metadata service as well as the associated ETag.
|
||||||
|
// This func is otherwise equivalent to Get.
|
||||||
|
func (c *Client) getETag(suffix string) (value, etag string, err error) {
|
||||||
|
// Using a fixed IP makes it very difficult to spoof the metadata service in
|
||||||
|
// a container, which is an important use-case for local testing of cloud
|
||||||
|
// deployments. To enable spoofing of the metadata service, the environment
|
||||||
|
// variable GCE_METADATA_HOST is first inspected to decide where metadata
|
||||||
|
// requests shall go.
|
||||||
|
host := os.Getenv(metadataHostEnv)
|
||||||
|
if host == "" {
|
||||||
|
// Using 169.254.169.254 instead of "metadata" here because Go
|
||||||
|
// binaries built with the "netgo" tag and without cgo won't
|
||||||
|
// know the search suffix for "metadata" is
|
||||||
|
// ".google.internal", and this IP address is documented as
|
||||||
|
// being stable anyway.
|
||||||
|
host = metadataIP
|
||||||
|
}
|
||||||
|
u := "http://" + host + "/computeMetadata/v1/" + suffix
|
||||||
|
req, _ := http.NewRequest("GET", u, nil)
|
||||||
|
req.Header.Set("Metadata-Flavor", "Google")
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
res, err := c.hc.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
if res.StatusCode == http.StatusNotFound {
|
||||||
|
return "", "", NotDefinedError(suffix)
|
||||||
|
}
|
||||||
|
all, err := ioutil.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
return "", "", err
|
||||||
|
}
|
||||||
|
if res.StatusCode != 200 {
|
||||||
|
return "", "", &Error{Code: res.StatusCode, Message: string(all)}
|
||||||
|
}
|
||||||
|
return string(all), res.Header.Get("Etag"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get returns a value from the metadata service.
|
||||||
|
// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
|
||||||
|
//
|
||||||
|
// If the GCE_METADATA_HOST environment variable is not defined, a default of
|
||||||
|
// 169.254.169.254 will be used instead.
|
||||||
|
//
|
||||||
|
// If the requested metadata is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
func (c *Client) Get(suffix string) (string, error) {
|
||||||
|
val, _, err := c.getETag(suffix)
|
||||||
|
return val, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) getTrimmed(suffix string) (s string, err error) {
|
||||||
|
s, err = c.Get(suffix)
|
||||||
|
s = strings.TrimSpace(s)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *Client) lines(suffix string) ([]string, error) {
|
||||||
|
j, err := c.Get(suffix)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
s := strings.Split(strings.TrimSpace(j), "\n")
|
||||||
|
for i := range s {
|
||||||
|
s[i] = strings.TrimSpace(s[i])
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectID returns the current instance's project ID string.
|
||||||
|
func (c *Client) ProjectID() (string, error) { return projID.get(c) }
|
||||||
|
|
||||||
|
// NumericProjectID returns the current instance's numeric project ID.
|
||||||
|
func (c *Client) NumericProjectID() (string, error) { return projNum.get(c) }
|
||||||
|
|
||||||
|
// InstanceID returns the current VM's numeric instance ID.
|
||||||
|
func (c *Client) InstanceID() (string, error) { return instID.get(c) }
|
||||||
|
|
||||||
|
// InternalIP returns the instance's primary internal IP address.
|
||||||
|
func (c *Client) InternalIP() (string, error) {
|
||||||
|
return c.getTrimmed("instance/network-interfaces/0/ip")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Email returns the email address associated with the service account.
|
||||||
|
// The account may be empty or the string "default" to use the instance's
|
||||||
|
// main account.
|
||||||
|
func (c *Client) Email(serviceAccount string) (string, error) {
|
||||||
|
if serviceAccount == "" {
|
||||||
|
serviceAccount = "default"
|
||||||
|
}
|
||||||
|
return c.getTrimmed("instance/service-accounts/" + serviceAccount + "/email")
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExternalIP returns the instance's primary external (public) IP address.
|
||||||
|
func (c *Client) ExternalIP() (string, error) {
|
||||||
|
return c.getTrimmed("instance/network-interfaces/0/access-configs/0/external-ip")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Hostname returns the instance's hostname. This will be of the form
|
||||||
|
// "<instanceID>.c.<projID>.internal".
|
||||||
|
func (c *Client) Hostname() (string, error) {
|
||||||
|
return c.getTrimmed("instance/hostname")
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceTags returns the list of user-defined instance tags,
|
||||||
|
// assigned when initially creating a GCE instance.
|
||||||
|
func (c *Client) InstanceTags() ([]string, error) {
|
||||||
|
var s []string
|
||||||
|
j, err := c.Get("instance/tags")
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if err := json.NewDecoder(strings.NewReader(j)).Decode(&s); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return s, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceName returns the current VM's instance ID string.
|
||||||
|
func (c *Client) InstanceName() (string, error) {
|
||||||
|
host, err := c.Hostname()
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return strings.Split(host, ".")[0], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// Zone returns the current VM's zone, such as "us-central1-b".
|
||||||
|
func (c *Client) Zone() (string, error) {
|
||||||
|
zone, err := c.getTrimmed("instance/zone")
|
||||||
|
// zone is of the form "projects/<projNum>/zones/<zoneName>".
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return zone[strings.LastIndex(zone, "/")+1:], nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// InstanceAttributes returns the list of user-defined attributes,
|
||||||
|
// assigned when initially creating a GCE VM instance. The value of an
|
||||||
|
// attribute can be obtained with InstanceAttributeValue.
|
||||||
|
func (c *Client) InstanceAttributes() ([]string, error) { return c.lines("instance/attributes/") }
|
||||||
|
|
||||||
|
// ProjectAttributes returns the list of user-defined attributes
|
||||||
|
// applying to the project as a whole, not just this VM. The value of
|
||||||
|
// an attribute can be obtained with ProjectAttributeValue.
|
||||||
|
func (c *Client) ProjectAttributes() ([]string, error) { return c.lines("project/attributes/") }
|
||||||
|
|
||||||
|
// InstanceAttributeValue returns the value of the provided VM
|
||||||
|
// instance attribute.
|
||||||
|
//
|
||||||
|
// If the requested attribute is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
//
|
||||||
|
// InstanceAttributeValue may return ("", nil) if the attribute was
|
||||||
|
// defined to be the empty string.
|
||||||
|
func (c *Client) InstanceAttributeValue(attr string) (string, error) {
|
||||||
|
return c.Get("instance/attributes/" + attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ProjectAttributeValue returns the value of the provided
|
||||||
|
// project attribute.
|
||||||
|
//
|
||||||
|
// If the requested attribute is not defined, the returned error will
|
||||||
|
// be of type NotDefinedError.
|
||||||
|
//
|
||||||
|
// ProjectAttributeValue may return ("", nil) if the attribute was
|
||||||
|
// defined to be the empty string.
|
||||||
|
func (c *Client) ProjectAttributeValue(attr string) (string, error) {
|
||||||
|
return c.Get("project/attributes/" + attr)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Scopes returns the service account scopes for the given account.
|
||||||
|
// The account may be empty or the string "default" to use the instance's
|
||||||
|
// main account.
|
||||||
|
func (c *Client) Scopes(serviceAccount string) ([]string, error) {
|
||||||
|
if serviceAccount == "" {
|
||||||
|
serviceAccount = "default"
|
||||||
|
}
|
||||||
|
return c.lines("instance/service-accounts/" + serviceAccount + "/scopes")
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subscribe subscribes to a value from the metadata service.
|
||||||
|
// The suffix is appended to "http://${GCE_METADATA_HOST}/computeMetadata/v1/".
|
||||||
|
// The suffix may contain query parameters.
|
||||||
|
//
|
||||||
|
// Subscribe calls fn with the latest metadata value indicated by the provided
|
||||||
|
// suffix. If the metadata value is deleted, fn is called with the empty string
|
||||||
|
// and ok false. Subscribe blocks until fn returns a non-nil error or the value
|
||||||
|
// is deleted. Subscribe returns the error value returned from the last call to
|
||||||
|
// fn, which may be nil when ok == false.
|
||||||
|
func (c *Client) Subscribe(suffix string, fn func(v string, ok bool) error) error {
|
||||||
|
const failedSubscribeSleep = time.Second * 5
|
||||||
|
|
||||||
|
// First check to see if the metadata value exists at all.
|
||||||
|
val, lastETag, err := c.getETag(suffix)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := fn(val, true); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
ok := true
|
||||||
|
if strings.ContainsRune(suffix, '?') {
|
||||||
|
suffix += "&wait_for_change=true&last_etag="
|
||||||
|
} else {
|
||||||
|
suffix += "?wait_for_change=true&last_etag="
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
val, etag, err := c.getETag(suffix + url.QueryEscape(lastETag))
|
||||||
|
if err != nil {
|
||||||
|
if _, deleted := err.(NotDefinedError); !deleted {
|
||||||
|
time.Sleep(failedSubscribeSleep)
|
||||||
|
continue // Retry on other errors.
|
||||||
|
}
|
||||||
|
ok = false
|
||||||
|
}
|
||||||
|
lastETag = etag
|
||||||
|
|
||||||
|
if err := fn(val, ok); err != nil || !ok {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Error contains an error response from the server.
|
||||||
|
type Error struct {
|
||||||
|
// Code is the HTTP response status code.
|
||||||
|
Code int
|
||||||
|
// Message is the server response message.
|
||||||
|
Message string
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Error) Error() string {
|
||||||
|
return fmt.Sprintf("compute: Received %d `%s`", e.Code, e.Message)
|
||||||
|
}
|
|
@ -0,0 +1,202 @@
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright 2016 Microsoft Corporation
|
||||||
|
|
||||||
|
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.
|
|
@ -0,0 +1,5 @@
|
||||||
|
Microsoft Azure-SDK-for-Go
|
||||||
|
Copyright 2014-2017 Microsoft
|
||||||
|
|
||||||
|
This product includes software developed at
|
||||||
|
the Microsoft Corporation (https://www.microsoft.com).
|
138
vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/dns/mgmt/dns/models.go
сгенерированный
поставляемый
Normal file
138
vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/dns/mgmt/dns/models.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
// +build go1.9
|
||||||
|
|
||||||
|
// Copyright 2019 Microsoft Corporation
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// This code was auto-generated by:
|
||||||
|
// github.com/Azure/azure-sdk-for-go/tools/profileBuilder
|
||||||
|
|
||||||
|
package dns
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
original "github.com/Azure/azure-sdk-for-go/services/dns/mgmt/2018-05-01/dns"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultBaseURI = original.DefaultBaseURI
|
||||||
|
)
|
||||||
|
|
||||||
|
type RecordType = original.RecordType
|
||||||
|
|
||||||
|
const (
|
||||||
|
A RecordType = original.A
|
||||||
|
AAAA RecordType = original.AAAA
|
||||||
|
CAA RecordType = original.CAA
|
||||||
|
CNAME RecordType = original.CNAME
|
||||||
|
MX RecordType = original.MX
|
||||||
|
NS RecordType = original.NS
|
||||||
|
PTR RecordType = original.PTR
|
||||||
|
SOA RecordType = original.SOA
|
||||||
|
SRV RecordType = original.SRV
|
||||||
|
TXT RecordType = original.TXT
|
||||||
|
)
|
||||||
|
|
||||||
|
type ZoneType = original.ZoneType
|
||||||
|
|
||||||
|
const (
|
||||||
|
Private ZoneType = original.Private
|
||||||
|
Public ZoneType = original.Public
|
||||||
|
)
|
||||||
|
|
||||||
|
type ARecord = original.ARecord
|
||||||
|
type AaaaRecord = original.AaaaRecord
|
||||||
|
type BaseClient = original.BaseClient
|
||||||
|
type CaaRecord = original.CaaRecord
|
||||||
|
type CloudError = original.CloudError
|
||||||
|
type CloudErrorBody = original.CloudErrorBody
|
||||||
|
type CnameRecord = original.CnameRecord
|
||||||
|
type MxRecord = original.MxRecord
|
||||||
|
type NsRecord = original.NsRecord
|
||||||
|
type PtrRecord = original.PtrRecord
|
||||||
|
type RecordSet = original.RecordSet
|
||||||
|
type RecordSetListResult = original.RecordSetListResult
|
||||||
|
type RecordSetListResultIterator = original.RecordSetListResultIterator
|
||||||
|
type RecordSetListResultPage = original.RecordSetListResultPage
|
||||||
|
type RecordSetProperties = original.RecordSetProperties
|
||||||
|
type RecordSetUpdateParameters = original.RecordSetUpdateParameters
|
||||||
|
type RecordSetsClient = original.RecordSetsClient
|
||||||
|
type Resource = original.Resource
|
||||||
|
type ResourceReference = original.ResourceReference
|
||||||
|
type ResourceReferenceClient = original.ResourceReferenceClient
|
||||||
|
type ResourceReferenceRequest = original.ResourceReferenceRequest
|
||||||
|
type ResourceReferenceRequestProperties = original.ResourceReferenceRequestProperties
|
||||||
|
type ResourceReferenceResult = original.ResourceReferenceResult
|
||||||
|
type ResourceReferenceResultProperties = original.ResourceReferenceResultProperties
|
||||||
|
type SoaRecord = original.SoaRecord
|
||||||
|
type SrvRecord = original.SrvRecord
|
||||||
|
type SubResource = original.SubResource
|
||||||
|
type TxtRecord = original.TxtRecord
|
||||||
|
type Zone = original.Zone
|
||||||
|
type ZoneListResult = original.ZoneListResult
|
||||||
|
type ZoneListResultIterator = original.ZoneListResultIterator
|
||||||
|
type ZoneListResultPage = original.ZoneListResultPage
|
||||||
|
type ZoneProperties = original.ZoneProperties
|
||||||
|
type ZoneUpdate = original.ZoneUpdate
|
||||||
|
type ZonesClient = original.ZonesClient
|
||||||
|
type ZonesDeleteFuture = original.ZonesDeleteFuture
|
||||||
|
|
||||||
|
func New(subscriptionID string) BaseClient {
|
||||||
|
return original.New(subscriptionID)
|
||||||
|
}
|
||||||
|
func NewRecordSetListResultIterator(page RecordSetListResultPage) RecordSetListResultIterator {
|
||||||
|
return original.NewRecordSetListResultIterator(page)
|
||||||
|
}
|
||||||
|
func NewRecordSetListResultPage(getNextPage func(context.Context, RecordSetListResult) (RecordSetListResult, error)) RecordSetListResultPage {
|
||||||
|
return original.NewRecordSetListResultPage(getNextPage)
|
||||||
|
}
|
||||||
|
func NewRecordSetsClient(subscriptionID string) RecordSetsClient {
|
||||||
|
return original.NewRecordSetsClient(subscriptionID)
|
||||||
|
}
|
||||||
|
func NewRecordSetsClientWithBaseURI(baseURI string, subscriptionID string) RecordSetsClient {
|
||||||
|
return original.NewRecordSetsClientWithBaseURI(baseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
func NewResourceReferenceClient(subscriptionID string) ResourceReferenceClient {
|
||||||
|
return original.NewResourceReferenceClient(subscriptionID)
|
||||||
|
}
|
||||||
|
func NewResourceReferenceClientWithBaseURI(baseURI string, subscriptionID string) ResourceReferenceClient {
|
||||||
|
return original.NewResourceReferenceClientWithBaseURI(baseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient {
|
||||||
|
return original.NewWithBaseURI(baseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
func NewZoneListResultIterator(page ZoneListResultPage) ZoneListResultIterator {
|
||||||
|
return original.NewZoneListResultIterator(page)
|
||||||
|
}
|
||||||
|
func NewZoneListResultPage(getNextPage func(context.Context, ZoneListResult) (ZoneListResult, error)) ZoneListResultPage {
|
||||||
|
return original.NewZoneListResultPage(getNextPage)
|
||||||
|
}
|
||||||
|
func NewZonesClient(subscriptionID string) ZonesClient {
|
||||||
|
return original.NewZonesClient(subscriptionID)
|
||||||
|
}
|
||||||
|
func NewZonesClientWithBaseURI(baseURI string, subscriptionID string) ZonesClient {
|
||||||
|
return original.NewZonesClientWithBaseURI(baseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
func PossibleRecordTypeValues() []RecordType {
|
||||||
|
return original.PossibleRecordTypeValues()
|
||||||
|
}
|
||||||
|
func PossibleZoneTypeValues() []ZoneType {
|
||||||
|
return original.PossibleZoneTypeValues()
|
||||||
|
}
|
||||||
|
func UserAgent() string {
|
||||||
|
return original.UserAgent() + " profiles/latest"
|
||||||
|
}
|
||||||
|
func Version() string {
|
||||||
|
return original.Version()
|
||||||
|
}
|
124
vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/subscriptions/models.go
сгенерированный
поставляемый
Normal file
124
vendor/github.com/Azure/azure-sdk-for-go/profiles/latest/resources/mgmt/subscriptions/models.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
// +build go1.9
|
||||||
|
|
||||||
|
// Copyright 2019 Microsoft Corporation
|
||||||
|
//
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// This code was auto-generated by:
|
||||||
|
// github.com/Azure/azure-sdk-for-go/tools/profileBuilder
|
||||||
|
|
||||||
|
package subscriptions
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
|
||||||
|
original "github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2018-06-01/subscriptions"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
DefaultBaseURI = original.DefaultBaseURI
|
||||||
|
)
|
||||||
|
|
||||||
|
type SpendingLimit = original.SpendingLimit
|
||||||
|
|
||||||
|
const (
|
||||||
|
CurrentPeriodOff SpendingLimit = original.CurrentPeriodOff
|
||||||
|
Off SpendingLimit = original.Off
|
||||||
|
On SpendingLimit = original.On
|
||||||
|
)
|
||||||
|
|
||||||
|
type State = original.State
|
||||||
|
|
||||||
|
const (
|
||||||
|
Deleted State = original.Deleted
|
||||||
|
Disabled State = original.Disabled
|
||||||
|
Enabled State = original.Enabled
|
||||||
|
PastDue State = original.PastDue
|
||||||
|
Warned State = original.Warned
|
||||||
|
)
|
||||||
|
|
||||||
|
type BaseClient = original.BaseClient
|
||||||
|
type Client = original.Client
|
||||||
|
type ListResult = original.ListResult
|
||||||
|
type ListResultIterator = original.ListResultIterator
|
||||||
|
type ListResultPage = original.ListResultPage
|
||||||
|
type Location = original.Location
|
||||||
|
type LocationListResult = original.LocationListResult
|
||||||
|
type Operation = original.Operation
|
||||||
|
type OperationDisplay = original.OperationDisplay
|
||||||
|
type OperationListResult = original.OperationListResult
|
||||||
|
type OperationListResultIterator = original.OperationListResultIterator
|
||||||
|
type OperationListResultPage = original.OperationListResultPage
|
||||||
|
type OperationsClient = original.OperationsClient
|
||||||
|
type Policies = original.Policies
|
||||||
|
type Subscription = original.Subscription
|
||||||
|
type TenantIDDescription = original.TenantIDDescription
|
||||||
|
type TenantListResult = original.TenantListResult
|
||||||
|
type TenantListResultIterator = original.TenantListResultIterator
|
||||||
|
type TenantListResultPage = original.TenantListResultPage
|
||||||
|
type TenantsClient = original.TenantsClient
|
||||||
|
|
||||||
|
func New() BaseClient {
|
||||||
|
return original.New()
|
||||||
|
}
|
||||||
|
func NewClient() Client {
|
||||||
|
return original.NewClient()
|
||||||
|
}
|
||||||
|
func NewClientWithBaseURI(baseURI string) Client {
|
||||||
|
return original.NewClientWithBaseURI(baseURI)
|
||||||
|
}
|
||||||
|
func NewListResultIterator(page ListResultPage) ListResultIterator {
|
||||||
|
return original.NewListResultIterator(page)
|
||||||
|
}
|
||||||
|
func NewListResultPage(getNextPage func(context.Context, ListResult) (ListResult, error)) ListResultPage {
|
||||||
|
return original.NewListResultPage(getNextPage)
|
||||||
|
}
|
||||||
|
func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator {
|
||||||
|
return original.NewOperationListResultIterator(page)
|
||||||
|
}
|
||||||
|
func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage {
|
||||||
|
return original.NewOperationListResultPage(getNextPage)
|
||||||
|
}
|
||||||
|
func NewOperationsClient() OperationsClient {
|
||||||
|
return original.NewOperationsClient()
|
||||||
|
}
|
||||||
|
func NewOperationsClientWithBaseURI(baseURI string) OperationsClient {
|
||||||
|
return original.NewOperationsClientWithBaseURI(baseURI)
|
||||||
|
}
|
||||||
|
func NewTenantListResultIterator(page TenantListResultPage) TenantListResultIterator {
|
||||||
|
return original.NewTenantListResultIterator(page)
|
||||||
|
}
|
||||||
|
func NewTenantListResultPage(getNextPage func(context.Context, TenantListResult) (TenantListResult, error)) TenantListResultPage {
|
||||||
|
return original.NewTenantListResultPage(getNextPage)
|
||||||
|
}
|
||||||
|
func NewTenantsClient() TenantsClient {
|
||||||
|
return original.NewTenantsClient()
|
||||||
|
}
|
||||||
|
func NewTenantsClientWithBaseURI(baseURI string) TenantsClient {
|
||||||
|
return original.NewTenantsClientWithBaseURI(baseURI)
|
||||||
|
}
|
||||||
|
func NewWithBaseURI(baseURI string) BaseClient {
|
||||||
|
return original.NewWithBaseURI(baseURI)
|
||||||
|
}
|
||||||
|
func PossibleSpendingLimitValues() []SpendingLimit {
|
||||||
|
return original.PossibleSpendingLimitValues()
|
||||||
|
}
|
||||||
|
func PossibleStateValues() []State {
|
||||||
|
return original.PossibleStateValues()
|
||||||
|
}
|
||||||
|
func UserAgent() string {
|
||||||
|
return original.UserAgent() + " profiles/latest"
|
||||||
|
}
|
||||||
|
func Version() string {
|
||||||
|
return original.Version()
|
||||||
|
}
|
154
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go
сгенерированный
поставляемый
Normal file
154
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/classicadministrators.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,154 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ClassicAdministratorsClient is the role based access control provides you a way to apply granular level policy
|
||||||
|
// administration down to individual resources or resource groups. These operations enable you to manage role
|
||||||
|
// definitions and role assignments. A role definition describes the set of actions that can be performed on resources.
|
||||||
|
// A role assignment grants access to Azure Active Directory users.
|
||||||
|
type ClassicAdministratorsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClassicAdministratorsClient creates an instance of the ClassicAdministratorsClient client.
|
||||||
|
func NewClassicAdministratorsClient(subscriptionID string) ClassicAdministratorsClient {
|
||||||
|
return NewClassicAdministratorsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewClassicAdministratorsClientWithBaseURI creates an instance of the ClassicAdministratorsClient client.
|
||||||
|
func NewClassicAdministratorsClientWithBaseURI(baseURI string, subscriptionID string) ClassicAdministratorsClient {
|
||||||
|
return ClassicAdministratorsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets service administrator, account administrator, and co-administrators for the subscription.
|
||||||
|
func (client ClassicAdministratorsClient) List(ctx context.Context) (result ClassicAdministratorListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.calr.Response.Response != nil {
|
||||||
|
sc = result.calr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.calr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.calr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ClassicAdministratorsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/classicAdministrators", 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 ClassicAdministratorsClient) 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 ClassicAdministratorsClient) ListResponder(resp *http.Response) (result ClassicAdministratorListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ClassicAdministratorsClient) listNextResults(ctx context.Context, lastResults ClassicAdministratorListResult) (result ClassicAdministratorListResult, err error) {
|
||||||
|
req, err := lastResults.classicAdministratorListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ClassicAdministratorsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ClassicAdministratorsClient) ListComplete(ctx context.Context) (result ClassicAdministratorListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ClassicAdministratorsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
54
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/client.go
сгенерированный
поставляемый
Normal file
54
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/client.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
// Package authorization implements the Azure ARM Authorization service API version 2015-07-01.
|
||||||
|
//
|
||||||
|
// Role based access control provides you a way to apply granular level policy administration down to individual
|
||||||
|
// resources or resource groups. These operations enable you to manage role definitions and role assignments. A role
|
||||||
|
// definition describes the set of actions that can be performed on resources. A role assignment grants access to Azure
|
||||||
|
// Active Directory users.
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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 Authorization
|
||||||
|
DefaultBaseURI = "https://management.azure.com"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaseClient is the base client for Authorization.
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
111
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/globaladministrator.go
сгенерированный
поставляемый
Normal file
111
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/globaladministrator.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GlobalAdministratorClient is the role based access control provides you a way to apply granular level policy
|
||||||
|
// administration down to individual resources or resource groups. These operations enable you to manage role
|
||||||
|
// definitions and role assignments. A role definition describes the set of actions that can be performed on resources.
|
||||||
|
// A role assignment grants access to Azure Active Directory users.
|
||||||
|
type GlobalAdministratorClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGlobalAdministratorClient creates an instance of the GlobalAdministratorClient client.
|
||||||
|
func NewGlobalAdministratorClient(subscriptionID string) GlobalAdministratorClient {
|
||||||
|
return NewGlobalAdministratorClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGlobalAdministratorClientWithBaseURI creates an instance of the GlobalAdministratorClient client.
|
||||||
|
func NewGlobalAdministratorClientWithBaseURI(baseURI string, subscriptionID string) GlobalAdministratorClient {
|
||||||
|
return GlobalAdministratorClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElevateAccess elevates access for a Global Administrator.
|
||||||
|
func (client GlobalAdministratorClient) ElevateAccess(ctx context.Context) (result autorest.Response, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GlobalAdministratorClient.ElevateAccess")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response != nil {
|
||||||
|
sc = result.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ElevateAccessPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ElevateAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ElevateAccessResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.GlobalAdministratorClient", "ElevateAccess", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElevateAccessPreparer prepares the ElevateAccess request.
|
||||||
|
func (client GlobalAdministratorClient) ElevateAccessPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPath("/providers/Microsoft.Authorization/elevateAccess"),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElevateAccessSender sends the ElevateAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GlobalAdministratorClient) ElevateAccessSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ElevateAccessResponder handles the response to the ElevateAccess request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GlobalAdministratorClient) ElevateAccessResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
1036
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/models.go
сгенерированный
поставляемый
Normal file
1036
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/models.go
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
278
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/permissions.go
сгенерированный
поставляемый
Normal file
278
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/permissions.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,278 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PermissionsClient is the role based access control provides you a way to apply granular level policy administration
|
||||||
|
// down to individual resources or resource groups. These operations enable you to manage role definitions and role
|
||||||
|
// assignments. A role definition describes the set of actions that can be performed on resources. A role assignment
|
||||||
|
// grants access to Azure Active Directory users.
|
||||||
|
type PermissionsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPermissionsClient creates an instance of the PermissionsClient client.
|
||||||
|
func NewPermissionsClient(subscriptionID string) PermissionsClient {
|
||||||
|
return NewPermissionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewPermissionsClientWithBaseURI creates an instance of the PermissionsClient client.
|
||||||
|
func NewPermissionsClientWithBaseURI(baseURI string, subscriptionID string) PermissionsClient {
|
||||||
|
return PermissionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResource gets all permissions the caller has for a resource.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group containing the resource. The name is case insensitive.
|
||||||
|
// resourceProviderNamespace - the namespace of the resource provider.
|
||||||
|
// parentResourcePath - the parent resource identity.
|
||||||
|
// resourceType - the resource type of the resource.
|
||||||
|
// resourceName - the name of the resource to get the permissions for.
|
||||||
|
func (client PermissionsClient) ListForResource(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.pgr.Response.Response != nil {
|
||||||
|
sc = result.pgr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listForResourceNextResults
|
||||||
|
req, err := client.ListForResourcePreparer(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListForResourceSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.pgr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.pgr, err = client.ListForResourceResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResource", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourcePreparer prepares the ListForResource request.
|
||||||
|
func (client PermissionsClient) ListForResourcePreparer(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"parentResourcePath": parentResourcePath,
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"resourceName": autorest.Encode("path", resourceName),
|
||||||
|
"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
|
||||||
|
"resourceType": resourceType,
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{parentResourcePath}/{resourceType}/{resourceName}/providers/Microsoft.Authorization/permissions", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceSender sends the ListForResource request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client PermissionsClient) ListForResourceSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceResponder handles the response to the ListForResource request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client PermissionsClient) ListForResourceResponder(resp *http.Response) (result PermissionGetResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listForResourceNextResults retrieves the next set of results, if any.
|
||||||
|
func (client PermissionsClient) listForResourceNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) {
|
||||||
|
req, err := lastResults.permissionGetResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListForResourceSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListForResourceResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client PermissionsClient) ListForResourceComplete(ctx context.Context, resourceGroupName string, resourceProviderNamespace string, parentResourcePath string, resourceType string, resourceName string) (result PermissionGetResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResource")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListForResource(ctx, resourceGroupName, resourceProviderNamespace, parentResourcePath, resourceType, resourceName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceGroup gets all permissions the caller has for a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group to get the permissions for. The name is case insensitive.
|
||||||
|
func (client PermissionsClient) ListForResourceGroup(ctx context.Context, resourceGroupName string) (result PermissionGetResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.pgr.Response.Response != nil {
|
||||||
|
sc = result.pgr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listForResourceGroupNextResults
|
||||||
|
req, err := client.ListForResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListForResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.pgr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.pgr, err = client.ListForResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "ListForResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceGroupPreparer prepares the ListForResourceGroup request.
|
||||||
|
func (client PermissionsClient) ListForResourceGroupPreparer(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 = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Authorization/permissions", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceGroupSender sends the ListForResourceGroup request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client PermissionsClient) ListForResourceGroupSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceGroupResponder handles the response to the ListForResourceGroup request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client PermissionsClient) ListForResourceGroupResponder(resp *http.Response) (result PermissionGetResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listForResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client PermissionsClient) listForResourceGroupNextResults(ctx context.Context, lastResults PermissionGetResult) (result PermissionGetResult, err error) {
|
||||||
|
req, err := lastResults.permissionGetResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListForResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListForResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.PermissionsClient", "listForResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListForResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client PermissionsClient) ListForResourceGroupComplete(ctx context.Context, resourceGroupName string) (result PermissionGetResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/PermissionsClient.ListForResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListForResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
237
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go
сгенерированный
поставляемый
Normal file
237
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/provideroperationsmetadata.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,237 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProviderOperationsMetadataClient is the role based access control provides you a way to apply granular level policy
|
||||||
|
// administration down to individual resources or resource groups. These operations enable you to manage role
|
||||||
|
// definitions and role assignments. A role definition describes the set of actions that can be performed on resources.
|
||||||
|
// A role assignment grants access to Azure Active Directory users.
|
||||||
|
type ProviderOperationsMetadataClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProviderOperationsMetadataClient creates an instance of the ProviderOperationsMetadataClient client.
|
||||||
|
func NewProviderOperationsMetadataClient(subscriptionID string) ProviderOperationsMetadataClient {
|
||||||
|
return NewProviderOperationsMetadataClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProviderOperationsMetadataClientWithBaseURI creates an instance of the ProviderOperationsMetadataClient client.
|
||||||
|
func NewProviderOperationsMetadataClientWithBaseURI(baseURI string, subscriptionID string) ProviderOperationsMetadataClient {
|
||||||
|
return ProviderOperationsMetadataClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets provider operations metadata for the specified resource provider.
|
||||||
|
// Parameters:
|
||||||
|
// resourceProviderNamespace - the namespace of the resource provider.
|
||||||
|
// expand - specifies whether to expand the values.
|
||||||
|
func (client ProviderOperationsMetadataClient) Get(ctx context.Context, resourceProviderNamespace string, expand string) (result ProviderOperationsMetadata, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.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, resourceProviderNamespace, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ProviderOperationsMetadataClient) GetPreparer(ctx context.Context, resourceProviderNamespace string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceProviderNamespace": autorest.Encode("path", resourceProviderNamespace),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
} else {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", "resourceTypes")
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/providers/Microsoft.Authorization/providerOperations/{resourceProviderNamespace}", 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 ProviderOperationsMetadataClient) GetSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetResponder handles the response to the Get request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ProviderOperationsMetadataClient) GetResponder(resp *http.Response) (result ProviderOperationsMetadata, 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 gets provider operations metadata for all resource providers.
|
||||||
|
// Parameters:
|
||||||
|
// expand - specifies whether to expand the values.
|
||||||
|
func (client ProviderOperationsMetadataClient) List(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.pomlr.Response.Response != nil {
|
||||||
|
sc = result.pomlr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.pomlr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.pomlr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ProviderOperationsMetadataClient) ListPreparer(ctx context.Context, expand string) (*http.Request, error) {
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
} else {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", "resourceTypes")
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPath("/providers/Microsoft.Authorization/providerOperations"),
|
||||||
|
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 ProviderOperationsMetadataClient) 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 ProviderOperationsMetadataClient) ListResponder(resp *http.Response) (result ProviderOperationsMetadataListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ProviderOperationsMetadataClient) listNextResults(ctx context.Context, lastResults ProviderOperationsMetadataListResult) (result ProviderOperationsMetadataListResult, err error) {
|
||||||
|
req, err := lastResults.providerOperationsMetadataListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.ProviderOperationsMetadataClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ProviderOperationsMetadataClient) ListComplete(ctx context.Context, expand string) (result ProviderOperationsMetadataListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProviderOperationsMetadataClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, expand)
|
||||||
|
return
|
||||||
|
}
|
1013
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go
сгенерированный
поставляемый
Normal file
1013
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/roleassignments.go
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
472
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go
сгенерированный
поставляемый
Normal file
472
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/roledefinitions.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,472 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// RoleDefinitionsClient is the role based access control provides you a way to apply granular level policy
|
||||||
|
// administration down to individual resources or resource groups. These operations enable you to manage role
|
||||||
|
// definitions and role assignments. A role definition describes the set of actions that can be performed on resources.
|
||||||
|
// A role assignment grants access to Azure Active Directory users.
|
||||||
|
type RoleDefinitionsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRoleDefinitionsClient creates an instance of the RoleDefinitionsClient client.
|
||||||
|
func NewRoleDefinitionsClient(subscriptionID string) RoleDefinitionsClient {
|
||||||
|
return NewRoleDefinitionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewRoleDefinitionsClientWithBaseURI creates an instance of the RoleDefinitionsClient client.
|
||||||
|
func NewRoleDefinitionsClientWithBaseURI(baseURI string, subscriptionID string) RoleDefinitionsClient {
|
||||||
|
return RoleDefinitionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a role definition.
|
||||||
|
// Parameters:
|
||||||
|
// scope - the scope of the role definition.
|
||||||
|
// roleDefinitionID - the ID of the role definition.
|
||||||
|
// roleDefinition - the values for the role definition.
|
||||||
|
func (client RoleDefinitionsClient) CreateOrUpdate(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (result RoleDefinition, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, scope, roleDefinitionID, roleDefinition)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client RoleDefinitionsClient) CreateOrUpdatePreparer(ctx context.Context, scope string, roleDefinitionID string, roleDefinition RoleDefinition) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"roleDefinitionId": autorest.Encode("path", roleDefinitionID),
|
||||||
|
"scope": scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
roleDefinition.ID = nil
|
||||||
|
roleDefinition.Name = nil
|
||||||
|
roleDefinition.Type = nil
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", pathParameters),
|
||||||
|
autorest.WithJSON(roleDefinition),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client RoleDefinitionsClient) CreateOrUpdateSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client RoleDefinitionsClient) CreateOrUpdateResponder(resp *http.Response) (result RoleDefinition, 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 role definition.
|
||||||
|
// Parameters:
|
||||||
|
// scope - the scope of the role definition.
|
||||||
|
// roleDefinitionID - the ID of the role definition to delete.
|
||||||
|
func (client RoleDefinitionsClient) Delete(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, scope, roleDefinitionID)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client RoleDefinitionsClient) DeletePreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"roleDefinitionId": autorest.Encode("path", roleDefinitionID),
|
||||||
|
"scope": scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", 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 RoleDefinitionsClient) DeleteSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client RoleDefinitionsClient) DeleteResponder(resp *http.Response) (result RoleDefinition, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get get role definition by name (GUID).
|
||||||
|
// Parameters:
|
||||||
|
// scope - the scope of the role definition.
|
||||||
|
// roleDefinitionID - the ID of the role definition.
|
||||||
|
func (client RoleDefinitionsClient) Get(ctx context.Context, scope string, roleDefinitionID string) (result RoleDefinition, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.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, scope, roleDefinitionID)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client RoleDefinitionsClient) GetPreparer(ctx context.Context, scope string, roleDefinitionID string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"roleDefinitionId": autorest.Encode("path", roleDefinitionID),
|
||||||
|
"scope": scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId}", 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 RoleDefinitionsClient) GetSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetResponder handles the response to the Get request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client RoleDefinitionsClient) GetResponder(resp *http.Response) (result RoleDefinition, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByID gets a role definition by ID.
|
||||||
|
// Parameters:
|
||||||
|
// roleDefinitionID - the fully qualified role definition ID. Use the format,
|
||||||
|
// /subscriptions/{guid}/providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for subscription
|
||||||
|
// level role definitions, or /providers/Microsoft.Authorization/roleDefinitions/{roleDefinitionId} for tenant
|
||||||
|
// level role definitions.
|
||||||
|
func (client RoleDefinitionsClient) GetByID(ctx context.Context, roleDefinitionID string) (result RoleDefinition, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.GetByID")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.GetByIDPreparer(ctx, roleDefinitionID)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetByIDSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetByIDResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "GetByID", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByIDPreparer prepares the GetByID request.
|
||||||
|
func (client RoleDefinitionsClient) GetByIDPreparer(ctx context.Context, roleDefinitionID string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"roleDefinitionId": roleDefinitionID,
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/{roleDefinitionId}", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByIDSender sends the GetByID request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client RoleDefinitionsClient) GetByIDSender(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...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetByIDResponder handles the response to the GetByID request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client RoleDefinitionsClient) GetByIDResponder(resp *http.Response) (result RoleDefinition, 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 get all role definitions that are applicable at scope and above.
|
||||||
|
// Parameters:
|
||||||
|
// scope - the scope of the role definition.
|
||||||
|
// filter - the filter to apply on the operation. Use atScopeAndBelow filter to search below the given scope as
|
||||||
|
// well.
|
||||||
|
func (client RoleDefinitionsClient) List(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.rdlr.Response.Response != nil {
|
||||||
|
sc = result.rdlr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, scope, filter)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.rdlr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.rdlr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client RoleDefinitionsClient) ListPreparer(ctx context.Context, scope string, filter string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"scope": scope,
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2015-07-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(filter) > 0 {
|
||||||
|
queryParameters["$filter"] = autorest.Encode("query", filter)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/{scope}/providers/Microsoft.Authorization/roleDefinitions", 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 RoleDefinitionsClient) 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 RoleDefinitionsClient) ListResponder(resp *http.Response) (result RoleDefinitionListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client RoleDefinitionsClient) listNextResults(ctx context.Context, lastResults RoleDefinitionListResult) (result RoleDefinitionListResult, err error) {
|
||||||
|
req, err := lastResults.roleDefinitionListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "authorization.RoleDefinitionsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client RoleDefinitionsClient) ListComplete(ctx context.Context, scope string, filter string) (result RoleDefinitionListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/RoleDefinitionsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, scope, filter)
|
||||||
|
return
|
||||||
|
}
|
30
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/version.go
сгенерированный
поставляемый
Normal file
30
vendor/github.com/Azure/azure-sdk-for-go/services/authorization/mgmt/2015-07-01/authorization/version.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package authorization
|
||||||
|
|
||||||
|
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 + " authorization/2015-07-01"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version returns the semantic version (see http://semver.org) of the client.
|
||||||
|
func Version() string {
|
||||||
|
return version.Number
|
||||||
|
}
|
655
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/availabilitysets.go
сгенерированный
поставляемый
Normal file
655
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/availabilitysets.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,655 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AvailabilitySetsClient is the compute Client
|
||||||
|
type AvailabilitySetsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAvailabilitySetsClient creates an instance of the AvailabilitySetsClient client.
|
||||||
|
func NewAvailabilitySetsClient(subscriptionID string) AvailabilitySetsClient {
|
||||||
|
return NewAvailabilitySetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAvailabilitySetsClientWithBaseURI creates an instance of the AvailabilitySetsClient client.
|
||||||
|
func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) AvailabilitySetsClient {
|
||||||
|
return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
// parameters - parameters supplied to the Create Availability Set operation.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) Delete(ctx context.Context, resourceGroupName string, availabilitySetName string) (result autorest.Response, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response != nil {
|
||||||
|
sc = result.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client AvailabilitySetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) 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 retrieves information about an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.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, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client AvailabilitySetsClient) GetPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) 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 AvailabilitySetsClient) GetResponder(resp *http.Response) (result AvailabilitySet, 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 all availability sets in a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client AvailabilitySetsClient) List(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.aslr.Response.Response != nil {
|
||||||
|
sc = result.aslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.aslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.aslr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client AvailabilitySetsClient) ListPreparer(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 = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", 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 AvailabilitySetsClient) 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 AvailabilitySetsClient) ListResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client AvailabilitySetsClient) listNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
|
||||||
|
req, err := lastResults.availabilitySetListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client AvailabilitySetsClient) ListComplete(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizes lists all available virtual machine sizes that can be used to create a new virtual machine in an
|
||||||
|
// existing availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizes(ctx context.Context, resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListAvailableSizes")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListAvailableSizesPreparer(ctx, resourceGroupName, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListAvailableSizesSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListAvailableSizesResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesPreparer prepares the ListAvailableSizes request.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesSender sends the ListAvailableSizes request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesResponder handles the response to the ListAvailableSizes request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesResponder(resp *http.Response) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscription lists all availability sets in a subscription.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscription(ctx context.Context) (result AvailabilitySetListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.aslr.Response.Response != nil {
|
||||||
|
sc = result.aslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listBySubscriptionNextResults
|
||||||
|
req, err := client.ListBySubscriptionPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.aslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.aslr, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionPreparer prepares the ListBySubscription request.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listBySubscriptionNextResults retrieves the next set of results, if any.
|
||||||
|
func (client AvailabilitySetsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
|
||||||
|
req, err := lastResults.availabilitySetListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionComplete(ctx context.Context) (result AvailabilitySetListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListBySubscription(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
// parameters - parameters supplied to the Update Availability Set operation.
|
||||||
|
func (client AvailabilitySetsClient) Update(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client AvailabilitySetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateResponder handles the response to the Update request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) UpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
51
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/client.go
сгенерированный
поставляемый
Normal file
51
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/client.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Package compute implements the Azure ARM Compute service API version .
|
||||||
|
//
|
||||||
|
// Compute Client
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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 Compute
|
||||||
|
DefaultBaseURI = "https://management.azure.com"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaseClient is the base client for Compute.
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
538
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/containerservices.go
сгенерированный
поставляемый
Normal file
538
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/containerservices.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,538 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContainerServicesClient is the compute Client
|
||||||
|
type ContainerServicesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContainerServicesClient creates an instance of the ContainerServicesClient client.
|
||||||
|
func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
|
||||||
|
return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContainerServicesClientWithBaseURI creates an instance of the ContainerServicesClient client.
|
||||||
|
func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
|
||||||
|
return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a container service with the specified configuration of orchestrator, masters, and
|
||||||
|
// agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
// parameters - parameters supplied to the Create or Update a Container Service operation.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (result ContainerServicesCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: parameters,
|
||||||
|
Constraints: []validation.Constraint{{Target: "parameters.ContainerServiceProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.Secret", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.MasterProfile", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.AgentPoolProfiles", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.WindowsProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.LinuxProfile", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-z][a-z0-9_-]*$`, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.ContainerServicesClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, containerServiceName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (future ContainerServicesCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes the specified container service in the specified subscription and resource group. The operation does
|
||||||
|
// not delete other resources created as part of creating a container service, including storage accounts, VMs, and
|
||||||
|
// availability sets. All the other resources created with the container service are part of the same resource group
|
||||||
|
// and can be deleted individually.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
func (client ContainerServicesClient) Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerServicesDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, containerServiceName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client ContainerServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", 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 ContainerServicesClient) DeleteSender(req *http.Request) (future ContainerServicesDeleteFuture, 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 ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets the properties of the specified container service in the specified subscription and resource group. The
|
||||||
|
// operation returns the properties including state, orchestrator, number of masters and agents, and FQDNs of masters
|
||||||
|
// and agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
func (client ContainerServicesClient) Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.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, containerServiceName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ContainerServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", 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 ContainerServicesClient) 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 ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, 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 gets a list of container services in the specified subscription. The operation returns properties of each
|
||||||
|
// container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
|
||||||
|
func (client ContainerServicesClient) List(ctx context.Context) (result ContainerServiceListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.cslr.Response.Response != nil {
|
||||||
|
sc = result.cslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.cslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.cslr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ContainerServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", 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 ContainerServicesClient) 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 ContainerServicesClient) ListResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ContainerServicesClient) listNextResults(ctx context.Context, lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||||
|
req, err := lastResults.containerServiceListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ContainerServicesClient) ListComplete(ctx context.Context) (result ContainerServiceListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup gets a list of container services in the specified subscription and resource group. The
|
||||||
|
// operation returns properties of each container service including state, orchestrator, number of masters and agents,
|
||||||
|
// and FQDNs of masters and agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client ContainerServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.cslr.Response.Response != nil {
|
||||||
|
sc = result.cslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.cslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.cslr, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client ContainerServicesClient) 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 = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", 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 ContainerServicesClient) 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 ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ContainerServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||||
|
req, err := lastResults.containerServiceListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ContainerServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
774
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/disks.go
сгенерированный
поставляемый
Normal file
774
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/disks.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,774 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DisksClient is the compute Client
|
||||||
|
type DisksClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDisksClient creates an instance of the DisksClient client.
|
||||||
|
func NewDisksClient(subscriptionID string) DisksClient {
|
||||||
|
return NewDisksClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDisksClientWithBaseURI creates an instance of the DisksClient client.
|
||||||
|
func NewDisksClientWithBaseURI(baseURI string, subscriptionID string) DisksClient {
|
||||||
|
return DisksClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
// disk - disk object supplied in the body of the Put disk operation.
|
||||||
|
func (client DisksClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (result DisksCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: disk,
|
||||||
|
Constraints: []validation.Constraint{{Target: "disk.DiskProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "disk.DiskProperties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "disk.DiskProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "disk.DiskProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.DisksClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, diskName, disk)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client DisksClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk Disk) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
disk.ManagedBy = 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.Compute/disks/{diskName}", pathParameters),
|
||||||
|
autorest.WithJSON(disk),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DisksClient) CreateOrUpdateSender(req *http.Request) (future DisksCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DisksClient) CreateOrUpdateResponder(resp *http.Response) (result Disk, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
func (client DisksClient) Delete(ctx context.Context, resourceGroupName string, diskName string) (result DisksDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, diskName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client DisksClient) DeletePreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", 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 DisksClient) DeleteSender(req *http.Request) (future DisksDeleteFuture, 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 DisksClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets information about a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
func (client DisksClient) Get(ctx context.Context, resourceGroupName string, diskName string) (result Disk, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.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, diskName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client DisksClient) GetPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", 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 DisksClient) 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 DisksClient) GetResponder(resp *http.Response) (result Disk, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccess grants access to a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
// grantAccessData - access data object supplied in the body of the get disk access operation.
|
||||||
|
func (client DisksClient) GrantAccess(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (result DisksGrantAccessFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.GrantAccess")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: grantAccessData,
|
||||||
|
Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.DisksClient", "GrantAccess", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.GrantAccessPreparer(ctx, resourceGroupName, diskName, grantAccessData)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GrantAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "GrantAccess", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessPreparer prepares the GrantAccess request.
|
||||||
|
func (client DisksClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, diskName string, grantAccessData GrantAccessData) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/beginGetAccess", pathParameters),
|
||||||
|
autorest.WithJSON(grantAccessData),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DisksClient) GrantAccessSender(req *http.Request) (future DisksGrantAccessFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessResponder handles the response to the GrantAccess request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DisksClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists all the disks under a subscription.
|
||||||
|
func (client DisksClient) List(ctx context.Context) (result DiskListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.dl.Response.Response != nil {
|
||||||
|
sc = result.dl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.dl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.dl, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client DisksClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/disks", 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 DisksClient) 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 DisksClient) ListResponder(resp *http.Response) (result DiskList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client DisksClient) listNextResults(ctx context.Context, lastResults DiskList) (result DiskList, err error) {
|
||||||
|
req, err := lastResults.diskListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client DisksClient) ListComplete(ctx context.Context) (result DiskListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup lists all the disks under a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client DisksClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DiskListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.dl.Response.Response != nil {
|
||||||
|
sc = result.dl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.dl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.dl, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client DisksClient) 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 = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks", 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 DisksClient) 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 DisksClient) ListByResourceGroupResponder(resp *http.Response) (result DiskList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client DisksClient) listByResourceGroupNextResults(ctx context.Context, lastResults DiskList) (result DiskList, err error) {
|
||||||
|
req, err := lastResults.diskListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client DisksClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DiskListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccess revokes access to a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
func (client DisksClient) RevokeAccess(ctx context.Context, resourceGroupName string, diskName string) (result DisksRevokeAccessFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.RevokeAccess")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, diskName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.RevokeAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "RevokeAccess", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||||
|
func (client DisksClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, diskName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}/endGetAccess", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DisksClient) RevokeAccessSender(req *http.Request) (future DisksRevokeAccessFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DisksClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update updates (patches) a disk.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// diskName - the name of the managed disk that is being created. The name can't be changed after the disk is
|
||||||
|
// created. Supported characters for the name are a-z, A-Z, 0-9 and _. The maximum name length is 80
|
||||||
|
// characters.
|
||||||
|
// disk - disk object supplied in the body of the Patch disk operation.
|
||||||
|
func (client DisksClient) Update(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (result DisksUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DisksClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, diskName, disk)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DisksClient", "Update", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client DisksClient) UpdatePreparer(ctx context.Context, resourceGroupName string, diskName string, disk DiskUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"diskName": autorest.Encode("path", diskName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}", pathParameters),
|
||||||
|
autorest.WithJSON(disk),
|
||||||
|
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 DisksClient) UpdateSender(req *http.Request) (future DisksUpdateFuture, 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 DisksClient) UpdateResponder(resp *http.Response) (result Disk, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
498
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleries.go
сгенерированный
поставляемый
Normal file
498
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleries.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,498 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GalleriesClient is the compute Client
|
||||||
|
type GalleriesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleriesClient creates an instance of the GalleriesClient client.
|
||||||
|
func NewGalleriesClient(subscriptionID string) GalleriesClient {
|
||||||
|
return NewGalleriesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleriesClientWithBaseURI creates an instance of the GalleriesClient client.
|
||||||
|
func NewGalleriesClientWithBaseURI(baseURI string, subscriptionID string) GalleriesClient {
|
||||||
|
return GalleriesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a Shared Image Gallery.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery. The allowed characters are alphabets and numbers with
|
||||||
|
// dots and periods allowed in the middle. The maximum length is 80 characters.
|
||||||
|
// gallery - parameters supplied to the create or update Shared Image Gallery operation.
|
||||||
|
func (client GalleriesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery) (result GalleriesCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, gallery)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client GalleriesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, galleryName string, gallery Gallery) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", pathParameters),
|
||||||
|
autorest.WithJSON(gallery),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GalleriesClient) CreateOrUpdateSender(req *http.Request) (future GalleriesCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GalleriesClient) CreateOrUpdateResponder(resp *http.Response) (result Gallery, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete a Shared Image Gallery.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery to be deleted.
|
||||||
|
func (client GalleriesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string) (result GalleriesDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client GalleriesClient) DeletePreparer(ctx context.Context, resourceGroupName string, galleryName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", 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 GalleriesClient) DeleteSender(req *http.Request) (future GalleriesDeleteFuture, 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 GalleriesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves information about a Shared Image Gallery.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery.
|
||||||
|
func (client GalleriesClient) Get(ctx context.Context, resourceGroupName string, galleryName string) (result Gallery, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.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, galleryName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client GalleriesClient) GetPreparer(ctx context.Context, resourceGroupName string, galleryName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}", 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 GalleriesClient) 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 GalleriesClient) GetResponder(resp *http.Response) (result Gallery, 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 list galleries under a subscription.
|
||||||
|
func (client GalleriesClient) List(ctx context.Context) (result GalleryListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.gl.Response.Response != nil {
|
||||||
|
sc = result.gl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.gl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.gl, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client GalleriesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/galleries", 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 GalleriesClient) 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 GalleriesClient) ListResponder(resp *http.Response) (result GalleryList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client GalleriesClient) listNextResults(ctx context.Context, lastResults GalleryList) (result GalleryList, err error) {
|
||||||
|
req, err := lastResults.galleryListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleriesClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleriesClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client GalleriesClient) ListComplete(ctx context.Context) (result GalleryListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup list galleries under a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client GalleriesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result GalleryListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.gl.Response.Response != nil {
|
||||||
|
sc = result.gl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.gl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.gl, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client GalleriesClient) 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 = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries", 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 GalleriesClient) 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 GalleriesClient) ListByResourceGroupResponder(resp *http.Response) (result GalleryList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client GalleriesClient) listByResourceGroupNextResults(ctx context.Context, lastResults GalleryList) (result GalleryList, err error) {
|
||||||
|
req, err := lastResults.galleryListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleriesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleriesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleriesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client GalleriesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result GalleryListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleriesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
410
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleryimages.go
сгенерированный
поставляемый
Normal file
410
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleryimages.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,410 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GalleryImagesClient is the compute Client
|
||||||
|
type GalleryImagesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleryImagesClient creates an instance of the GalleryImagesClient client.
|
||||||
|
func NewGalleryImagesClient(subscriptionID string) GalleryImagesClient {
|
||||||
|
return NewGalleryImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleryImagesClientWithBaseURI creates an instance of the GalleryImagesClient client.
|
||||||
|
func NewGalleryImagesClientWithBaseURI(baseURI string, subscriptionID string) GalleryImagesClient {
|
||||||
|
return GalleryImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a gallery Image Definition.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be created.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition to be created or updated. The allowed characters
|
||||||
|
// are alphabets and numbers with dots, dashes, and periods allowed in the middle. The maximum length is 80
|
||||||
|
// characters.
|
||||||
|
// galleryImage - parameters supplied to the create or update gallery image operation.
|
||||||
|
func (client GalleryImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage GalleryImage) (result GalleryImagesCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImagesClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: galleryImage,
|
||||||
|
Constraints: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "galleryImage.GalleryImageProperties.Identifier.Publisher", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "galleryImage.GalleryImageProperties.Identifier.Offer", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "galleryImage.GalleryImageProperties.Identifier.Sku", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.GalleryImagesClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImage)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client GalleryImagesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImage GalleryImage) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", pathParameters),
|
||||||
|
autorest.WithJSON(galleryImage),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GalleryImagesClient) CreateOrUpdateSender(req *http.Request) (future GalleryImagesCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GalleryImagesClient) CreateOrUpdateResponder(resp *http.Response) (result GalleryImage, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete a gallery image.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition is to be deleted.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition to be deleted.
|
||||||
|
func (client GalleryImagesClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImagesDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImagesClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client GalleryImagesClient) DeletePreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", 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 GalleryImagesClient) DeleteSender(req *http.Request) (future GalleryImagesDeleteFuture, 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 GalleryImagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves information about a gallery Image Definition.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery from which the Image Definitions are to be retrieved.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition to be retrieved.
|
||||||
|
func (client GalleryImagesClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImagesClient.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, galleryName, galleryImageName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client GalleryImagesClient) GetPreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}", 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 GalleryImagesClient) 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 GalleryImagesClient) GetResponder(resp *http.Response) (result GalleryImage, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGallery list gallery Image Definitions in a gallery.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery from which Image Definitions are to be listed.
|
||||||
|
func (client GalleryImagesClient) ListByGallery(ctx context.Context, resourceGroupName string, galleryName string) (result GalleryImageListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImagesClient.ListByGallery")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.gil.Response.Response != nil {
|
||||||
|
sc = result.gil.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByGalleryNextResults
|
||||||
|
req, err := client.ListByGalleryPreparer(ctx, resourceGroupName, galleryName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "ListByGallery", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByGallerySender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.gil.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "ListByGallery", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.gil, err = client.ListByGalleryResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "ListByGallery", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryPreparer prepares the ListByGallery request.
|
||||||
|
func (client GalleryImagesClient) ListByGalleryPreparer(ctx context.Context, resourceGroupName string, galleryName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGallerySender sends the ListByGallery request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GalleryImagesClient) ListByGallerySender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryResponder handles the response to the ListByGallery request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GalleryImagesClient) ListByGalleryResponder(resp *http.Response) (result GalleryImageList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByGalleryNextResults retrieves the next set of results, if any.
|
||||||
|
func (client GalleryImagesClient) listByGalleryNextResults(ctx context.Context, lastResults GalleryImageList) (result GalleryImageList, err error) {
|
||||||
|
req, err := lastResults.galleryImageListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "listByGalleryNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByGallerySender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "listByGalleryNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByGalleryResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImagesClient", "listByGalleryNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client GalleryImagesClient) ListByGalleryComplete(ctx context.Context, resourceGroupName string, galleryName string) (result GalleryImageListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImagesClient.ListByGallery")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByGallery(ctx, resourceGroupName, galleryName)
|
||||||
|
return
|
||||||
|
}
|
418
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleryimageversions.go
сгенерированный
поставляемый
Normal file
418
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/galleryimageversions.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,418 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// GalleryImageVersionsClient is the compute Client
|
||||||
|
type GalleryImageVersionsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleryImageVersionsClient creates an instance of the GalleryImageVersionsClient client.
|
||||||
|
func NewGalleryImageVersionsClient(subscriptionID string) GalleryImageVersionsClient {
|
||||||
|
return NewGalleryImageVersionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewGalleryImageVersionsClientWithBaseURI creates an instance of the GalleryImageVersionsClient client.
|
||||||
|
func NewGalleryImageVersionsClientWithBaseURI(baseURI string, subscriptionID string) GalleryImageVersionsClient {
|
||||||
|
return GalleryImageVersionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a gallery Image Version.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition in which the Image Version is to be created.
|
||||||
|
// galleryImageVersionName - the name of the gallery Image Version to be created. Needs to follow semantic
|
||||||
|
// version name pattern: The allowed characters are digit and period. Digits must be within the range of a
|
||||||
|
// 32-bit integer. Format: <MajorVersion>.<MinorVersion>.<Patch>
|
||||||
|
// galleryImageVersion - parameters supplied to the create or update gallery Image Version operation.
|
||||||
|
func (client GalleryImageVersionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion GalleryImageVersion) (result GalleryImageVersionsCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImageVersionsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: galleryImageVersion,
|
||||||
|
Constraints: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "galleryImageVersion.GalleryImageVersionProperties.PublishingProfile", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.GalleryImageVersionsClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName, galleryImageVersion)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client GalleryImageVersionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, galleryImageVersion GalleryImageVersion) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryImageVersionName": autorest.Encode("path", galleryImageVersionName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", pathParameters),
|
||||||
|
autorest.WithJSON(galleryImageVersion),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GalleryImageVersionsClient) CreateOrUpdateSender(req *http.Request) (future GalleryImageVersionsCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GalleryImageVersionsClient) CreateOrUpdateResponder(resp *http.Response) (result GalleryImageVersion, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete a gallery Image Version.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
|
||||||
|
// galleryImageVersionName - the name of the gallery Image Version to be deleted.
|
||||||
|
func (client GalleryImageVersionsClient) Delete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string) (result GalleryImageVersionsDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImageVersionsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, galleryName, galleryImageName, galleryImageVersionName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client GalleryImageVersionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryImageVersionName": autorest.Encode("path", galleryImageVersionName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", 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 GalleryImageVersionsClient) DeleteSender(req *http.Request) (future GalleryImageVersionsDeleteFuture, 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 GalleryImageVersionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves information about a gallery Image Version.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||||
|
// galleryImageName - the name of the gallery Image Definition in which the Image Version resides.
|
||||||
|
// galleryImageVersionName - the name of the gallery Image Version to be retrieved.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client GalleryImageVersionsClient) Get(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, expand ReplicationStatusTypes) (result GalleryImageVersion, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImageVersionsClient.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, galleryName, galleryImageName, galleryImageVersionName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client GalleryImageVersionsClient) GetPreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string, galleryImageVersionName string, expand ReplicationStatusTypes) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryImageVersionName": autorest.Encode("path", galleryImageVersionName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(string(expand)) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions/{galleryImageVersionName}", 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 GalleryImageVersionsClient) 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 GalleryImageVersionsClient) GetResponder(resp *http.Response) (result GalleryImageVersion, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryImage list gallery Image Versions in a gallery Image Definition.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// galleryName - the name of the Shared Image Gallery in which the Image Definition resides.
|
||||||
|
// galleryImageName - the name of the Shared Image Gallery Image Definition from which the Image Versions are
|
||||||
|
// to be listed.
|
||||||
|
func (client GalleryImageVersionsClient) ListByGalleryImage(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImageVersionListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImageVersionsClient.ListByGalleryImage")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.givl.Response.Response != nil {
|
||||||
|
sc = result.givl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByGalleryImageNextResults
|
||||||
|
req, err := client.ListByGalleryImagePreparer(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "ListByGalleryImage", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByGalleryImageSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.givl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "ListByGalleryImage", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.givl, err = client.ListByGalleryImageResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "ListByGalleryImage", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryImagePreparer prepares the ListByGalleryImage request.
|
||||||
|
func (client GalleryImageVersionsClient) ListByGalleryImagePreparer(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"galleryImageName": autorest.Encode("path", galleryImageName),
|
||||||
|
"galleryName": autorest.Encode("path", galleryName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/galleries/{galleryName}/images/{galleryImageName}/versions", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryImageSender sends the ListByGalleryImage request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client GalleryImageVersionsClient) ListByGalleryImageSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryImageResponder handles the response to the ListByGalleryImage request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client GalleryImageVersionsClient) ListByGalleryImageResponder(resp *http.Response) (result GalleryImageVersionList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByGalleryImageNextResults retrieves the next set of results, if any.
|
||||||
|
func (client GalleryImageVersionsClient) listByGalleryImageNextResults(ctx context.Context, lastResults GalleryImageVersionList) (result GalleryImageVersionList, err error) {
|
||||||
|
req, err := lastResults.galleryImageVersionListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "listByGalleryImageNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByGalleryImageSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "listByGalleryImageNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByGalleryImageResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.GalleryImageVersionsClient", "listByGalleryImageNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByGalleryImageComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client GalleryImageVersionsClient) ListByGalleryImageComplete(ctx context.Context, resourceGroupName string, galleryName string, galleryImageName string) (result GalleryImageVersionListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/GalleryImageVersionsClient.ListByGalleryImage")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByGalleryImage(ctx, resourceGroupName, galleryName, galleryImageName)
|
||||||
|
return
|
||||||
|
}
|
582
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/images.go
сгенерированный
поставляемый
Normal file
582
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/images.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,582 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ImagesClient is the compute Client
|
||||||
|
type ImagesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewImagesClient creates an instance of the ImagesClient client.
|
||||||
|
func NewImagesClient(subscriptionID string) ImagesClient {
|
||||||
|
return NewImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewImagesClientWithBaseURI creates an instance of the ImagesClient client.
|
||||||
|
func NewImagesClientWithBaseURI(baseURI string, subscriptionID string) ImagesClient {
|
||||||
|
return ImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update an image.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// imageName - the name of the image.
|
||||||
|
// parameters - parameters supplied to the Create Image operation.
|
||||||
|
func (client ImagesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, imageName string, parameters Image) (result ImagesCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, imageName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client ImagesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, imageName string, parameters Image) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client ImagesClient) CreateOrUpdateSender(req *http.Request) (future ImagesCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ImagesClient) CreateOrUpdateResponder(resp *http.Response) (result Image, 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 an Image.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// imageName - the name of the image.
|
||||||
|
func (client ImagesClient) Delete(ctx context.Context, resourceGroupName string, imageName string) (result ImagesDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, imageName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client ImagesClient) DeletePreparer(ctx context.Context, resourceGroupName string, imageName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", 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 ImagesClient) DeleteSender(req *http.Request) (future ImagesDeleteFuture, 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 ImagesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets an image.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// imageName - the name of the image.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client ImagesClient) Get(ctx context.Context, resourceGroupName string, imageName string, expand string) (result Image, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.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, imageName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ImagesClient) GetPreparer(ctx context.Context, resourceGroupName string, imageName string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", 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 ImagesClient) 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 ImagesClient) GetResponder(resp *http.Response) (result Image, 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 gets the list of Images in the subscription. Use nextLink property in the response to get the next page of
|
||||||
|
// Images. Do this till nextLink is null to fetch all the Images.
|
||||||
|
func (client ImagesClient) List(ctx context.Context) (result ImageListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.ilr.Response.Response != nil {
|
||||||
|
sc = result.ilr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.ilr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.ilr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ImagesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/images", 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 ImagesClient) 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 ImagesClient) ListResponder(resp *http.Response) (result ImageListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ImagesClient) listNextResults(ctx context.Context, lastResults ImageListResult) (result ImageListResult, err error) {
|
||||||
|
req, err := lastResults.imageListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ImagesClient) ListComplete(ctx context.Context) (result ImageListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup gets the list of images under a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client ImagesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ImageListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.ilr.Response.Response != nil {
|
||||||
|
sc = result.ilr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.ilr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.ilr, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client ImagesClient) 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 = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images", 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 ImagesClient) 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 ImagesClient) ListByResourceGroupResponder(resp *http.Response) (result ImageListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ImagesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ImageListResult) (result ImageListResult, err error) {
|
||||||
|
req, err := lastResults.imageListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ImagesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ImagesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ImageListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update an image.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// imageName - the name of the image.
|
||||||
|
// parameters - parameters supplied to the Update Image operation.
|
||||||
|
func (client ImagesClient) Update(ctx context.Context, resourceGroupName string, imageName string, parameters ImageUpdate) (result ImagesUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ImagesClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, imageName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ImagesClient", "Update", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client ImagesClient) UpdatePreparer(ctx context.Context, resourceGroupName string, imageName string, parameters ImageUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"imageName": autorest.Encode("path", imageName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/images/{imageName}", 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 ImagesClient) UpdateSender(req *http.Request) (future ImagesUpdateFuture, 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 ImagesClient) UpdateResponder(resp *http.Response) (result Image, 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
|
||||||
|
}
|
212
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/loganalytics.go
сгенерированный
поставляемый
Normal file
212
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/loganalytics.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,212 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// LogAnalyticsClient is the compute Client
|
||||||
|
type LogAnalyticsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLogAnalyticsClient creates an instance of the LogAnalyticsClient client.
|
||||||
|
func NewLogAnalyticsClient(subscriptionID string) LogAnalyticsClient {
|
||||||
|
return NewLogAnalyticsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewLogAnalyticsClientWithBaseURI creates an instance of the LogAnalyticsClient client.
|
||||||
|
func NewLogAnalyticsClientWithBaseURI(baseURI string, subscriptionID string) LogAnalyticsClient {
|
||||||
|
return LogAnalyticsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportRequestRateByInterval export logs that show Api requests made by this subscription in the given time window to
|
||||||
|
// show throttling activities.
|
||||||
|
// Parameters:
|
||||||
|
// parameters - parameters supplied to the LogAnalytics getRequestRateByInterval Api.
|
||||||
|
// location - the location upon which virtual-machine-sizes is queried.
|
||||||
|
func (client LogAnalyticsClient) ExportRequestRateByInterval(ctx context.Context, parameters RequestRateByIntervalInput, location string) (result LogAnalyticsExportRequestRateByIntervalFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.ExportRequestRateByInterval")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.LogAnalyticsClient", "ExportRequestRateByInterval", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.ExportRequestRateByIntervalPreparer(ctx, parameters, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.LogAnalyticsClient", "ExportRequestRateByInterval", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ExportRequestRateByIntervalSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.LogAnalyticsClient", "ExportRequestRateByInterval", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportRequestRateByIntervalPreparer prepares the ExportRequestRateByInterval request.
|
||||||
|
func (client LogAnalyticsClient) ExportRequestRateByIntervalPreparer(ctx context.Context, parameters RequestRateByIntervalInput, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getRequestRateByInterval", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportRequestRateByIntervalSender sends the ExportRequestRateByInterval request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client LogAnalyticsClient) ExportRequestRateByIntervalSender(req *http.Request) (future LogAnalyticsExportRequestRateByIntervalFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportRequestRateByIntervalResponder handles the response to the ExportRequestRateByInterval request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client LogAnalyticsClient) ExportRequestRateByIntervalResponder(resp *http.Response) (result LogAnalyticsOperationResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportThrottledRequests export logs that show total throttled Api requests for this subscription in the given time
|
||||||
|
// window.
|
||||||
|
// Parameters:
|
||||||
|
// parameters - parameters supplied to the LogAnalytics getThrottledRequests Api.
|
||||||
|
// location - the location upon which virtual-machine-sizes is queried.
|
||||||
|
func (client LogAnalyticsClient) ExportThrottledRequests(ctx context.Context, parameters ThrottledRequestsInput, location string) (result LogAnalyticsExportThrottledRequestsFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/LogAnalyticsClient.ExportThrottledRequests")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.LogAnalyticsClient", "ExportThrottledRequests", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.ExportThrottledRequestsPreparer(ctx, parameters, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.LogAnalyticsClient", "ExportThrottledRequests", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ExportThrottledRequestsSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.LogAnalyticsClient", "ExportThrottledRequests", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportThrottledRequestsPreparer prepares the ExportThrottledRequests request.
|
||||||
|
func (client LogAnalyticsClient) ExportThrottledRequestsPreparer(ctx context.Context, parameters ThrottledRequestsInput, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/logAnalytics/apiAccess/getThrottledRequests", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportThrottledRequestsSender sends the ExportThrottledRequests request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client LogAnalyticsClient) ExportThrottledRequestsSender(req *http.Request) (future LogAnalyticsExportThrottledRequestsFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// ExportThrottledRequestsResponder handles the response to the ExportThrottledRequests request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client LogAnalyticsClient) ExportThrottledRequestsResponder(resp *http.Response) (result LogAnalyticsOperationResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
10779
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/models.go
сгенерированный
поставляемый
Normal file
10779
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/models.go
сгенерированный
поставляемый
Normal file
Различия файлов скрыты, потому что одна или несколько строк слишком длинны
109
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/operations.go
сгенерированный
поставляемый
Normal file
109
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/operations.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// OperationsClient is the compute Client
|
||||||
|
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 gets a list of compute operations.
|
||||||
|
func (client OperationsClient) List(ctx context.Context) (result OperationListResult, 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, "compute.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, "compute.OperationsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.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 = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPath("/providers/Microsoft.Compute/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 OperationListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
577
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/proximityplacementgroups.go
сгенерированный
поставляемый
Normal file
577
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/proximityplacementgroups.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,577 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ProximityPlacementGroupsClient is the compute Client
|
||||||
|
type ProximityPlacementGroupsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProximityPlacementGroupsClient creates an instance of the ProximityPlacementGroupsClient client.
|
||||||
|
func NewProximityPlacementGroupsClient(subscriptionID string) ProximityPlacementGroupsClient {
|
||||||
|
return NewProximityPlacementGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewProximityPlacementGroupsClientWithBaseURI creates an instance of the ProximityPlacementGroupsClient client.
|
||||||
|
func NewProximityPlacementGroupsClientWithBaseURI(baseURI string, subscriptionID string) ProximityPlacementGroupsClient {
|
||||||
|
return ProximityPlacementGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a proximity placement group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// proximityPlacementGroupName - the name of the proximity placement group.
|
||||||
|
// parameters - parameters supplied to the Create Proximity Placement Group operation.
|
||||||
|
func (client ProximityPlacementGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string, parameters ProximityPlacementGroup) (result ProximityPlacementGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, proximityPlacementGroupName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client ProximityPlacementGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string, parameters ProximityPlacementGroup) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"proximityPlacementGroupName": autorest.Encode("path", proximityPlacementGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client ProximityPlacementGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ProximityPlacementGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result ProximityPlacementGroup, 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 delete a proximity placement group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// proximityPlacementGroupName - the name of the proximity placement group.
|
||||||
|
func (client ProximityPlacementGroupsClient) Delete(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string) (result autorest.Response, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response != nil {
|
||||||
|
sc = result.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, proximityPlacementGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Delete", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client ProximityPlacementGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"proximityPlacementGroupName": autorest.Encode("path", proximityPlacementGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", 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 ProximityPlacementGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ProximityPlacementGroupsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves information about a proximity placement group .
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// proximityPlacementGroupName - the name of the proximity placement group.
|
||||||
|
func (client ProximityPlacementGroupsClient) Get(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string) (result ProximityPlacementGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.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, proximityPlacementGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ProximityPlacementGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"proximityPlacementGroupName": autorest.Encode("path", proximityPlacementGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", 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 ProximityPlacementGroupsClient) 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 ProximityPlacementGroupsClient) GetResponder(resp *http.Response) (result ProximityPlacementGroup, 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 all proximity placement groups in a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ProximityPlacementGroupListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.ppglr.Response.Response != nil {
|
||||||
|
sc = result.ppglr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.ppglr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.ppglr, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client ProximityPlacementGroupsClient) 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 = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups", 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 ProximityPlacementGroupsClient) 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 ProximityPlacementGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result ProximityPlacementGroupListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ProximityPlacementGroupsClient) listByResourceGroupNextResults(ctx context.Context, lastResults ProximityPlacementGroupListResult) (result ProximityPlacementGroupListResult, err error) {
|
||||||
|
req, err := lastResults.proximityPlacementGroupListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ProximityPlacementGroupListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscription lists all proximity placement groups in a subscription.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListBySubscription(ctx context.Context) (result ProximityPlacementGroupListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.ppglr.Response.Response != nil {
|
||||||
|
sc = result.ppglr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listBySubscriptionNextResults
|
||||||
|
req, err := client.ListBySubscriptionPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListBySubscription", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.ppglr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListBySubscription", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.ppglr, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "ListBySubscription", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionPreparer prepares the ListBySubscription request.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/proximityPlacementGroups", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListBySubscriptionResponder(resp *http.Response) (result ProximityPlacementGroupListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listBySubscriptionNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ProximityPlacementGroupsClient) listBySubscriptionNextResults(ctx context.Context, lastResults ProximityPlacementGroupListResult) (result ProximityPlacementGroupListResult, err error) {
|
||||||
|
req, err := lastResults.proximityPlacementGroupListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ProximityPlacementGroupsClient) ListBySubscriptionComplete(ctx context.Context) (result ProximityPlacementGroupListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListBySubscription(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update a proximity placement group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// proximityPlacementGroupName - the name of the proximity placement group.
|
||||||
|
// parameters - parameters supplied to the Update Proximity Placement Group operation.
|
||||||
|
func (client ProximityPlacementGroupsClient) Update(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string, parameters ProximityPlacementGroupUpdate) (result ProximityPlacementGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ProximityPlacementGroupsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, proximityPlacementGroupName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Update", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ProximityPlacementGroupsClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client ProximityPlacementGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, proximityPlacementGroupName string, parameters ProximityPlacementGroupUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"proximityPlacementGroupName": autorest.Encode("path", proximityPlacementGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/proximityPlacementGroups/{proximityPlacementGroupName}", 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 ProximityPlacementGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateResponder handles the response to the Update request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ProximityPlacementGroupsClient) UpdateResponder(resp *http.Response) (result ProximityPlacementGroup, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
151
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/resourceskus.go
сгенерированный
поставляемый
Normal file
151
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/resourceskus.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,151 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ResourceSkusClient is the compute Client
|
||||||
|
type ResourceSkusClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResourceSkusClient creates an instance of the ResourceSkusClient client.
|
||||||
|
func NewResourceSkusClient(subscriptionID string) ResourceSkusClient {
|
||||||
|
return NewResourceSkusClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewResourceSkusClientWithBaseURI creates an instance of the ResourceSkusClient client.
|
||||||
|
func NewResourceSkusClientWithBaseURI(baseURI string, subscriptionID string) ResourceSkusClient {
|
||||||
|
return ResourceSkusClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets the list of Microsoft.Compute SKUs available for your Subscription.
|
||||||
|
func (client ResourceSkusClient) List(ctx context.Context) (result ResourceSkusResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.rsr.Response.Response != nil {
|
||||||
|
sc = result.rsr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.rsr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.rsr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ResourceSkusClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-09-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/skus", 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 ResourceSkusClient) 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 ResourceSkusClient) ListResponder(resp *http.Response) (result ResourceSkusResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ResourceSkusClient) listNextResults(ctx context.Context, lastResults ResourceSkusResult) (result ResourceSkusResult, err error) {
|
||||||
|
req, err := lastResults.resourceSkusResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ResourceSkusClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ResourceSkusClient) ListComplete(ctx context.Context) (result ResourceSkusResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ResourceSkusClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
768
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/snapshots.go
сгенерированный
поставляемый
Normal file
768
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/snapshots.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,768 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// SnapshotsClient is the compute Client
|
||||||
|
type SnapshotsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSnapshotsClient creates an instance of the SnapshotsClient client.
|
||||||
|
func NewSnapshotsClient(subscriptionID string) SnapshotsClient {
|
||||||
|
return NewSnapshotsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewSnapshotsClientWithBaseURI creates an instance of the SnapshotsClient client.
|
||||||
|
func NewSnapshotsClientWithBaseURI(baseURI string, subscriptionID string) SnapshotsClient {
|
||||||
|
return SnapshotsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
// snapshot - snapshot object supplied in the body of the Put disk operation.
|
||||||
|
func (client SnapshotsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (result SnapshotsCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: snapshot,
|
||||||
|
Constraints: []validation.Constraint{{Target: "snapshot.SnapshotProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.CreationData.ImageReference.ID", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "snapshot.SnapshotProperties.EncryptionSettings", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "snapshot.SnapshotProperties.EncryptionSettings.DiskEncryptionKey.SecretURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.SourceVault", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "snapshot.SnapshotProperties.EncryptionSettings.KeyEncryptionKey.KeyURL", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.SnapshotsClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client SnapshotsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot Snapshot) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshot.ManagedBy = 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.Compute/snapshots/{snapshotName}", pathParameters),
|
||||||
|
autorest.WithJSON(snapshot),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client SnapshotsClient) CreateOrUpdateSender(req *http.Request) (future SnapshotsCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client SnapshotsClient) CreateOrUpdateResponder(resp *http.Response) (result Snapshot, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
func (client SnapshotsClient) Delete(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, snapshotName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client SnapshotsClient) DeletePreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", 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 SnapshotsClient) DeleteSender(req *http.Request) (future SnapshotsDeleteFuture, 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 SnapshotsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets information about a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
func (client SnapshotsClient) Get(ctx context.Context, resourceGroupName string, snapshotName string) (result Snapshot, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.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, snapshotName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client SnapshotsClient) GetPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", 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 SnapshotsClient) 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 SnapshotsClient) GetResponder(resp *http.Response) (result Snapshot, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccess grants access to a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
// grantAccessData - access data object supplied in the body of the get snapshot access operation.
|
||||||
|
func (client SnapshotsClient) GrantAccess(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (result SnapshotsGrantAccessFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.GrantAccess")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: grantAccessData,
|
||||||
|
Constraints: []validation.Constraint{{Target: "grantAccessData.DurationInSeconds", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.SnapshotsClient", "GrantAccess", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.GrantAccessPreparer(ctx, resourceGroupName, snapshotName, grantAccessData)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GrantAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "GrantAccess", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessPreparer prepares the GrantAccess request.
|
||||||
|
func (client SnapshotsClient) GrantAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string, grantAccessData GrantAccessData) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/beginGetAccess", pathParameters),
|
||||||
|
autorest.WithJSON(grantAccessData),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessSender sends the GrantAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client SnapshotsClient) GrantAccessSender(req *http.Request) (future SnapshotsGrantAccessFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// GrantAccessResponder handles the response to the GrantAccess request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client SnapshotsClient) GrantAccessResponder(resp *http.Response) (result AccessURI, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// List lists snapshots under a subscription.
|
||||||
|
func (client SnapshotsClient) List(ctx context.Context) (result SnapshotListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.sl.Response.Response != nil {
|
||||||
|
sc = result.sl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.sl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.sl, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client SnapshotsClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/snapshots", 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 SnapshotsClient) 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 SnapshotsClient) ListResponder(resp *http.Response) (result SnapshotList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client SnapshotsClient) listNextResults(ctx context.Context, lastResults SnapshotList) (result SnapshotList, err error) {
|
||||||
|
req, err := lastResults.snapshotListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client SnapshotsClient) ListComplete(ctx context.Context) (result SnapshotListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup lists snapshots under a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client SnapshotsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result SnapshotListPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.sl.Response.Response != nil {
|
||||||
|
sc = result.sl.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.sl.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.sl, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client SnapshotsClient) 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 = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots", 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 SnapshotsClient) 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 SnapshotsClient) ListByResourceGroupResponder(resp *http.Response) (result SnapshotList, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client SnapshotsClient) listByResourceGroupNextResults(ctx context.Context, lastResults SnapshotList) (result SnapshotList, err error) {
|
||||||
|
req, err := lastResults.snapshotListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client SnapshotsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result SnapshotListIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccess revokes access to a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
func (client SnapshotsClient) RevokeAccess(ctx context.Context, resourceGroupName string, snapshotName string) (result SnapshotsRevokeAccessFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.RevokeAccess")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.RevokeAccessPreparer(ctx, resourceGroupName, snapshotName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.RevokeAccessSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "RevokeAccess", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessPreparer prepares the RevokeAccess request.
|
||||||
|
func (client SnapshotsClient) RevokeAccessPreparer(ctx context.Context, resourceGroupName string, snapshotName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}/endGetAccess", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessSender sends the RevokeAccess request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client SnapshotsClient) RevokeAccessSender(req *http.Request) (future SnapshotsRevokeAccessFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// RevokeAccessResponder handles the response to the RevokeAccess request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client SnapshotsClient) RevokeAccessResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update updates (patches) a snapshot.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// snapshotName - the name of the snapshot that is being created. The name can't be changed after the snapshot
|
||||||
|
// is created. Supported characters for the name are a-z, A-Z, 0-9 and _. The max name length is 80 characters.
|
||||||
|
// snapshot - snapshot object supplied in the body of the Patch snapshot operation.
|
||||||
|
func (client SnapshotsClient) Update(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (result SnapshotsUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/SnapshotsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, snapshotName, snapshot)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.SnapshotsClient", "Update", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client SnapshotsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, snapshotName string, snapshot SnapshotUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"snapshotName": autorest.Encode("path", snapshotName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-06-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/snapshots/{snapshotName}", pathParameters),
|
||||||
|
autorest.WithJSON(snapshot),
|
||||||
|
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 SnapshotsClient) UpdateSender(req *http.Request) (future SnapshotsUpdateFuture, 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 SnapshotsClient) UpdateResponder(resp *http.Response) (result Snapshot, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
162
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/usage.go
сгенерированный
поставляемый
Normal file
162
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/usage.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,162 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// UsageClient is the compute Client
|
||||||
|
type UsageClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUsageClient creates an instance of the UsageClient client.
|
||||||
|
func NewUsageClient(subscriptionID string) UsageClient {
|
||||||
|
return NewUsageClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewUsageClientWithBaseURI creates an instance of the UsageClient client.
|
||||||
|
func NewUsageClientWithBaseURI(baseURI string, subscriptionID string) UsageClient {
|
||||||
|
return UsageClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List gets, for the specified location, the current compute resource usage information as well as the limits for
|
||||||
|
// compute resources under the subscription.
|
||||||
|
// Parameters:
|
||||||
|
// location - the location for which resource usage is queried.
|
||||||
|
func (client UsageClient) List(ctx context.Context, location string) (result ListUsagesResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/UsageClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.lur.Response.Response != nil {
|
||||||
|
sc = result.lur.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.UsageClient", "List", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.lur.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.lur, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.UsageClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client UsageClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/usages", 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 UsageClient) 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 UsageClient) ListResponder(resp *http.Response) (result ListUsagesResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client UsageClient) listNextResults(ctx context.Context, lastResults ListUsagesResult) (result ListUsagesResult, err error) {
|
||||||
|
req, err := lastResults.listUsagesResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.UsageClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.UsageClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.UsageClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client UsageClient) ListComplete(ctx context.Context, location string) (result ListUsagesResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/UsageClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, location)
|
||||||
|
return
|
||||||
|
}
|
30
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/version.go
сгенерированный
поставляемый
Normal file
30
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/version.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
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 + " compute/2018-10-01"
|
||||||
|
}
|
||||||
|
|
||||||
|
// Version returns the semantic version (see http://semver.org) of the client.
|
||||||
|
func Version() string {
|
||||||
|
return version.Number
|
||||||
|
}
|
283
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineextensionimages.go
сгенерированный
поставляемый
Normal file
283
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineextensionimages.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,283 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineExtensionImagesClient is the compute Client
|
||||||
|
type VirtualMachineExtensionImagesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineExtensionImagesClient creates an instance of the VirtualMachineExtensionImagesClient client.
|
||||||
|
func NewVirtualMachineExtensionImagesClient(subscriptionID string) VirtualMachineExtensionImagesClient {
|
||||||
|
return NewVirtualMachineExtensionImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineExtensionImagesClientWithBaseURI creates an instance of the VirtualMachineExtensionImagesClient
|
||||||
|
// client.
|
||||||
|
func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineExtensionImagesClient {
|
||||||
|
return VirtualMachineExtensionImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets a virtual machine extension image.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) Get(ctx context.Context, location string, publisherName string, typeParameter string, version string) (result VirtualMachineExtensionImage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionImagesClient.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, location, publisherName, typeParameter, version)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) GetPreparer(ctx context.Context, location string, publisherName string, typeParameter string, version string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"type": autorest.Encode("path", typeParameter),
|
||||||
|
"version": autorest.Encode("path", version),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions/{version}", 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 VirtualMachineExtensionImagesClient) 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 VirtualMachineExtensionImagesClient) GetResponder(resp *http.Response) (result VirtualMachineExtensionImage, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypes gets a list of virtual machine extension image types.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListTypes(ctx context.Context, location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionImagesClient.ListTypes")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListTypesPreparer(ctx, location, publisherName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListTypesSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListTypesResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypesPreparer prepares the ListTypes request.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListTypesPreparer(ctx context.Context, location string, publisherName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypesSender sends the ListTypes request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListTypesSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListTypesResponder handles the response to the ListTypes request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http.Response) (result ListVirtualMachineExtensionImage, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVersions gets a list of virtual machine extension image versions.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
// filter - the filter to apply on the operation.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListVersions(ctx context.Context, location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionImagesClient.ListVersions")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListVersionsPreparer(ctx, location, publisherName, typeParameter, filter, top, orderby)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListVersionsSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListVersionsResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVersionsPreparer prepares the ListVersions request.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(ctx context.Context, location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"type": autorest.Encode("path", typeParameter),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(filter) > 0 {
|
||||||
|
queryParameters["$filter"] = autorest.Encode("query", filter)
|
||||||
|
}
|
||||||
|
if top != nil {
|
||||||
|
queryParameters["$top"] = autorest.Encode("query", *top)
|
||||||
|
}
|
||||||
|
if len(orderby) > 0 {
|
||||||
|
queryParameters["$orderby"] = autorest.Encode("query", orderby)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmextension/types/{type}/versions", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVersionsSender sends the ListVersions request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListVersionsSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListVersionsResponder handles the response to the ListVersions request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineExtensionImagesClient) ListVersionsResponder(resp *http.Response) (result ListVirtualMachineExtensionImage, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
447
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineextensions.go
сгенерированный
поставляемый
Normal file
447
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineextensions.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,447 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineExtensionsClient is the compute Client
|
||||||
|
type VirtualMachineExtensionsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineExtensionsClient creates an instance of the VirtualMachineExtensionsClient client.
|
||||||
|
func NewVirtualMachineExtensionsClient(subscriptionID string) VirtualMachineExtensionsClient {
|
||||||
|
return NewVirtualMachineExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineExtensionsClientWithBaseURI creates an instance of the VirtualMachineExtensionsClient client.
|
||||||
|
func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineExtensionsClient {
|
||||||
|
return VirtualMachineExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate the operation to create or update the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMName - the name of the virtual machine where the extension should be created or updated.
|
||||||
|
// VMExtensionName - the name of the virtual machine extension.
|
||||||
|
// extensionParameters - parameters supplied to the Create Virtual Machine Extension operation.
|
||||||
|
func (client VirtualMachineExtensionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension) (result VirtualMachineExtensionsCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, VMName, VMExtensionName, extensionParameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmExtensionName": autorest.Encode("path", VMExtensionName),
|
||||||
|
"vmName": autorest.Encode("path", VMName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", pathParameters),
|
||||||
|
autorest.WithJSON(extensionParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineExtensionsClient) CreateOrUpdateSender(req *http.Request) (future VirtualMachineExtensionsCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineExtension, 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 the operation to delete the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMName - the name of the virtual machine where the extension should be deleted.
|
||||||
|
// VMExtensionName - the name of the virtual machine extension.
|
||||||
|
func (client VirtualMachineExtensionsClient) Delete(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string) (result VirtualMachineExtensionsDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, VMName, VMExtensionName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client VirtualMachineExtensionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmExtensionName": autorest.Encode("path", VMExtensionName),
|
||||||
|
"vmName": autorest.Encode("path", VMName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", 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 VirtualMachineExtensionsClient) DeleteSender(req *http.Request) (future VirtualMachineExtensionsDeleteFuture, 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 VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the operation to get the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMName - the name of the virtual machine containing the extension.
|
||||||
|
// VMExtensionName - the name of the virtual machine extension.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client VirtualMachineExtensionsClient) Get(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, expand string) (result VirtualMachineExtension, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionsClient.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, VMName, VMExtensionName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client VirtualMachineExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmExtensionName": autorest.Encode("path", VMExtensionName),
|
||||||
|
"vmName": autorest.Encode("path", VMName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", 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 VirtualMachineExtensionsClient) 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 VirtualMachineExtensionsClient) GetResponder(resp *http.Response) (result VirtualMachineExtension, 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 the operation to get all extensions of a Virtual Machine.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMName - the name of the virtual machine containing the extension.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client VirtualMachineExtensionsClient) List(ctx context.Context, resourceGroupName string, VMName string, expand string) (result VirtualMachineExtensionsListResult, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionsClient.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, resourceGroupName, VMName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client VirtualMachineExtensionsClient) ListPreparer(ctx context.Context, resourceGroupName string, VMName string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmName": autorest.Encode("path", VMName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions", 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 VirtualMachineExtensionsClient) 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 VirtualMachineExtensionsClient) ListResponder(resp *http.Response) (result VirtualMachineExtensionsListResult, 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 the operation to update the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMName - the name of the virtual machine where the extension should be updated.
|
||||||
|
// VMExtensionName - the name of the virtual machine extension.
|
||||||
|
// extensionParameters - parameters supplied to the Update Virtual Machine Extension operation.
|
||||||
|
func (client VirtualMachineExtensionsClient) Update(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtensionUpdate) (result VirtualMachineExtensionsUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineExtensionsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, VMName, VMExtensionName, extensionParameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Update", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client VirtualMachineExtensionsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtensionUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmExtensionName": autorest.Encode("path", VMExtensionName),
|
||||||
|
"vmName": autorest.Encode("path", VMName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/extensions/{vmExtensionName}", pathParameters),
|
||||||
|
autorest.WithJSON(extensionParameters),
|
||||||
|
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 VirtualMachineExtensionsClient) UpdateSender(req *http.Request) (future VirtualMachineExtensionsUpdateFuture, 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 VirtualMachineExtensionsClient) UpdateResponder(resp *http.Response) (result VirtualMachineExtension, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
446
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineimages.go
сгенерированный
поставляемый
Normal file
446
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineimages.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,446 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineImagesClient is the compute Client
|
||||||
|
type VirtualMachineImagesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineImagesClient creates an instance of the VirtualMachineImagesClient client.
|
||||||
|
func NewVirtualMachineImagesClient(subscriptionID string) VirtualMachineImagesClient {
|
||||||
|
return NewVirtualMachineImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineImagesClientWithBaseURI creates an instance of the VirtualMachineImagesClient client.
|
||||||
|
func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineImagesClient {
|
||||||
|
return VirtualMachineImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets a virtual machine image.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
// publisherName - a valid image publisher.
|
||||||
|
// offer - a valid image publisher offer.
|
||||||
|
// skus - a valid image SKU.
|
||||||
|
// version - a valid image SKU version.
|
||||||
|
func (client VirtualMachineImagesClient) Get(ctx context.Context, location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImagesClient.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, location, publisherName, offer, skus, version)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client VirtualMachineImagesClient) GetPreparer(ctx context.Context, location string, publisherName string, offer string, skus string, version string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"offer": autorest.Encode("path", offer),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"skus": autorest.Encode("path", skus),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"version": autorest.Encode("path", version),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions/{version}", 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 VirtualMachineImagesClient) 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 VirtualMachineImagesClient) GetResponder(resp *http.Response) (result VirtualMachineImage, 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 gets a list of all virtual machine image versions for the specified location, publisher, offer, and SKU.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
// publisherName - a valid image publisher.
|
||||||
|
// offer - a valid image publisher offer.
|
||||||
|
// skus - a valid image SKU.
|
||||||
|
// filter - the filter to apply on the operation.
|
||||||
|
func (client VirtualMachineImagesClient) List(ctx context.Context, location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImagesClient.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, location, publisherName, offer, skus, filter, top, orderby)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client VirtualMachineImagesClient) ListPreparer(ctx context.Context, location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"offer": autorest.Encode("path", offer),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"skus": autorest.Encode("path", skus),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(filter) > 0 {
|
||||||
|
queryParameters["$filter"] = autorest.Encode("query", filter)
|
||||||
|
}
|
||||||
|
if top != nil {
|
||||||
|
queryParameters["$top"] = autorest.Encode("query", *top)
|
||||||
|
}
|
||||||
|
if len(orderby) > 0 {
|
||||||
|
queryParameters["$orderby"] = autorest.Encode("query", orderby)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus/{skus}/versions", 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 VirtualMachineImagesClient) 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 VirtualMachineImagesClient) ListResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOffers gets a list of virtual machine image offers for the specified location and publisher.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
// publisherName - a valid image publisher.
|
||||||
|
func (client VirtualMachineImagesClient) ListOffers(ctx context.Context, location string, publisherName string) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImagesClient.ListOffers")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListOffersPreparer(ctx, location, publisherName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListOffersSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListOffersResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOffersPreparer prepares the ListOffers request.
|
||||||
|
func (client VirtualMachineImagesClient) ListOffersPreparer(ctx context.Context, location string, publisherName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOffersSender sends the ListOffers request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineImagesClient) ListOffersSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListOffersResponder handles the response to the ListOffers request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPublishers gets a list of virtual machine image publishers for the specified Azure location.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
func (client VirtualMachineImagesClient) ListPublishers(ctx context.Context, location string) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImagesClient.ListPublishers")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListPublishersPreparer(ctx, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListPublishersSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListPublishersResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPublishersPreparer prepares the ListPublishers request.
|
||||||
|
func (client VirtualMachineImagesClient) ListPublishersPreparer(ctx context.Context, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPublishersSender sends the ListPublishers request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineImagesClient) ListPublishersSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPublishersResponder handles the response to the ListPublishers request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSkus gets a list of virtual machine image SKUs for the specified location, publisher, and offer.
|
||||||
|
// Parameters:
|
||||||
|
// location - the name of a supported Azure region.
|
||||||
|
// publisherName - a valid image publisher.
|
||||||
|
// offer - a valid image publisher offer.
|
||||||
|
func (client VirtualMachineImagesClient) ListSkus(ctx context.Context, location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineImagesClient.ListSkus")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListSkusPreparer(ctx, location, publisherName, offer)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSkusSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListSkusResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSkusPreparer prepares the ListSkus request.
|
||||||
|
func (client VirtualMachineImagesClient) ListSkusPreparer(ctx context.Context, location string, publisherName string, offer string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"offer": autorest.Encode("path", offer),
|
||||||
|
"publisherName": autorest.Encode("path", publisherName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/publishers/{publisherName}/artifacttypes/vmimage/offers/{offer}/skus", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSkusSender sends the ListSkus request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineImagesClient) ListSkusSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListSkusResponder handles the response to the ListSkus request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineImagesClient) ListSkusResponder(resp *http.Response) (result ListVirtualMachineImageResource, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result.Value),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
244
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineruncommands.go
сгенерированный
поставляемый
Normal file
244
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachineruncommands.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,244 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineRunCommandsClient is the compute Client
|
||||||
|
type VirtualMachineRunCommandsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineRunCommandsClient creates an instance of the VirtualMachineRunCommandsClient client.
|
||||||
|
func NewVirtualMachineRunCommandsClient(subscriptionID string) VirtualMachineRunCommandsClient {
|
||||||
|
return NewVirtualMachineRunCommandsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineRunCommandsClientWithBaseURI creates an instance of the VirtualMachineRunCommandsClient client.
|
||||||
|
func NewVirtualMachineRunCommandsClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineRunCommandsClient {
|
||||||
|
return VirtualMachineRunCommandsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets specific run command for a subscription in a location.
|
||||||
|
// Parameters:
|
||||||
|
// location - the location upon which run commands is queried.
|
||||||
|
// commandID - the command id.
|
||||||
|
func (client VirtualMachineRunCommandsClient) Get(ctx context.Context, location string, commandID string) (result RunCommandDocument, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineRunCommandsClient.Get")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.VirtualMachineRunCommandsClient", "Get", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.GetPreparer(ctx, location, commandID)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client VirtualMachineRunCommandsClient) GetPreparer(ctx context.Context, location string, commandID string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"commandId": autorest.Encode("path", commandID),
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands/{commandId}", 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 VirtualMachineRunCommandsClient) 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 VirtualMachineRunCommandsClient) GetResponder(resp *http.Response) (result RunCommandDocument, 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 all available run commands for a subscription in a location.
|
||||||
|
// Parameters:
|
||||||
|
// location - the location upon which run commands is queried.
|
||||||
|
func (client VirtualMachineRunCommandsClient) List(ctx context.Context, location string) (result RunCommandListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineRunCommandsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.rclr.Response.Response != nil {
|
||||||
|
sc = result.rclr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.VirtualMachineRunCommandsClient", "List", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.rclr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.rclr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client VirtualMachineRunCommandsClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/runCommands", 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 VirtualMachineRunCommandsClient) 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 VirtualMachineRunCommandsClient) ListResponder(resp *http.Response) (result RunCommandListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client VirtualMachineRunCommandsClient) listNextResults(ctx context.Context, lastResults RunCommandListResult) (result RunCommandListResult, err error) {
|
||||||
|
req, err := lastResults.runCommandListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineRunCommandsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client VirtualMachineRunCommandsClient) ListComplete(ctx context.Context, location string) (result RunCommandListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineRunCommandsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, location)
|
||||||
|
return
|
||||||
|
}
|
1747
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachines.go
сгенерированный
поставляемый
Normal file
1747
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachines.go
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
400
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetextensions.go
сгенерированный
поставляемый
Normal file
400
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetextensions.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,400 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineScaleSetExtensionsClient is the compute Client
|
||||||
|
type VirtualMachineScaleSetExtensionsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineScaleSetExtensionsClient creates an instance of the VirtualMachineScaleSetExtensionsClient client.
|
||||||
|
func NewVirtualMachineScaleSetExtensionsClient(subscriptionID string) VirtualMachineScaleSetExtensionsClient {
|
||||||
|
return NewVirtualMachineScaleSetExtensionsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineScaleSetExtensionsClientWithBaseURI creates an instance of the
|
||||||
|
// VirtualMachineScaleSetExtensionsClient client.
|
||||||
|
func NewVirtualMachineScaleSetExtensionsClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineScaleSetExtensionsClient {
|
||||||
|
return VirtualMachineScaleSetExtensionsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate the operation to create or update an extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set where the extension should be create or updated.
|
||||||
|
// vmssExtensionName - the name of the VM scale set extension.
|
||||||
|
// extensionParameters - parameters supplied to the Create VM scale set Extension operation.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters VirtualMachineScaleSetExtension) (result VirtualMachineScaleSetExtensionsCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, VMScaleSetName, vmssExtensionName, extensionParameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, extensionParameters VirtualMachineScaleSetExtension) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
"vmssExtensionName": autorest.Encode("path", vmssExtensionName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", pathParameters),
|
||||||
|
autorest.WithJSON(extensionParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) CreateOrUpdateSender(req *http.Request) (future VirtualMachineScaleSetExtensionsCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineScaleSetExtension, 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 the operation to delete the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set where the extension should be deleted.
|
||||||
|
// vmssExtensionName - the name of the VM scale set extension.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) Delete(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string) (result VirtualMachineScaleSetExtensionsDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, VMScaleSetName, vmssExtensionName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) DeletePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
"vmssExtensionName": autorest.Encode("path", vmssExtensionName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", 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 VirtualMachineScaleSetExtensionsClient) DeleteSender(req *http.Request) (future VirtualMachineScaleSetExtensionsDeleteFuture, 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 VirtualMachineScaleSetExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the operation to get the extension.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set containing the extension.
|
||||||
|
// vmssExtensionName - the name of the VM scale set extension.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) Get(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, expand string) (result VirtualMachineScaleSetExtension, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.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, VMScaleSetName, vmssExtensionName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) GetPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string, vmssExtensionName string, expand string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
"vmssExtensionName": autorest.Encode("path", vmssExtensionName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(expand) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions/{vmssExtensionName}", 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 VirtualMachineScaleSetExtensionsClient) 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 VirtualMachineScaleSetExtensionsClient) GetResponder(resp *http.Response) (result VirtualMachineScaleSetExtension, 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 gets a list of all extensions in a VM scale set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set containing the extension.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) List(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetExtensionListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.vmsselr.Response.Response != nil {
|
||||||
|
sc = result.vmsselr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.vmsselr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.vmsselr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) ListPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensions", 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 VirtualMachineScaleSetExtensionsClient) 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 VirtualMachineScaleSetExtensionsClient) ListResponder(resp *http.Response) (result VirtualMachineScaleSetExtensionListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) listNextResults(ctx context.Context, lastResults VirtualMachineScaleSetExtensionListResult) (result VirtualMachineScaleSetExtensionListResult, err error) {
|
||||||
|
req, err := lastResults.virtualMachineScaleSetExtensionListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetExtensionsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client VirtualMachineScaleSetExtensionsClient) ListComplete(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetExtensionListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetExtensionsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
return
|
||||||
|
}
|
351
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetrollingupgrades.go
сгенерированный
поставляемый
Normal file
351
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetrollingupgrades.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,351 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineScaleSetRollingUpgradesClient is the compute Client
|
||||||
|
type VirtualMachineScaleSetRollingUpgradesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineScaleSetRollingUpgradesClient creates an instance of the
|
||||||
|
// VirtualMachineScaleSetRollingUpgradesClient client.
|
||||||
|
func NewVirtualMachineScaleSetRollingUpgradesClient(subscriptionID string) VirtualMachineScaleSetRollingUpgradesClient {
|
||||||
|
return NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI creates an instance of the
|
||||||
|
// VirtualMachineScaleSetRollingUpgradesClient client.
|
||||||
|
func NewVirtualMachineScaleSetRollingUpgradesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineScaleSetRollingUpgradesClient {
|
||||||
|
return VirtualMachineScaleSetRollingUpgradesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cancel cancels the current virtual machine scale set rolling upgrade.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) Cancel(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesCancelFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.Cancel")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CancelPreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "Cancel", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CancelSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "Cancel", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelPreparer prepares the Cancel request.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) CancelPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/cancel", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelSender sends the Cancel request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) CancelSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesCancelFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CancelResponder handles the response to the Cancel request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) CancelResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatest gets the status of the latest virtual machine scale set rolling upgrade.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatest(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result RollingUpgradeStatusInfo, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.GetLatest")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.GetLatestPreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetLatestSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetLatestResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "GetLatest", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatestPreparer prepares the GetLatest request.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestPreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/rollingUpgrades/latest", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatestSender sends the GetLatest request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetLatestResponder handles the response to the GetLatest request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) GetLatestResponder(resp *http.Response) (result RollingUpgradeStatusInfo, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartExtensionUpgrade starts a rolling upgrade to move all extensions for all virtual machine scale set instances to
|
||||||
|
// the latest available extension version. Instances which are already running the latest extension versions are not
|
||||||
|
// affected.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.StartExtensionUpgrade")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.StartExtensionUpgradePreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.StartExtensionUpgradeSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartExtensionUpgrade", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartExtensionUpgradePreparer prepares the StartExtensionUpgrade request.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/extensionRollingUpgrade", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartExtensionUpgradeSender sends the StartExtensionUpgrade request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartExtensionUpgradeFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartExtensionUpgradeResponder handles the response to the StartExtensionUpgrade request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartExtensionUpgradeResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartOSUpgrade starts a rolling upgrade to move all virtual machine scale set instances to the latest available
|
||||||
|
// Platform Image OS version. Instances which are already running the latest available OS version are not affected.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// VMScaleSetName - the name of the VM scale set.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgrade(ctx context.Context, resourceGroupName string, VMScaleSetName string) (result VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineScaleSetRollingUpgradesClient.StartOSUpgrade")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.StartOSUpgradePreparer(ctx, resourceGroupName, VMScaleSetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartOSUpgrade", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.StartOSUpgradeSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetRollingUpgradesClient", "StartOSUpgrade", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartOSUpgradePreparer prepares the StartOSUpgrade request.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradePreparer(ctx context.Context, resourceGroupName string, VMScaleSetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsPost(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/osRollingUpgrade", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartOSUpgradeSender sends the StartOSUpgrade request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradeSender(req *http.Request) (future VirtualMachineScaleSetRollingUpgradesStartOSUpgradeFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// StartOSUpgradeResponder handles the response to the StartOSUpgrade request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client VirtualMachineScaleSetRollingUpgradesClient) StartOSUpgradeResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
1823
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesets.go
сгенерированный
поставляемый
Normal file
1823
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesets.go
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
1234
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetvms.go
сгенерированный
поставляемый
Normal file
1234
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinescalesetvms.go
сгенерированный
поставляемый
Normal file
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
124
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinesizes.go
сгенерированный
поставляемый
Normal file
124
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-10-01/compute/virtualmachinesizes.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// VirtualMachineSizesClient is the compute Client
|
||||||
|
type VirtualMachineSizesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineSizesClient creates an instance of the VirtualMachineSizesClient client.
|
||||||
|
func NewVirtualMachineSizesClient(subscriptionID string) VirtualMachineSizesClient {
|
||||||
|
return NewVirtualMachineSizesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewVirtualMachineSizesClientWithBaseURI creates an instance of the VirtualMachineSizesClient client.
|
||||||
|
func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineSizesClient {
|
||||||
|
return VirtualMachineSizesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// List this API is deprecated. Use [Resources
|
||||||
|
// Skus](https://docs.microsoft.com/en-us/rest/api/compute/resourceskus/list)
|
||||||
|
// Parameters:
|
||||||
|
// location - the location upon which virtual-machine-sizes is queried.
|
||||||
|
func (client VirtualMachineSizesClient) List(ctx context.Context, location string) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/VirtualMachineSizesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: location,
|
||||||
|
Constraints: []validation.Constraint{{Target: "location", Name: validation.Pattern, Rule: `^[-\w\._]+$`, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.VirtualMachineSizesClient", "List", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.ListPreparer(ctx, location)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client VirtualMachineSizesClient) ListPreparer(ctx context.Context, location string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"location": autorest.Encode("path", location),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2018-10-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/locations/{location}/vmSizes", 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 VirtualMachineSizesClient) 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 VirtualMachineSizesClient) ListResponder(resp *http.Response) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
655
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/availabilitysets.go
сгенерированный
поставляемый
Normal file
655
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/availabilitysets.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,655 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// AvailabilitySetsClient is the compute Client
|
||||||
|
type AvailabilitySetsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAvailabilitySetsClient creates an instance of the AvailabilitySetsClient client.
|
||||||
|
func NewAvailabilitySetsClient(subscriptionID string) AvailabilitySetsClient {
|
||||||
|
return NewAvailabilitySetsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewAvailabilitySetsClientWithBaseURI creates an instance of the AvailabilitySetsClient client.
|
||||||
|
func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) AvailabilitySetsClient {
|
||||||
|
return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
// parameters - parameters supplied to the Create Availability Set operation.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySet) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete delete an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) Delete(ctx context.Context, resourceGroupName string, availabilitySetName string) (result autorest.Response, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response != nil {
|
||||||
|
sc = result.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client AvailabilitySetsClient) DeletePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) 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 retrieves information about an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) Get(ctx context.Context, resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.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, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client AvailabilitySetsClient) GetPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) 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 AvailabilitySetsClient) GetResponder(resp *http.Response) (result AvailabilitySet, 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 all availability sets in a resource group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client AvailabilitySetsClient) List(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.aslr.Response.Response != nil {
|
||||||
|
sc = result.aslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.aslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.aslr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client AvailabilitySetsClient) ListPreparer(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-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets", 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 AvailabilitySetsClient) 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 AvailabilitySetsClient) ListResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client AvailabilitySetsClient) listNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
|
||||||
|
req, err := lastResults.availabilitySetListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client AvailabilitySetsClient) ListComplete(ctx context.Context, resourceGroupName string) (result AvailabilitySetListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizes lists all available virtual machine sizes that can be used to create a new virtual machine in an
|
||||||
|
// existing availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizes(ctx context.Context, resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListAvailableSizes")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.ListAvailableSizesPreparer(ctx, resourceGroupName, availabilitySetName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListAvailableSizesSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.ListAvailableSizesResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesPreparer prepares the ListAvailableSizes request.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesPreparer(ctx context.Context, resourceGroupName string, availabilitySetName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}/vmSizes", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesSender sends the ListAvailableSizes request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListAvailableSizesResponder handles the response to the ListAvailableSizes request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) ListAvailableSizesResponder(resp *http.Response) (result VirtualMachineSizeListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscription lists all availability sets in a subscription.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscription(ctx context.Context) (result AvailabilitySetListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.aslr.Response.Response != nil {
|
||||||
|
sc = result.aslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listBySubscriptionNextResults
|
||||||
|
req, err := client.ListBySubscriptionPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.aslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.aslr, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListBySubscription", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionPreparer prepares the ListBySubscription request.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/availabilitySets", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionResponder(resp *http.Response) (result AvailabilitySetListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listBySubscriptionNextResults retrieves the next set of results, if any.
|
||||||
|
func (client AvailabilitySetsClient) listBySubscriptionNextResults(ctx context.Context, lastResults AvailabilitySetListResult) (result AvailabilitySetListResult, err error) {
|
||||||
|
req, err := lastResults.availabilitySetListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client AvailabilitySetsClient) ListBySubscriptionComplete(ctx context.Context) (result AvailabilitySetListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListBySubscription(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update an availability set.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// availabilitySetName - the name of the availability set.
|
||||||
|
// parameters - parameters supplied to the Update Availability Set operation.
|
||||||
|
func (client AvailabilitySetsClient) Update(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (result AvailabilitySet, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/AvailabilitySetsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, availabilitySetName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client AvailabilitySetsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, availabilitySetName string, parameters AvailabilitySetUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"availabilitySetName": autorest.Encode("path", availabilitySetName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}", 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 AvailabilitySetsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateResponder handles the response to the Update request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client AvailabilitySetsClient) UpdateResponder(resp *http.Response) (result AvailabilitySet, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
51
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/client.go
сгенерированный
поставляемый
Normal file
51
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/client.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
// Package compute implements the Azure ARM Compute service API version .
|
||||||
|
//
|
||||||
|
// Compute Client
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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 Compute
|
||||||
|
DefaultBaseURI = "https://management.azure.com"
|
||||||
|
)
|
||||||
|
|
||||||
|
// BaseClient is the base client for Compute.
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
}
|
538
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/containerservices.go
сгенерированный
поставляемый
Normal file
538
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/containerservices.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,538 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ContainerServicesClient is the compute Client
|
||||||
|
type ContainerServicesClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContainerServicesClient creates an instance of the ContainerServicesClient client.
|
||||||
|
func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
|
||||||
|
return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewContainerServicesClientWithBaseURI creates an instance of the ContainerServicesClient client.
|
||||||
|
func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
|
||||||
|
return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate creates or updates a container service with the specified configuration of orchestrator, masters, and
|
||||||
|
// agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
// parameters - parameters supplied to the Create or Update a Container Service operation.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (result ContainerServicesCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: parameters,
|
||||||
|
Constraints: []validation.Constraint{{Target: "parameters.ContainerServiceProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.ServicePrincipalProfile.Secret", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.MasterProfile", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.AgentPoolProfiles", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.WindowsProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true, Chain: nil},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.LinuxProfile", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-z][a-z0-9_-]*$`, Chain: nil}}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.ContainerServiceProperties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil}}},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.ContainerServicesClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, containerServiceName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, containerServiceName string, parameters ContainerService) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (future ContainerServicesCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result ContainerService, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Delete deletes the specified container service in the specified subscription and resource group. The operation does
|
||||||
|
// not delete other resources created as part of creating a container service, including storage accounts, VMs, and
|
||||||
|
// availability sets. All the other resources created with the container service are part of the same resource group
|
||||||
|
// and can be deleted individually.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
func (client ContainerServicesClient) Delete(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerServicesDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, containerServiceName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client ContainerServicesClient) DeletePreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", 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 ContainerServicesClient) DeleteSender(req *http.Request) (future ContainerServicesDeleteFuture, 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 ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get gets the properties of the specified container service in the specified subscription and resource group. The
|
||||||
|
// operation returns the properties including state, orchestrator, number of masters and agents, and FQDNs of masters
|
||||||
|
// and agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// containerServiceName - the name of the container service in the specified subscription and resource group.
|
||||||
|
func (client ContainerServicesClient) Get(ctx context.Context, resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.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, containerServiceName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client ContainerServicesClient) GetPreparer(ctx context.Context, resourceGroupName string, containerServiceName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"containerServiceName": autorest.Encode("path", containerServiceName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", 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 ContainerServicesClient) 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 ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, 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 gets a list of container services in the specified subscription. The operation returns properties of each
|
||||||
|
// container service including state, orchestrator, number of masters and agents, and FQDNs of masters and agents.
|
||||||
|
func (client ContainerServicesClient) List(ctx context.Context) (result ContainerServiceListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.cslr.Response.Response != nil {
|
||||||
|
sc = result.cslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listNextResults
|
||||||
|
req, err := client.ListPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.cslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.cslr, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "List", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListPreparer prepares the List request.
|
||||||
|
func (client ContainerServicesClient) ListPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", 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 ContainerServicesClient) 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 ContainerServicesClient) ListResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ContainerServicesClient) listNextResults(ctx context.Context, lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||||
|
req, err := lastResults.containerServiceListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ContainerServicesClient) ListComplete(ctx context.Context) (result ContainerServiceListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.List")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.List(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroup gets a list of container services in the specified subscription and resource group. The
|
||||||
|
// operation returns properties of each container service including state, orchestrator, number of masters and agents,
|
||||||
|
// and FQDNs of masters and agents.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client ContainerServicesClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.cslr.Response.Response != nil {
|
||||||
|
sc = result.cslr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.cslr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.cslr, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client ContainerServicesClient) 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 = "2017-01-31"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", 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 ContainerServicesClient) 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 ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ContainerServiceListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client ContainerServicesClient) listByResourceGroupNextResults(ctx context.Context, lastResults ContainerServiceListResult) (result ContainerServiceListResult, err error) {
|
||||||
|
req, err := lastResults.containerServiceListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.ContainerServicesClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client ContainerServicesClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result ContainerServiceListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/ContainerServicesClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
592
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/dedicatedhostgroups.go
сгенерированный
поставляемый
Normal file
592
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/dedicatedhostgroups.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,592 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DedicatedHostGroupsClient is the compute Client
|
||||||
|
type DedicatedHostGroupsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDedicatedHostGroupsClient creates an instance of the DedicatedHostGroupsClient client.
|
||||||
|
func NewDedicatedHostGroupsClient(subscriptionID string) DedicatedHostGroupsClient {
|
||||||
|
return NewDedicatedHostGroupsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDedicatedHostGroupsClientWithBaseURI creates an instance of the DedicatedHostGroupsClient client.
|
||||||
|
func NewDedicatedHostGroupsClientWithBaseURI(baseURI string, subscriptionID string) DedicatedHostGroupsClient {
|
||||||
|
return DedicatedHostGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a dedicated host group. For details of Dedicated Host and Dedicated Host Groups
|
||||||
|
// please see [Dedicated Host Documentation] (https://go.microsoft.com/fwlink/?linkid=2082596)
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// parameters - parameters supplied to the Create Dedicated Host Group.
|
||||||
|
func (client DedicatedHostGroupsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, hostGroupName string, parameters DedicatedHostGroup) (result DedicatedHostGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: parameters,
|
||||||
|
Constraints: []validation.Constraint{{Target: "parameters.DedicatedHostGroupProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.DedicatedHostGroupProperties.PlatformFaultDomainCount", Name: validation.Null, Rule: true,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.DedicatedHostGroupProperties.PlatformFaultDomainCount", Name: validation.InclusiveMaximum, Rule: int64(3), Chain: nil},
|
||||||
|
{Target: "parameters.DedicatedHostGroupProperties.PlatformFaultDomainCount", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
|
||||||
|
}},
|
||||||
|
}}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.DedicatedHostGroupsClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, hostGroupName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client DedicatedHostGroupsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, hostGroupName string, parameters DedicatedHostGroup) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DedicatedHostGroupsClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result DedicatedHostGroup, 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 delete a dedicated host group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
func (client DedicatedHostGroupsClient) Delete(ctx context.Context, resourceGroupName string, hostGroupName string) (result autorest.Response, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response != nil {
|
||||||
|
sc = result.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, hostGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = resp
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Delete", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Delete", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client DedicatedHostGroupsClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", 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 DedicatedHostGroupsClient) DeleteSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeleteResponder handles the response to the Delete request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostGroupsClient) 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 retrieves information about a dedicated host group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
func (client DedicatedHostGroupsClient) Get(ctx context.Context, resourceGroupName string, hostGroupName string) (result DedicatedHostGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.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, hostGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client DedicatedHostGroupsClient) GetPreparer(ctx context.Context, resourceGroupName string, hostGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", 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 DedicatedHostGroupsClient) 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 DedicatedHostGroupsClient) GetResponder(resp *http.Response) (result DedicatedHostGroup, 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 all of the dedicated host groups in the specified resource group. Use the nextLink
|
||||||
|
// property in the response to get the next page of dedicated host groups.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
func (client DedicatedHostGroupsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result DedicatedHostGroupListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.dhglr.Response.Response != nil {
|
||||||
|
sc = result.dhglr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByResourceGroupNextResults
|
||||||
|
req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListByResourceGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.dhglr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListByResourceGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.dhglr, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListByResourceGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
|
||||||
|
func (client DedicatedHostGroupsClient) 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-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups", 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 DedicatedHostGroupsClient) 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 DedicatedHostGroupsClient) ListByResourceGroupResponder(resp *http.Response) (result DedicatedHostGroupListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByResourceGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client DedicatedHostGroupsClient) listByResourceGroupNextResults(ctx context.Context, lastResults DedicatedHostGroupListResult) (result DedicatedHostGroupListResult, err error) {
|
||||||
|
req, err := lastResults.dedicatedHostGroupListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByResourceGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByResourceGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client DedicatedHostGroupsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result DedicatedHostGroupListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.ListByResourceGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByResourceGroup(ctx, resourceGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscription lists all of the dedicated host groups in the subscription. Use the nextLink property in the
|
||||||
|
// response to get the next page of dedicated host groups.
|
||||||
|
func (client DedicatedHostGroupsClient) ListBySubscription(ctx context.Context) (result DedicatedHostGroupListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.dhglr.Response.Response != nil {
|
||||||
|
sc = result.dhglr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listBySubscriptionNextResults
|
||||||
|
req, err := client.ListBySubscriptionPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListBySubscription", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.dhglr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListBySubscription", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.dhglr, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "ListBySubscription", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionPreparer prepares the ListBySubscription request.
|
||||||
|
func (client DedicatedHostGroupsClient) ListBySubscriptionPreparer(ctx context.Context) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Compute/hostGroups", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionSender sends the ListBySubscription request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DedicatedHostGroupsClient) ListBySubscriptionSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionResponder handles the response to the ListBySubscription request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostGroupsClient) ListBySubscriptionResponder(resp *http.Response) (result DedicatedHostGroupListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listBySubscriptionNextResults retrieves the next set of results, if any.
|
||||||
|
func (client DedicatedHostGroupsClient) listBySubscriptionNextResults(ctx context.Context, lastResults DedicatedHostGroupListResult) (result DedicatedHostGroupListResult, err error) {
|
||||||
|
req, err := lastResults.dedicatedHostGroupListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listBySubscriptionNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListBySubscriptionSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listBySubscriptionNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListBySubscriptionResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "listBySubscriptionNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListBySubscriptionComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client DedicatedHostGroupsClient) ListBySubscriptionComplete(ctx context.Context) (result DedicatedHostGroupListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.ListBySubscription")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListBySubscription(ctx)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update an dedicated host group.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// parameters - parameters supplied to the Update Dedicated Host Group operation.
|
||||||
|
func (client DedicatedHostGroupsClient) Update(ctx context.Context, resourceGroupName string, hostGroupName string, parameters DedicatedHostGroupUpdate) (result DedicatedHostGroup, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostGroupsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response.Response != nil {
|
||||||
|
sc = result.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, hostGroupName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Update", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostGroupsClient", "Update", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client DedicatedHostGroupsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hostGroupName string, parameters DedicatedHostGroupUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}", 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 DedicatedHostGroupsClient) UpdateSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdateResponder handles the response to the Update request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostGroupsClient) UpdateResponder(resp *http.Response) (result DedicatedHostGroup, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
495
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/dedicatedhosts.go
сгенерированный
поставляемый
Normal file
495
vendor/github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2019-03-01/compute/dedicatedhosts.go
сгенерированный
поставляемый
Normal file
|
@ -0,0 +1,495 @@
|
||||||
|
package compute
|
||||||
|
|
||||||
|
// 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/Azure/go-autorest/autorest"
|
||||||
|
"github.com/Azure/go-autorest/autorest/azure"
|
||||||
|
"github.com/Azure/go-autorest/autorest/validation"
|
||||||
|
"github.com/Azure/go-autorest/tracing"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// DedicatedHostsClient is the compute Client
|
||||||
|
type DedicatedHostsClient struct {
|
||||||
|
BaseClient
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDedicatedHostsClient creates an instance of the DedicatedHostsClient client.
|
||||||
|
func NewDedicatedHostsClient(subscriptionID string) DedicatedHostsClient {
|
||||||
|
return NewDedicatedHostsClientWithBaseURI(DefaultBaseURI, subscriptionID)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewDedicatedHostsClientWithBaseURI creates an instance of the DedicatedHostsClient client.
|
||||||
|
func NewDedicatedHostsClientWithBaseURI(baseURI string, subscriptionID string) DedicatedHostsClient {
|
||||||
|
return DedicatedHostsClient{NewWithBaseURI(baseURI, subscriptionID)}
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdate create or update a dedicated host .
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// hostName - the name of the dedicated host .
|
||||||
|
// parameters - parameters supplied to the Create Dedicated Host.
|
||||||
|
func (client DedicatedHostsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost) (result DedicatedHostsCreateOrUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.CreateOrUpdate")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
if err := validation.Validate([]validation.Validation{
|
||||||
|
{TargetValue: parameters,
|
||||||
|
Constraints: []validation.Constraint{{Target: "parameters.DedicatedHostProperties", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.DedicatedHostProperties.PlatformFaultDomain", Name: validation.Null, Rule: false,
|
||||||
|
Chain: []validation.Constraint{{Target: "parameters.DedicatedHostProperties.PlatformFaultDomain", Name: validation.InclusiveMaximum, Rule: int64(2), Chain: nil},
|
||||||
|
{Target: "parameters.DedicatedHostProperties.PlatformFaultDomain", Name: validation.InclusiveMinimum, Rule: 0, Chain: nil},
|
||||||
|
}},
|
||||||
|
}},
|
||||||
|
{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
|
||||||
|
return result, validation.NewError("compute.DedicatedHostsClient", "CreateOrUpdate", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, hostGroupName, hostName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "CreateOrUpdate", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.CreateOrUpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "CreateOrUpdate", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
|
||||||
|
func (client DedicatedHostsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHost) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"hostName": autorest.Encode("path", hostName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPut(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", pathParameters),
|
||||||
|
autorest.WithJSON(parameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DedicatedHostsClient) CreateOrUpdateSender(req *http.Request) (future DedicatedHostsCreateOrUpdateFuture, 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
|
||||||
|
}
|
||||||
|
|
||||||
|
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostsClient) CreateOrUpdateResponder(resp *http.Response) (result DedicatedHost, 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 delete a dedicated host.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// hostName - the name of the dedicated host.
|
||||||
|
func (client DedicatedHostsClient) Delete(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string) (result DedicatedHostsDeleteFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.Delete")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.DeletePreparer(ctx, resourceGroupName, hostGroupName, hostName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Delete", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.DeleteSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Delete", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// DeletePreparer prepares the Delete request.
|
||||||
|
func (client DedicatedHostsClient) DeletePreparer(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"hostName": autorest.Encode("path", hostName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsDelete(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", 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 DedicatedHostsClient) DeleteSender(req *http.Request) (future DedicatedHostsDeleteFuture, 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 DedicatedHostsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = resp
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get retrieves information about a dedicated host.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// hostName - the name of the dedicated host.
|
||||||
|
// expand - the expand expression to apply on the operation.
|
||||||
|
func (client DedicatedHostsClient) Get(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, expand InstanceViewTypes) (result DedicatedHost, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.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, hostGroupName, hostName, expand)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Get", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.GetSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Get", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.GetResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Get", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPreparer prepares the Get request.
|
||||||
|
func (client DedicatedHostsClient) GetPreparer(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, expand InstanceViewTypes) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"hostName": autorest.Encode("path", hostName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
if len(string(expand)) > 0 {
|
||||||
|
queryParameters["$expand"] = autorest.Encode("query", expand)
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", 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 DedicatedHostsClient) 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 DedicatedHostsClient) GetResponder(resp *http.Response) (result DedicatedHost, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByHostGroup lists all of the dedicated hosts in the specified dedicated host group. Use the nextLink property in
|
||||||
|
// the response to get the next page of dedicated hosts.
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
func (client DedicatedHostsClient) ListByHostGroup(ctx context.Context, resourceGroupName string, hostGroupName string) (result DedicatedHostListResultPage, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.ListByHostGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.dhlr.Response.Response != nil {
|
||||||
|
sc = result.dhlr.Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.fn = client.listByHostGroupNextResults
|
||||||
|
req, err := client.ListByHostGroupPreparer(ctx, resourceGroupName, hostGroupName)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "ListByHostGroup", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := client.ListByHostGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.dhlr.Response = autorest.Response{Response: resp}
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "ListByHostGroup", resp, "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result.dhlr, err = client.ListByHostGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "ListByHostGroup", resp, "Failure responding to request")
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByHostGroupPreparer prepares the ListByHostGroup request.
|
||||||
|
func (client DedicatedHostsClient) ListByHostGroupPreparer(ctx context.Context, resourceGroupName string, hostGroupName string) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsGet(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts", pathParameters),
|
||||||
|
autorest.WithQueryParameters(queryParameters))
|
||||||
|
return preparer.Prepare((&http.Request{}).WithContext(ctx))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByHostGroupSender sends the ListByHostGroup request. The method will close the
|
||||||
|
// http.Response Body if it receives an error.
|
||||||
|
func (client DedicatedHostsClient) ListByHostGroupSender(req *http.Request) (*http.Response, error) {
|
||||||
|
sd := autorest.GetSendDecorators(req.Context(), azure.DoRetryWithRegistration(client.Client))
|
||||||
|
return autorest.SendWithSender(client, req, sd...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByHostGroupResponder handles the response to the ListByHostGroup request. The method always
|
||||||
|
// closes the http.Response Body.
|
||||||
|
func (client DedicatedHostsClient) ListByHostGroupResponder(resp *http.Response) (result DedicatedHostListResult, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// listByHostGroupNextResults retrieves the next set of results, if any.
|
||||||
|
func (client DedicatedHostsClient) listByHostGroupNextResults(ctx context.Context, lastResults DedicatedHostListResult) (result DedicatedHostListResult, err error) {
|
||||||
|
req, err := lastResults.dedicatedHostListResultPreparer(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "listByHostGroupNextResults", nil, "Failure preparing next results request")
|
||||||
|
}
|
||||||
|
if req == nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
resp, err := client.ListByHostGroupSender(req)
|
||||||
|
if err != nil {
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return result, autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "listByHostGroupNextResults", resp, "Failure sending next results request")
|
||||||
|
}
|
||||||
|
result, err = client.ListByHostGroupResponder(resp)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "listByHostGroupNextResults", resp, "Failure responding to next results request")
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// ListByHostGroupComplete enumerates all values, automatically crossing page boundaries as required.
|
||||||
|
func (client DedicatedHostsClient) ListByHostGroupComplete(ctx context.Context, resourceGroupName string, hostGroupName string) (result DedicatedHostListResultIterator, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.ListByHostGroup")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response().Response.Response != nil {
|
||||||
|
sc = result.page.Response().Response.Response.StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
result.page, err = client.ListByHostGroup(ctx, resourceGroupName, hostGroupName)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update update an dedicated host .
|
||||||
|
// Parameters:
|
||||||
|
// resourceGroupName - the name of the resource group.
|
||||||
|
// hostGroupName - the name of the dedicated host group.
|
||||||
|
// hostName - the name of the dedicated host .
|
||||||
|
// parameters - parameters supplied to the Update Dedicated Host operation.
|
||||||
|
func (client DedicatedHostsClient) Update(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHostUpdate) (result DedicatedHostsUpdateFuture, err error) {
|
||||||
|
if tracing.IsEnabled() {
|
||||||
|
ctx = tracing.StartSpan(ctx, fqdn+"/DedicatedHostsClient.Update")
|
||||||
|
defer func() {
|
||||||
|
sc := -1
|
||||||
|
if result.Response() != nil {
|
||||||
|
sc = result.Response().StatusCode
|
||||||
|
}
|
||||||
|
tracing.EndSpan(ctx, sc, err)
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
req, err := client.UpdatePreparer(ctx, resourceGroupName, hostGroupName, hostName, parameters)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Update", nil, "Failure preparing request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err = client.UpdateSender(req)
|
||||||
|
if err != nil {
|
||||||
|
err = autorest.NewErrorWithError(err, "compute.DedicatedHostsClient", "Update", result.Response(), "Failure sending request")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpdatePreparer prepares the Update request.
|
||||||
|
func (client DedicatedHostsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, hostGroupName string, hostName string, parameters DedicatedHostUpdate) (*http.Request, error) {
|
||||||
|
pathParameters := map[string]interface{}{
|
||||||
|
"hostGroupName": autorest.Encode("path", hostGroupName),
|
||||||
|
"hostName": autorest.Encode("path", hostName),
|
||||||
|
"resourceGroupName": autorest.Encode("path", resourceGroupName),
|
||||||
|
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
|
||||||
|
}
|
||||||
|
|
||||||
|
const APIVersion = "2019-03-01"
|
||||||
|
queryParameters := map[string]interface{}{
|
||||||
|
"api-version": APIVersion,
|
||||||
|
}
|
||||||
|
|
||||||
|
preparer := autorest.CreatePreparer(
|
||||||
|
autorest.AsContentType("application/json; charset=utf-8"),
|
||||||
|
autorest.AsPatch(),
|
||||||
|
autorest.WithBaseURL(client.BaseURI),
|
||||||
|
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/hostGroups/{hostGroupName}/hosts/{hostName}", 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 DedicatedHostsClient) UpdateSender(req *http.Request) (future DedicatedHostsUpdateFuture, 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 DedicatedHostsClient) UpdateResponder(resp *http.Response) (result DedicatedHost, err error) {
|
||||||
|
err = autorest.Respond(
|
||||||
|
resp,
|
||||||
|
client.ByInspecting(),
|
||||||
|
azure.WithErrorUnlessStatusCode(http.StatusOK),
|
||||||
|
autorest.ByUnmarshallingJSON(&result),
|
||||||
|
autorest.ByClosing())
|
||||||
|
result.Response = autorest.Response{Response: resp}
|
||||||
|
return
|
||||||
|
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче