Update godeps.

This commit is contained in:
Brendan Burns 2017-06-08 04:56:33 +00:00 committed by Brendan Burns
parent 8e9186a53a
commit 56accd874d
708 changed files with 8299 additions and 29710 deletions

49
Godeps/Godeps.json generated
View File

@ -30,61 +30,66 @@
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute",
"Comment": "v7.0.1-beta", "Comment": "v10.0.4-beta-1-g786cc84",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4" "Rev": "786cc84138518bf7fd6d60e92fad1ac9d1a117ad"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/containerregistry", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/containerregistry",
"Comment": "v7.0.1-beta", "Comment": "v10.0.4-beta-1-g786cc84",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4" "Rev": "786cc84138518bf7fd6d60e92fad1ac9d1a117ad"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network",
"Comment": "v7.0.1-beta", "Comment": "v10.0.4-beta-1-g786cc84",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4" "Rev": "786cc84138518bf7fd6d60e92fad1ac9d1a117ad"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage",
"Comment": "v7.0.1-beta", "Comment": "v10.0.4-beta-1-g786cc84",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4" "Rev": "786cc84138518bf7fd6d60e92fad1ac9d1a117ad"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/storage",
"Comment": "v7.0.1-beta", "Comment": "v10.0.4-beta-1-g786cc84",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4" "Rev": "786cc84138518bf7fd6d60e92fad1ac9d1a117ad"
}, },
{ {
"ImportPath": "github.com/Azure/go-ansiterm", "ImportPath": "github.com/Azure/go-ansiterm",
"Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe" "Rev": "fa152c58bc15761d0200cb75fe958b89a9d4888e"
}, },
{ {
"ImportPath": "github.com/Azure/go-ansiterm/winterm", "ImportPath": "github.com/Azure/go-ansiterm/winterm",
"Rev": "70b2c90b260171e829f1ebd7c17f600c11858dbe" "Rev": "fa152c58bc15761d0200cb75fe958b89a9d4888e"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest", "ImportPath": "github.com/Azure/go-autorest/autorest",
"Comment": "v7.2.3", "Comment": "v8.0.0",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/adal",
"Comment": "v8.0.0",
"Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/azure", "ImportPath": "github.com/Azure/go-autorest/autorest/azure",
"Comment": "v7.2.3", "Comment": "v8.0.0",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/date", "ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Comment": "v7.2.3", "Comment": "v8.0.0",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/to", "ImportPath": "github.com/Azure/go-autorest/autorest/to",
"Comment": "v7.2.3", "Comment": "v8.0.0",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/validation", "ImportPath": "github.com/Azure/go-autorest/autorest/validation",
"Comment": "v7.2.3", "Comment": "v8.0.0",
"Rev": "d7c034a8af24eda120dd6460bfcd6d9ed14e43ca" "Rev": "58f6f26e200fa5dfb40c9cd1c83f3e2c860d779d"
}, },
{ {
"ImportPath": "github.com/MakeNowJust/heredoc", "ImportPath": "github.com/MakeNowJust/heredoc",

View File

@ -1,30 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"systemstat.go",
"systemstat_linux.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,27 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["autoneg.go"],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,32 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["metadata.go"],
tags = ["automanaged"],
deps = [
"//vendor/cloud.google.com/go/internal:go_default_library",
"//vendor/golang.org/x/net/context:go_default_library",
"//vendor/golang.org/x/net/context/ctxhttp:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,27 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["cloud.go"],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,47 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"availabilitysets.go",
"client.go",
"models.go",
"usageoperations.go",
"version.go",
"virtualmachineextensionimages.go",
"virtualmachineextensions.go",
"virtualmachineimages.go",
"virtualmachines.go",
"virtualmachinescalesets.go",
"virtualmachinescalesetvms.go",
"virtualmachinesizes.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/date:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/validation:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

68
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/availabilitysets.go generated vendored Normal file → Executable file
View File

@ -14,14 +14,13 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
@ -44,26 +43,21 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string)
// CreateOrUpdate create or update an availability set. // CreateOrUpdate create or update an availability set.
// //
// resourceGroupName is the name of the resource group. name is the name of // resourceGroupName is the name of the resource group. name is the name of the
// the availability set. parameters is parameters supplied to the Create // availability set. parameters is parameters supplied to the Create
// Availability Set operation. // Availability Set operation.
func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters AvailabilitySet) (result AvailabilitySet, err error) { func (client AvailabilitySetsClient) CreateOrUpdate(resourceGroupName string, name string, parameters AvailabilitySet) (result AvailabilitySet, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.AvailabilitySetProperties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AvailabilitySetProperties.Statuses", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters) req, err := client.CreateOrUpdatePreparer(resourceGroupName, name, parameters)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
@ -82,8 +76,9 @@ func (client AvailabilitySetsClient) CreateOrUpdatePreparer(resourceGroupName st
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -119,16 +114,18 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response
// //
// resourceGroupName is the name of the resource group. availabilitySetName is // resourceGroupName is the name of the resource group. availabilitySetName is
// the name of the availability set. // the name of the availability set.
func (client AvailabilitySetsClient) Delete(resourceGroupName string, availabilitySetName string) (result autorest.Response, err error) { func (client AvailabilitySetsClient) Delete(resourceGroupName string, availabilitySetName string) (result OperationStatusResponse, err error) {
req, err := client.DeletePreparer(resourceGroupName, availabilitySetName) req, err := client.DeletePreparer(resourceGroupName, availabilitySetName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
@ -147,8 +144,9 @@ func (client AvailabilitySetsClient) DeletePreparer(resourceGroupName string, av
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -167,13 +165,14 @@ func (client AvailabilitySetsClient) DeleteSender(req *http.Request) (*http.Resp
// DeleteResponder handles the response to the Delete request. The method always // DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -184,13 +183,15 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul
func (client AvailabilitySetsClient) Get(resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) { func (client AvailabilitySetsClient) Get(resourceGroupName string, availabilitySetName string) (result AvailabilitySet, err error) {
req, err := client.GetPreparer(resourceGroupName, availabilitySetName) req, err := client.GetPreparer(resourceGroupName, availabilitySetName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -209,8 +210,9 @@ func (client AvailabilitySetsClient) GetPreparer(resourceGroupName string, avail
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -246,13 +248,15 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A
func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) { func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -270,8 +274,9 @@ func (client AvailabilitySetsClient) ListPreparer(resourceGroupName string) (*ht
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -309,13 +314,15 @@ func (client AvailabilitySetsClient) ListResponder(resp *http.Response) (result
func (client AvailabilitySetsClient) ListAvailableSizes(resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) { func (client AvailabilitySetsClient) ListAvailableSizes(resourceGroupName string, availabilitySetName string) (result VirtualMachineSizeListResult, err error) {
req, err := client.ListAvailableSizesPreparer(resourceGroupName, availabilitySetName) req, err := client.ListAvailableSizesPreparer(resourceGroupName, availabilitySetName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", nil, "Failure preparing request")
return
} }
resp, err := client.ListAvailableSizesSender(req) resp, err := client.ListAvailableSizesSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "ListAvailableSizes", resp, "Failure sending request")
return
} }
result, err = client.ListAvailableSizesResponder(resp) result, err = client.ListAvailableSizesResponder(resp)
@ -334,8 +341,9 @@ func (client AvailabilitySetsClient) ListAvailableSizesPreparer(resourceGroupNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

9
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/client.go generated vendored Normal file → Executable file
View File

@ -1,5 +1,5 @@
// Package compute implements the Azure ARM Compute service API version // Package compute implements the Azure ARM Compute service API version
// 2016-03-30. // 2016-04-30-preview.
// //
// The Compute Management Client. // The Compute Management Client.
package compute package compute
@ -18,7 +18,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -27,9 +27,6 @@ import (
) )
const ( const (
// APIVersion is the version of the Compute
APIVersion = "2016-03-30"
// DefaultBaseURI is the default URI used for the service Compute // DefaultBaseURI is the default URI used for the service Compute
DefaultBaseURI = "https://management.azure.com" DefaultBaseURI = "https://management.azure.com"
) )
@ -38,7 +35,6 @@ const (
type ManagementClient struct { type ManagementClient struct {
autorest.Client autorest.Client
BaseURI string BaseURI string
APIVersion string
SubscriptionID string SubscriptionID string
} }
@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{ return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()), Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI, BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID, SubscriptionID: subscriptionID,
} }
} }

194
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/models.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -66,6 +66,19 @@ const (
InstanceView InstanceViewTypes = "instanceView" InstanceView InstanceViewTypes = "instanceView"
) )
// OperatingSystemStateTypes enumerates the values for operating system state
// types.
type OperatingSystemStateTypes string
const (
// Generalized specifies the generalized state for operating system state
// types.
Generalized OperatingSystemStateTypes = "Generalized"
// Specialized specifies the specialized state for operating system state
// types.
Specialized OperatingSystemStateTypes = "Specialized"
)
// OperatingSystemTypes enumerates the values for operating system types. // OperatingSystemTypes enumerates the values for operating system types.
type OperatingSystemTypes string type OperatingSystemTypes string
@ -94,6 +107,15 @@ const (
HTTPS ProtocolTypes = "Https" HTTPS ProtocolTypes = "Https"
) )
// ResourceIdentityType enumerates the values for resource identity type.
type ResourceIdentityType string
const (
// SystemAssigned specifies the system assigned state for resource identity
// type.
SystemAssigned ResourceIdentityType = "SystemAssigned"
)
// SettingNames enumerates the values for setting names. // SettingNames enumerates the values for setting names.
type SettingNames string type SettingNames string
@ -117,6 +139,16 @@ const (
Warning StatusLevelTypes = "Warning" Warning StatusLevelTypes = "Warning"
) )
// StorageAccountTypes enumerates the values for storage account types.
type StorageAccountTypes string
const (
// PremiumLRS specifies the premium lrs state for storage account types.
PremiumLRS StorageAccountTypes = "Premium_LRS"
// StandardLRS specifies the standard lrs state for storage account types.
StandardLRS StorageAccountTypes = "Standard_LRS"
)
// UpgradeMode enumerates the values for upgrade mode. // UpgradeMode enumerates the values for upgrade mode.
type UpgradeMode string type UpgradeMode string
@ -127,8 +159,8 @@ const (
Manual UpgradeMode = "Manual" Manual UpgradeMode = "Manual"
) )
// VirtualMachineScaleSetSkuScaleType enumerates the values for virtual // VirtualMachineScaleSetSkuScaleType enumerates the values for virtual machine
// machine scale set sku scale type. // scale set sku scale type.
type VirtualMachineScaleSetSkuScaleType string type VirtualMachineScaleSetSkuScaleType string
const ( const (
@ -335,8 +367,8 @@ const (
// AdditionalUnattendContent is additional XML formatted information that can // AdditionalUnattendContent is additional XML formatted information that can
// be included in the Unattend.xml file, which is used by Windows Setup. // be included in the Unattend.xml file, which is used by Windows Setup.
// Contents are defined by setting name, component name, and the pass in // Contents are defined by setting name, component name, and the pass in which
// which the content is a applied. // the content is a applied.
type AdditionalUnattendContent struct { type AdditionalUnattendContent struct {
PassName PassNames `json:"passName,omitempty"` PassName PassNames `json:"passName,omitempty"`
ComponentName ComponentNames `json:"componentName,omitempty"` ComponentName ComponentNames `json:"componentName,omitempty"`
@ -374,6 +406,7 @@ type AvailabilitySet struct {
Location *string `json:"location,omitempty"` Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
*AvailabilitySetProperties `json:"properties,omitempty"` *AvailabilitySetProperties `json:"properties,omitempty"`
Sku *Sku `json:"sku,omitempty"`
} }
// AvailabilitySetListResult is the List Availability Set operation response. // AvailabilitySetListResult is the List Availability Set operation response.
@ -388,6 +421,7 @@ type AvailabilitySetProperties struct {
PlatformFaultDomainCount *int32 `json:"platformFaultDomainCount,omitempty"` PlatformFaultDomainCount *int32 `json:"platformFaultDomainCount,omitempty"`
VirtualMachines *[]SubResource `json:"virtualMachines,omitempty"` VirtualMachines *[]SubResource `json:"virtualMachines,omitempty"`
Statuses *[]InstanceViewStatus `json:"statuses,omitempty"` Statuses *[]InstanceViewStatus `json:"statuses,omitempty"`
Managed *bool `json:"managed,omitempty"`
} }
// BootDiagnostics is describes Boot Diagnostics. // BootDiagnostics is describes Boot Diagnostics.
@ -412,6 +446,7 @@ type DataDisk struct {
Caching CachingTypes `json:"caching,omitempty"` Caching CachingTypes `json:"caching,omitempty"`
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"` CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
} }
// DataDiskImage is contains the data disk images information. // DataDiskImage is contains the data disk images information.
@ -442,14 +477,79 @@ type HardwareProfile struct {
VMSize VirtualMachineSizeTypes `json:"vmSize,omitempty"` VMSize VirtualMachineSizeTypes `json:"vmSize,omitempty"`
} }
// Image is describes an Image.
type Image struct {
autorest.Response `json:"-"`
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"`
*ImageProperties `json:"properties,omitempty"`
}
// ImageDataDisk is describes a data disk.
type ImageDataDisk struct {
Lun *int32 `json:"lun,omitempty"`
Snapshot *SubResource `json:"snapshot,omitempty"`
ManagedDisk *SubResource `json:"managedDisk,omitempty"`
BlobURI *string `json:"blobUri,omitempty"`
Caching CachingTypes `json:"caching,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
}
// ImageListResult is the List Image operation response.
type ImageListResult struct {
autorest.Response `json:"-"`
Value *[]Image `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// ImageListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client ImageListResult) ImageListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// ImageOSDisk is describes an Operating System disk.
type ImageOSDisk struct {
OsType OperatingSystemTypes `json:"osType,omitempty"`
OsState OperatingSystemStateTypes `json:"osState,omitempty"`
Snapshot *SubResource `json:"snapshot,omitempty"`
ManagedDisk *SubResource `json:"managedDisk,omitempty"`
BlobURI *string `json:"blobUri,omitempty"`
Caching CachingTypes `json:"caching,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
}
// ImageProperties is describes the properties of an Image.
type ImageProperties struct {
SourceVirtualMachine *SubResource `json:"sourceVirtualMachine,omitempty"`
StorageProfile *ImageStorageProfile `json:"storageProfile,omitempty"`
ProvisioningState *string `json:"provisioningState,omitempty"`
}
// ImageReference is the image reference. // ImageReference is the image reference.
type ImageReference struct { type ImageReference struct {
ID *string `json:"id,omitempty"`
Publisher *string `json:"publisher,omitempty"` Publisher *string `json:"publisher,omitempty"`
Offer *string `json:"offer,omitempty"` Offer *string `json:"offer,omitempty"`
Sku *string `json:"sku,omitempty"` Sku *string `json:"sku,omitempty"`
Version *string `json:"version,omitempty"` Version *string `json:"version,omitempty"`
} }
// ImageStorageProfile is describes a storage profile.
type ImageStorageProfile struct {
OsDisk *ImageOSDisk `json:"osDisk,omitempty"`
DataDisks *[]ImageDataDisk `json:"dataDisks,omitempty"`
}
// InnerError is inner error details. // InnerError is inner error details.
type InnerError struct { type InnerError struct {
Exceptiontype *string `json:"exceptiontype,omitempty"` Exceptiontype *string `json:"exceptiontype,omitempty"`
@ -520,6 +620,12 @@ type LongRunningOperationProperties struct {
Output *map[string]interface{} `json:"output,omitempty"` Output *map[string]interface{} `json:"output,omitempty"`
} }
// ManagedDiskParameters is the parameters of a managed disk.
type ManagedDiskParameters struct {
ID *string `json:"id,omitempty"`
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
}
// NetworkInterfaceReference is describes a network interface reference. // NetworkInterfaceReference is describes a network interface reference.
type NetworkInterfaceReference struct { type NetworkInterfaceReference struct {
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
@ -537,6 +643,16 @@ type NetworkProfile struct {
NetworkInterfaces *[]NetworkInterfaceReference `json:"networkInterfaces,omitempty"` NetworkInterfaces *[]NetworkInterfaceReference `json:"networkInterfaces,omitempty"`
} }
// OperationStatusResponse is operation status response
type OperationStatusResponse struct {
autorest.Response `json:"-"`
Name *string `json:"name,omitempty"`
Status *string `json:"status,omitempty"`
StartTime *date.Time `json:"startTime,omitempty"`
EndTime *date.Time `json:"endTime,omitempty"`
Error *APIError `json:"error,omitempty"`
}
// OSDisk is describes an Operating System disk. // OSDisk is describes an Operating System disk.
type OSDisk struct { type OSDisk struct {
OsType OperatingSystemTypes `json:"osType,omitempty"` OsType OperatingSystemTypes `json:"osType,omitempty"`
@ -547,6 +663,7 @@ type OSDisk struct {
Caching CachingTypes `json:"caching,omitempty"` Caching CachingTypes `json:"caching,omitempty"`
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"` CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"` DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
ManagedDisk *ManagedDiskParameters `json:"managedDisk,omitempty"`
} }
// OSDiskImage is contains the os disk image information. // OSDiskImage is contains the os disk image information.
@ -581,7 +698,7 @@ type PurchasePlan struct {
Product *string `json:"product,omitempty"` Product *string `json:"product,omitempty"`
} }
// Resource is the resource model definition. // Resource is the Resource model definition.
type Resource struct { type Resource struct {
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
@ -621,6 +738,11 @@ type SubResource struct {
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
} }
// SubResourceReadOnly is
type SubResourceReadOnly struct {
ID *string `json:"id,omitempty"`
}
// UpgradePolicy is describes an upgrade policy - automatic or manual. // UpgradePolicy is describes an upgrade policy - automatic or manual.
type UpgradePolicy struct { type UpgradePolicy struct {
Mode UpgradeMode `json:"mode,omitempty"` Mode UpgradeMode `json:"mode,omitempty"`
@ -640,8 +762,8 @@ type UsageName struct {
LocalizedValue *string `json:"localizedValue,omitempty"` LocalizedValue *string `json:"localizedValue,omitempty"`
} }
// VaultCertificate is describes a single certificate reference in a Key // VaultCertificate is describes a single certificate reference in a Key Vault,
// Vault, and where the certificate should reside on the VM. // and where the certificate should reside on the VM.
type VaultCertificate struct { type VaultCertificate struct {
CertificateURL *string `json:"certificateUrl,omitempty"` CertificateURL *string `json:"certificateUrl,omitempty"`
CertificateStore *string `json:"certificateStore,omitempty"` CertificateStore *string `json:"certificateStore,omitempty"`
@ -670,10 +792,11 @@ type VirtualMachine struct {
Plan *Plan `json:"plan,omitempty"` Plan *Plan `json:"plan,omitempty"`
*VirtualMachineProperties `json:"properties,omitempty"` *VirtualMachineProperties `json:"properties,omitempty"`
Resources *[]VirtualMachineExtension `json:"resources,omitempty"` Resources *[]VirtualMachineExtension `json:"resources,omitempty"`
Identity *VirtualMachineIdentity `json:"identity,omitempty"`
} }
// VirtualMachineAgentInstanceView is the instance view of the VM Agent // VirtualMachineAgentInstanceView is the instance view of the VM Agent running
// running on the virtual machine. // on the virtual machine.
type VirtualMachineAgentInstanceView struct { type VirtualMachineAgentInstanceView struct {
VMAgentVersion *string `json:"vmAgentVersion,omitempty"` VMAgentVersion *string `json:"vmAgentVersion,omitempty"`
ExtensionHandlers *[]VirtualMachineExtensionHandlerInstanceView `json:"extensionHandlers,omitempty"` ExtensionHandlers *[]VirtualMachineExtensionHandlerInstanceView `json:"extensionHandlers,omitempty"`
@ -711,8 +834,8 @@ type VirtualMachineExtension struct {
*VirtualMachineExtensionProperties `json:"properties,omitempty"` *VirtualMachineExtensionProperties `json:"properties,omitempty"`
} }
// VirtualMachineExtensionHandlerInstanceView is the instance view of a // VirtualMachineExtensionHandlerInstanceView is the instance view of a virtual
// virtual machine extension handler. // machine extension handler.
type VirtualMachineExtensionHandlerInstanceView struct { type VirtualMachineExtensionHandlerInstanceView struct {
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"` TypeHandlerVersion *string `json:"typeHandlerVersion,omitempty"`
@ -764,6 +887,13 @@ type VirtualMachineExtensionProperties struct {
InstanceView *VirtualMachineExtensionInstanceView `json:"instanceView,omitempty"` InstanceView *VirtualMachineExtensionInstanceView `json:"instanceView,omitempty"`
} }
// VirtualMachineIdentity is identity for the virtual machine.
type VirtualMachineIdentity struct {
PrincipalID *string `json:"principalId,omitempty"`
TenantID *string `json:"tenantId,omitempty"`
Type ResourceIdentityType `json:"type,omitempty"`
}
// VirtualMachineImage is describes a Virtual Machine Image. // VirtualMachineImage is describes a Virtual Machine Image.
type VirtualMachineImage struct { type VirtualMachineImage struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
@ -844,7 +974,20 @@ type VirtualMachineScaleSet struct {
Location *string `json:"location,omitempty"` Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
Sku *Sku `json:"sku,omitempty"` Sku *Sku `json:"sku,omitempty"`
Plan *Plan `json:"plan,omitempty"`
*VirtualMachineScaleSetProperties `json:"properties,omitempty"` *VirtualMachineScaleSetProperties `json:"properties,omitempty"`
Identity *VirtualMachineScaleSetIdentity `json:"identity,omitempty"`
}
// VirtualMachineScaleSetDataDisk is describes a virtual machine scale set data
// disk.
type VirtualMachineScaleSetDataDisk struct {
Name *string `json:"name,omitempty"`
Lun *int32 `json:"lun,omitempty"`
Caching CachingTypes `json:"caching,omitempty"`
CreateOption DiskCreateOptionTypes `json:"createOption,omitempty"`
DiskSizeGB *int32 `json:"diskSizeGB,omitempty"`
ManagedDisk *VirtualMachineScaleSetManagedDiskParameters `json:"managedDisk,omitempty"`
} }
// VirtualMachineScaleSetExtension is describes a Virtual Machine Scale Set // VirtualMachineScaleSetExtension is describes a Virtual Machine Scale Set
@ -873,8 +1016,16 @@ type VirtualMachineScaleSetExtensionProperties struct {
ProvisioningState *string `json:"provisioningState,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"`
} }
// VirtualMachineScaleSetInstanceView is the instance view of a virtual // VirtualMachineScaleSetIdentity is identity for the virtual machine scale
// machine scale set. // set.
type VirtualMachineScaleSetIdentity struct {
PrincipalID *string `json:"principalId,omitempty"`
TenantID *string `json:"tenantId,omitempty"`
Type ResourceIdentityType `json:"type,omitempty"`
}
// VirtualMachineScaleSetInstanceView is the instance view of a virtual machine
// scale set.
type VirtualMachineScaleSetInstanceView struct { type VirtualMachineScaleSetInstanceView struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
VirtualMachine *VirtualMachineScaleSetInstanceViewStatusesSummary `json:"virtualMachine,omitempty"` VirtualMachine *VirtualMachineScaleSetInstanceViewStatusesSummary `json:"virtualMachine,omitempty"`
@ -965,6 +1116,12 @@ func (client VirtualMachineScaleSetListWithLinkResult) VirtualMachineScaleSetLis
autorest.WithBaseURL(to.String(client.NextLink))) autorest.WithBaseURL(to.String(client.NextLink)))
} }
// VirtualMachineScaleSetManagedDiskParameters is describes the parameters of a
// ScaleSet managed disk.
type VirtualMachineScaleSetManagedDiskParameters struct {
StorageAccountType StorageAccountTypes `json:"storageAccountType,omitempty"`
}
// VirtualMachineScaleSetNetworkConfiguration is describes a virtual machine // VirtualMachineScaleSetNetworkConfiguration is describes a virtual machine
// scale set network profile's network configurations. // scale set network profile's network configurations.
type VirtualMachineScaleSetNetworkConfiguration struct { type VirtualMachineScaleSetNetworkConfiguration struct {
@ -995,6 +1152,7 @@ type VirtualMachineScaleSetOSDisk struct {
OsType OperatingSystemTypes `json:"osType,omitempty"` OsType OperatingSystemTypes `json:"osType,omitempty"`
Image *VirtualHardDisk `json:"image,omitempty"` Image *VirtualHardDisk `json:"image,omitempty"`
VhdContainers *[]string `json:"vhdContainers,omitempty"` VhdContainers *[]string `json:"vhdContainers,omitempty"`
ManagedDisk *VirtualMachineScaleSetManagedDiskParameters `json:"managedDisk,omitempty"`
} }
// VirtualMachineScaleSetOSProfile is describes a virtual machine scale set OS // VirtualMachineScaleSetOSProfile is describes a virtual machine scale set OS
@ -1016,6 +1174,7 @@ type VirtualMachineScaleSetProperties struct {
VirtualMachineProfile *VirtualMachineScaleSetVMProfile `json:"virtualMachineProfile,omitempty"` VirtualMachineProfile *VirtualMachineScaleSetVMProfile `json:"virtualMachineProfile,omitempty"`
ProvisioningState *string `json:"provisioningState,omitempty"` ProvisioningState *string `json:"provisioningState,omitempty"`
Overprovision *bool `json:"overprovision,omitempty"` Overprovision *bool `json:"overprovision,omitempty"`
SinglePlacementGroup *bool `json:"singlePlacementGroup,omitempty"`
} }
// VirtualMachineScaleSetSku is describes an available virtual machine scale // VirtualMachineScaleSetSku is describes an available virtual machine scale
@ -1039,6 +1198,7 @@ type VirtualMachineScaleSetSkuCapacity struct {
type VirtualMachineScaleSetStorageProfile struct { type VirtualMachineScaleSetStorageProfile struct {
ImageReference *ImageReference `json:"imageReference,omitempty"` ImageReference *ImageReference `json:"imageReference,omitempty"`
OsDisk *VirtualMachineScaleSetOSDisk `json:"osDisk,omitempty"` OsDisk *VirtualMachineScaleSetOSDisk `json:"osDisk,omitempty"`
DataDisks *[]VirtualMachineScaleSetDataDisk `json:"dataDisks,omitempty"`
} }
// VirtualMachineScaleSetVM is describes a virtual machine scale set virtual // VirtualMachineScaleSetVM is describes a virtual machine scale set virtual
@ -1088,10 +1248,11 @@ type VirtualMachineScaleSetVMInstanceView struct {
Extensions *[]VirtualMachineExtensionInstanceView `json:"extensions,omitempty"` Extensions *[]VirtualMachineExtensionInstanceView `json:"extensions,omitempty"`
BootDiagnostics *BootDiagnosticsInstanceView `json:"bootDiagnostics,omitempty"` BootDiagnostics *BootDiagnosticsInstanceView `json:"bootDiagnostics,omitempty"`
Statuses *[]InstanceViewStatus `json:"statuses,omitempty"` Statuses *[]InstanceViewStatus `json:"statuses,omitempty"`
PlacementGroupID *string `json:"placementGroupId,omitempty"`
} }
// VirtualMachineScaleSetVMListResult is the List Virtual Machine Scale Set // VirtualMachineScaleSetVMListResult is the List Virtual Machine Scale Set VMs
// VMs operation response. // operation response.
type VirtualMachineScaleSetVMListResult struct { type VirtualMachineScaleSetVMListResult struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
Value *[]VirtualMachineScaleSetVM `json:"value,omitempty"` Value *[]VirtualMachineScaleSetVM `json:"value,omitempty"`
@ -1123,6 +1284,7 @@ type VirtualMachineScaleSetVMProfile struct {
// machine scale set virtual machine. // machine scale set virtual machine.
type VirtualMachineScaleSetVMProperties struct { type VirtualMachineScaleSetVMProperties struct {
LatestModelApplied *bool `json:"latestModelApplied,omitempty"` LatestModelApplied *bool `json:"latestModelApplied,omitempty"`
VMID *string `json:"vmId,omitempty"`
InstanceView *VirtualMachineInstanceView `json:"instanceView,omitempty"` InstanceView *VirtualMachineInstanceView `json:"instanceView,omitempty"`
HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"` HardwareProfile *HardwareProfile `json:"hardwareProfile,omitempty"`
StorageProfile *StorageProfile `json:"storageProfile,omitempty"` StorageProfile *StorageProfile `json:"storageProfile,omitempty"`

View File

@ -1,136 +0,0 @@
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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// UsageOperationsClient is the the Compute Management Client.
type UsageOperationsClient struct {
ManagementClient
}
// NewUsageOperationsClient creates an instance of the UsageOperationsClient
// client.
func NewUsageOperationsClient(subscriptionID string) UsageOperationsClient {
return NewUsageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewUsageOperationsClientWithBaseURI creates an instance of the
// UsageOperationsClient client.
func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) UsageOperationsClient {
return UsageOperationsClient{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.
//
// location is the location for which resource usage is queried.
func (client UsageOperationsClient) List(location string) (result ListUsagesResult, err error) {
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.NewErrorWithValidationError(err, "compute.UsageOperationsClient", "List")
}
req, err := client.ListPreparer(location)
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing request")
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure sending request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client UsageOperationsClient) ListPreparer(location string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"location": autorest.Encode("path", location),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.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{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client UsageOperationsClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client UsageOperationsClient) 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 UsageOperationsClient) ListNextResults(lastResults ListUsagesResult) (result ListUsagesResult, err error) {
req, err := lastResults.ListUsagesResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", 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.UsageOperationsClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to next results request")
}
return
}

20
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/version.go generated vendored Normal file → Executable file
View File

@ -14,30 +14,16 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests. // UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string { func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "compute", "2016-03-30") return "Azure-SDK-For-Go/v10.0.2-beta arm-compute/2016-04-30-preview"
} }
// Version returns the semantic version (see http://semver.org) of the client. // Version returns the semantic version (see http://semver.org) of the client.
func Version() string { func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag) return "v10.0.2-beta"
} }

View File

@ -14,7 +14,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -35,8 +35,8 @@ func NewVirtualMachineExtensionImagesClient(subscriptionID string) VirtualMachin
return NewVirtualMachineExtensionImagesClientWithBaseURI(DefaultBaseURI, subscriptionID) return NewVirtualMachineExtensionImagesClientWithBaseURI(DefaultBaseURI, subscriptionID)
} }
// NewVirtualMachineExtensionImagesClientWithBaseURI creates an instance of // NewVirtualMachineExtensionImagesClientWithBaseURI creates an instance of the
// the VirtualMachineExtensionImagesClient client. // VirtualMachineExtensionImagesClient client.
func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineExtensionImagesClient { func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscriptionID string) VirtualMachineExtensionImagesClient {
return VirtualMachineExtensionImagesClient{NewWithBaseURI(baseURI, subscriptionID)} return VirtualMachineExtensionImagesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
@ -46,13 +46,15 @@ func NewVirtualMachineExtensionImagesClientWithBaseURI(baseURI string, subscript
func (client VirtualMachineExtensionImagesClient) Get(location string, publisherName string, typeParameter string, version string) (result VirtualMachineExtensionImage, err error) { func (client VirtualMachineExtensionImagesClient) Get(location string, publisherName string, typeParameter string, version string) (result VirtualMachineExtensionImage, err error) {
req, err := client.GetPreparer(location, publisherName, typeParameter, version) req, err := client.GetPreparer(location, publisherName, typeParameter, version)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -73,8 +75,9 @@ func (client VirtualMachineExtensionImagesClient) GetPreparer(location string, p
"version": autorest.Encode("path", version), "version": autorest.Encode("path", version),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -109,13 +112,15 @@ func (client VirtualMachineExtensionImagesClient) GetResponder(resp *http.Respon
func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) { func (client VirtualMachineExtensionImagesClient) ListTypes(location string, publisherName string) (result ListVirtualMachineExtensionImage, err error) {
req, err := client.ListTypesPreparer(location, publisherName) req, err := client.ListTypesPreparer(location, publisherName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", nil, "Failure preparing request")
return
} }
resp, err := client.ListTypesSender(req) resp, err := client.ListTypesSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListTypes", resp, "Failure sending request")
return
} }
result, err = client.ListTypesResponder(resp) result, err = client.ListTypesResponder(resp)
@ -134,8 +139,9 @@ func (client VirtualMachineExtensionImagesClient) ListTypesPreparer(location str
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -171,13 +177,15 @@ func (client VirtualMachineExtensionImagesClient) ListTypesResponder(resp *http.
func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) { func (client VirtualMachineExtensionImagesClient) ListVersions(location string, publisherName string, typeParameter string, filter string, top *int32, orderby string) (result ListVirtualMachineExtensionImage, err error) {
req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderby) req, err := client.ListVersionsPreparer(location, publisherName, typeParameter, filter, top, orderby)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", nil, "Failure preparing request")
return
} }
resp, err := client.ListVersionsSender(req) resp, err := client.ListVersionsSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionImagesClient", "ListVersions", resp, "Failure sending request")
return
} }
result, err = client.ListVersionsResponder(resp) result, err = client.ListVersionsResponder(resp)
@ -197,8 +205,9 @@ func (client VirtualMachineExtensionImagesClient) ListVersionsPreparer(location
"type": autorest.Encode("path", typeParameter), "type": autorest.Encode("path", typeParameter),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(filter) > 0 { if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter) queryParameters["$filter"] = autorest.Encode("query", filter)

133
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineextensions.go generated vendored Normal file → Executable file
View File

@ -14,14 +14,13 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
@ -47,49 +46,56 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID
// channel argument. The channel will be used to cancel polling and any // channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmName is the name of // resourceGroupName is the name of the resource group. VMName is the name of
// the virtual machine where the extension should be create or updated. // the virtual machine where the extension should be create or updated.
// vmExtensionName is the name of the virtual machine extension. // VMExtensionName is the name of the virtual machine extension.
// extensionParameters is parameters supplied to the Create Virtual Machine // extensionParameters is parameters supplied to the Create Virtual Machine
// Extension operation. // Extension operation.
func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineExtensionsClient) CreateOrUpdate(resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (<-chan VirtualMachineExtension, <-chan error) {
if err := validation.Validate([]validation.Validation{ resultChan := make(chan VirtualMachineExtension, 1)
{TargetValue: extensionParameters, errChan := make(chan error, 1)
Constraints: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties", Name: validation.Null, Rule: false, go func() {
Chain: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil { var err error
return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate") var result VirtualMachineExtension
} defer func() {
resultChan <- result
req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel) errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, VMName, VMExtensionName, extensionParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(resourceGroupName string, vmName string, vmExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineExtensionsClient) CreateOrUpdatePreparer(resourceGroupName string, VMName string, VMExtensionName string, extensionParameters VirtualMachineExtension, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmExtensionName": autorest.Encode("path", vmExtensionName), "vmExtensionName": autorest.Encode("path", VMExtensionName),
"vmName": autorest.Encode("path", vmName), "vmName": autorest.Encode("path", VMName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -112,55 +118,70 @@ func (client VirtualMachineExtensionsClient) CreateOrUpdateSender(req *http.Requ
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineExtensionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualMachineExtension, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete the operation to delete the extension. This method may poll for // Delete the operation to delete the extension. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. vmName is the name of // resourceGroupName is the name of the resource group. VMName is the name of
// the virtual machine where the extension should be deleted. vmExtensionName // the virtual machine where the extension should be deleted. VMExtensionName
// is the name of the virtual machine extension. // is the name of the virtual machine extension.
func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineExtensionsClient) Delete(resourceGroupName string, VMName string, VMExtensionName string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.DeletePreparer(resourceGroupName, vmName, vmExtensionName, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, VMName, VMExtensionName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
func (client VirtualMachineExtensionsClient) DeletePreparer(resourceGroupName string, vmName string, vmExtensionName string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineExtensionsClient) DeletePreparer(resourceGroupName string, VMName string, VMExtensionName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmExtensionName": autorest.Encode("path", vmExtensionName), "vmExtensionName": autorest.Encode("path", VMExtensionName),
"vmName": autorest.Encode("path", vmName), "vmName": autorest.Encode("path", VMName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -181,32 +202,35 @@ func (client VirtualMachineExtensionsClient) DeleteSender(req *http.Request) (*h
// DeleteResponder handles the response to the Delete request. The method always // DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineExtensionsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Get the operation to get the extension. // Get the operation to get the extension.
// //
// resourceGroupName is the name of the resource group. vmName is the name of // resourceGroupName is the name of the resource group. VMName is the name of
// the virtual machine containing the extension. vmExtensionName is the name // the virtual machine containing the extension. VMExtensionName is the name of
// of the virtual machine extension. expand is the expand expression to apply // the virtual machine extension. expand is the expand expression to apply on
// on the operation. // the operation.
func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmName string, vmExtensionName string, expand string) (result VirtualMachineExtension, err error) { func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, VMName string, VMExtensionName string, expand string) (result VirtualMachineExtension, err error) {
req, err := client.GetPreparer(resourceGroupName, vmName, vmExtensionName, expand) req, err := client.GetPreparer(resourceGroupName, VMName, VMExtensionName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -218,16 +242,17 @@ func (client VirtualMachineExtensionsClient) Get(resourceGroupName string, vmNam
} }
// GetPreparer prepares the Get request. // GetPreparer prepares the Get request.
func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, vmName string, vmExtensionName string, expand string) (*http.Request, error) { func (client VirtualMachineExtensionsClient) GetPreparer(resourceGroupName string, VMName string, VMExtensionName string, expand string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmExtensionName": autorest.Encode("path", vmExtensionName), "vmExtensionName": autorest.Encode("path", VMExtensionName),
"vmName": autorest.Encode("path", vmName), "vmName": autorest.Encode("path", VMName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)

47
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachineimages.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -49,13 +49,15 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str
func (client VirtualMachineImagesClient) Get(location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) { func (client VirtualMachineImagesClient) Get(location string, publisherName string, offer string, skus string, version string) (result VirtualMachineImage, err error) {
req, err := client.GetPreparer(location, publisherName, offer, skus, version) req, err := client.GetPreparer(location, publisherName, offer, skus, version)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -77,8 +79,9 @@ func (client VirtualMachineImagesClient) GetPreparer(location string, publisherN
"version": autorest.Encode("path", version), "version": autorest.Encode("path", version),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -117,13 +120,15 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu
func (client VirtualMachineImagesClient) List(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) { func (client VirtualMachineImagesClient) List(location string, publisherName string, offer string, skus string, filter string, top *int32, orderby string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListPreparer(location, publisherName, offer, skus, filter, top, orderby) req, err := client.ListPreparer(location, publisherName, offer, skus, filter, top, orderby)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -144,8 +149,9 @@ func (client VirtualMachineImagesClient) ListPreparer(location string, publisher
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(filter) > 0 { if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter) queryParameters["$filter"] = autorest.Encode("query", filter)
@ -192,13 +198,15 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res
func (client VirtualMachineImagesClient) ListOffers(location string, publisherName string) (result ListVirtualMachineImageResource, err error) { func (client VirtualMachineImagesClient) ListOffers(location string, publisherName string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListOffersPreparer(location, publisherName) req, err := client.ListOffersPreparer(location, publisherName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", nil, "Failure preparing request")
return
} }
resp, err := client.ListOffersSender(req) resp, err := client.ListOffersSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListOffers", resp, "Failure sending request")
return
} }
result, err = client.ListOffersResponder(resp) result, err = client.ListOffersResponder(resp)
@ -217,8 +225,9 @@ func (client VirtualMachineImagesClient) ListOffersPreparer(location string, pub
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -255,13 +264,15 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response
func (client VirtualMachineImagesClient) ListPublishers(location string) (result ListVirtualMachineImageResource, err error) { func (client VirtualMachineImagesClient) ListPublishers(location string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListPublishersPreparer(location) req, err := client.ListPublishersPreparer(location)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", nil, "Failure preparing request")
return
} }
resp, err := client.ListPublishersSender(req) resp, err := client.ListPublishersSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListPublishers", resp, "Failure sending request")
return
} }
result, err = client.ListPublishersResponder(resp) result, err = client.ListPublishersResponder(resp)
@ -279,8 +290,9 @@ func (client VirtualMachineImagesClient) ListPublishersPreparer(location string)
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -318,13 +330,15 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp
func (client VirtualMachineImagesClient) ListSkus(location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) { func (client VirtualMachineImagesClient) ListSkus(location string, publisherName string, offer string) (result ListVirtualMachineImageResource, err error) {
req, err := client.ListSkusPreparer(location, publisherName, offer) req, err := client.ListSkusPreparer(location, publisherName, offer)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", nil, "Failure preparing request")
return
} }
resp, err := client.ListSkusSender(req) resp, err := client.ListSkusSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineImagesClient", "ListSkus", resp, "Failure sending request")
return
} }
result, err = client.ListSkusResponder(resp) result, err = client.ListSkusResponder(resp)
@ -344,8 +358,9 @@ func (client VirtualMachineImagesClient) ListSkusPreparer(location string, publi
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

564
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachines.go generated vendored Normal file → Executable file

File diff suppressed because it is too large Load Diff

647
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesets.go generated vendored Normal file → Executable file

File diff suppressed because it is too large Load Diff

410
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinescalesetvms.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -42,46 +42,60 @@ func NewVirtualMachineScaleSetVMsClientWithBaseURI(baseURI string, subscriptionI
} }
// Deallocate deallocates a specific virtual machine in a VM scale set. Shuts // Deallocate deallocates a specific virtual machine in a VM scale set. Shuts
// down the virtual machine and releases the compute resources it uses. You // down the virtual machine and releases the compute resources it uses. You are
// are not billed for the compute resources of this virtual machine once it // not billed for the compute resources of this virtual machine once it is
// is deallocated. This method may poll for completion. Polling can be // deallocated. This method may poll for completion. Polling can be canceled by
// canceled by passing the cancel channel argument. The channel will be used // passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) Deallocate(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.DeallocatePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeallocatePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", nil, "Failure preparing request")
return
} }
resp, err := client.DeallocateSender(req) resp, err := client.DeallocateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure sending request")
return
} }
result, err = client.DeallocateResponder(resp) result, err = client.DeallocateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Deallocate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeallocatePreparer prepares the Deallocate request. // DeallocatePreparer prepares the Deallocate request.
func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) DeallocatePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -102,13 +116,14 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateSender(req *http.Request
// DeallocateResponder handles the response to the Deallocate request. The method always // DeallocateResponder handles the response to the Deallocate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -117,40 +132,54 @@ func (client VirtualMachineScaleSetVMsClient) DeallocateResponder(resp *http.Res
// argument. The channel will be used to cancel polling and any outstanding // argument. The channel will be used to cancel polling and any outstanding
// HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) Delete(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.DeletePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
func (client VirtualMachineScaleSetVMsClient) DeletePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) DeletePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -171,31 +200,34 @@ func (client VirtualMachineScaleSetVMsClient) DeleteSender(req *http.Request) (*
// DeleteResponder handles the response to the Delete request. The method always // DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) DeleteResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Get gets a virtual machine from a VM scale set. // Get gets a virtual machine from a VM scale set.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) { func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVM, err error) {
req, err := client.GetPreparer(resourceGroupName, vmScaleSetName, instanceID) req, err := client.GetPreparer(resourceGroupName, VMScaleSetName, instanceID)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -207,16 +239,17 @@ func (client VirtualMachineScaleSetVMsClient) Get(resourceGroupName string, vmSc
} }
// GetPreparer prepares the Get request. // GetPreparer prepares the Get request.
func (client VirtualMachineScaleSetVMsClient) GetPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) GetPreparer(resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -248,19 +281,21 @@ func (client VirtualMachineScaleSetVMsClient) GetResponder(resp *http.Response)
// GetInstanceView gets the status of a virtual machine from a VM scale set. // GetInstanceView gets the status of a virtual machine from a VM scale set.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName string, vmScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) { func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName string, VMScaleSetName string, instanceID string) (result VirtualMachineScaleSetVMInstanceView, err error) {
req, err := client.GetInstanceViewPreparer(resourceGroupName, vmScaleSetName, instanceID) req, err := client.GetInstanceViewPreparer(resourceGroupName, VMScaleSetName, instanceID)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", nil, "Failure preparing request")
return
} }
resp, err := client.GetInstanceViewSender(req) resp, err := client.GetInstanceViewSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "GetInstanceView", resp, "Failure sending request")
return
} }
result, err = client.GetInstanceViewResponder(resp) result, err = client.GetInstanceViewResponder(resp)
@ -272,16 +307,17 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceView(resourceGroupName
} }
// GetInstanceViewPreparer prepares the GetInstanceView request. // GetInstanceViewPreparer prepares the GetInstanceView request.
func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(resourceGroupName string, vmScaleSetName string, instanceID string) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) GetInstanceViewPreparer(resourceGroupName string, VMScaleSetName string, instanceID string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -320,13 +356,15 @@ func (client VirtualMachineScaleSetVMsClient) GetInstanceViewResponder(resp *htt
func (client VirtualMachineScaleSetVMsClient) List(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResult, err error) { func (client VirtualMachineScaleSetVMsClient) List(resourceGroupName string, virtualMachineScaleSetName string, filter string, selectParameter string, expand string) (result VirtualMachineScaleSetVMListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand) req, err := client.ListPreparer(resourceGroupName, virtualMachineScaleSetName, filter, selectParameter, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -345,8 +383,9 @@ func (client VirtualMachineScaleSetVMsClient) ListPreparer(resourceGroupName str
"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(filter) > 0 { if len(filter) > 0 {
queryParameters["$filter"] = autorest.Encode("query", filter) queryParameters["$filter"] = autorest.Encode("query", filter)
@ -410,46 +449,60 @@ func (client VirtualMachineScaleSetVMsClient) ListNextResults(lastResults Virtua
} }
// PowerOff power off (stop) a virtual machine in a VM scale set. Note that // PowerOff power off (stop) a virtual machine in a VM scale set. Note that
// resources are still attached and you are getting charged for the // resources are still attached and you are getting charged for the resources.
// resources. Instead, use deallocate to release resources and avoid charges. // Instead, use deallocate to release resources and avoid charges. This method
// This method may poll for completion. Polling can be canceled by passing // may poll for completion. Polling can be canceled by passing the cancel
// the cancel channel argument. The channel will be used to cancel polling // channel argument. The channel will be used to cancel polling and any
// and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) PowerOff(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.PowerOffPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.PowerOffPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", nil, "Failure preparing request")
return
} }
resp, err := client.PowerOffSender(req) resp, err := client.PowerOffSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure sending request")
return
} }
result, err = client.PowerOffResponder(resp) result, err = client.PowerOffResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "PowerOff", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// PowerOffPreparer prepares the PowerOff request. // PowerOffPreparer prepares the PowerOff request.
func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) PowerOffPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -470,55 +523,70 @@ func (client VirtualMachineScaleSetVMsClient) PowerOffSender(req *http.Request)
// PowerOffResponder handles the response to the PowerOff request. The method always // PowerOffResponder handles the response to the PowerOff request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) PowerOffResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Reimage reimages (upgrade the operating system) a specific virtual machine // Reimage reimages (upgrade the operating system) a specific virtual machine
// in a VM scale set. This method may poll for completion. Polling can be // in a VM scale set. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used // canceled by passing the cancel channel argument. The channel will be used to
// to cancel polling and any outstanding HTTP requests. // cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) Reimage(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.ReimagePreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ReimagePreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", nil, "Failure preparing request")
return
} }
resp, err := client.ReimageSender(req) resp, err := client.ReimageSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure sending request")
return
} }
result, err = client.ReimageResponder(resp) result, err = client.ReimageResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Reimage", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ReimagePreparer prepares the Reimage request. // ReimagePreparer prepares the Reimage request.
func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) ReimagePreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -539,13 +607,99 @@ func (client VirtualMachineScaleSetVMsClient) ReimageSender(req *http.Request) (
// ReimageResponder handles the response to the Reimage request. The method always // ReimageResponder handles the response to the Reimage request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return
}
// ReimageAll allows you to re-image all the disks ( including data disks ) in
// the a virtual machine scale set instance. This operation is only supported
// for managed disks. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used to
// cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual
// machine.
func (client VirtualMachineScaleSetVMsClient) ReimageAll(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ReimageAllPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", nil, "Failure preparing request")
return
}
resp, err := client.ReimageAllSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure sending request")
return
}
result, err = client.ReimageAllResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "ReimageAll", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// ReimageAllPreparer prepares the ReimageAll request.
func (client VirtualMachineScaleSetVMsClient) ReimageAllPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", VMScaleSetName),
}
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmScaleSetName}/virtualmachines/{instanceId}/reimageall", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// ReimageAllSender sends the ReimageAll request. The method will close the
// http.Response Body if it receives an error.
func (client VirtualMachineScaleSetVMsClient) ReimageAllSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// ReimageAllResponder handles the response to the ReimageAll request. The method always
// closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) ReimageAllResponder(resp *http.Response) (result OperationStatusResponse, 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 return
} }
@ -554,40 +708,54 @@ func (client VirtualMachineScaleSetVMsClient) ReimageResponder(resp *http.Respon
// argument. The channel will be used to cancel polling and any outstanding // argument. The channel will be used to cancel polling and any outstanding
// HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) Restart(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.RestartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.RestartPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", nil, "Failure preparing request")
return
} }
resp, err := client.RestartSender(req) resp, err := client.RestartSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure sending request")
return
} }
result, err = client.RestartResponder(resp) result, err = client.RestartResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Restart", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// RestartPreparer prepares the Restart request. // RestartPreparer prepares the Restart request.
func (client VirtualMachineScaleSetVMsClient) RestartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) RestartPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -608,55 +776,70 @@ func (client VirtualMachineScaleSetVMsClient) RestartSender(req *http.Request) (
// RestartResponder handles the response to the Restart request. The method always // RestartResponder handles the response to the Restart request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) RestartResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Start starts a virtual machine in a VM scale set. This method may poll for // Start starts a virtual machine in a VM scale set. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. vmScaleSetName is the // resourceGroupName is the name of the resource group. VMScaleSetName is the
// name of the VM scale set. instanceID is the instance ID of the virtual // name of the VM scale set. instanceID is the instance ID of the virtual
// machine. // machine.
func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) Start(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (<-chan OperationStatusResponse, <-chan error) {
req, err := client.StartPreparer(resourceGroupName, vmScaleSetName, instanceID, cancel) resultChan := make(chan OperationStatusResponse, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result OperationStatusResponse
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.StartPreparer(resourceGroupName, VMScaleSetName, instanceID, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", nil, "Failure preparing request")
return
} }
resp, err := client.StartSender(req) resp, err := client.StartSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure sending request")
return
} }
result, err = client.StartResponder(resp) result, err = client.StartResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineScaleSetVMsClient", "Start", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// StartPreparer prepares the Start request. // StartPreparer prepares the Start request.
func (client VirtualMachineScaleSetVMsClient) StartPreparer(resourceGroupName string, vmScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) { func (client VirtualMachineScaleSetVMsClient) StartPreparer(resourceGroupName string, VMScaleSetName string, instanceID string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"instanceId": autorest.Encode("path", instanceID), "instanceId": autorest.Encode("path", instanceID),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"vmScaleSetName": autorest.Encode("path", vmScaleSetName), "vmScaleSetName": autorest.Encode("path", VMScaleSetName),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -677,12 +860,13 @@ func (client VirtualMachineScaleSetVMsClient) StartSender(req *http.Request) (*h
// StartResponder handles the response to the Start request. The method always // StartResponder handles the response to the Start request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualMachineScaleSetVMsClient) StartResponder(resp *http.Response) (result OperationStatusResponse, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }

11
vendor/github.com/Azure/azure-sdk-for-go/arm/compute/virtualmachinesizes.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package compute
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -55,13 +55,15 @@ func (client VirtualMachineSizesClient) List(location string) (result VirtualMac
req, err := client.ListPreparer(location) req, err := client.ListPreparer(location)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -79,8 +81,9 @@ func (client VirtualMachineSizesClient) ListPreparer(location string) (*http.Req
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-04-30-preview"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

View File

@ -1,39 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"client.go",
"models.go",
"registries.go",
"version.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/date:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/validation:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

12
vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/client.go generated vendored Normal file → Executable file
View File

@ -1,5 +1,6 @@
// Package containerregistry implements the Azure ARM Containerregistry // Package containerregistry implements the Azure ARM Containerregistry service
// service API version 2016-06-27-preview. // API version 2017-03-01.
//
// //
package containerregistry package containerregistry
@ -17,7 +18,7 @@ package containerregistry
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -26,9 +27,6 @@ import (
) )
const ( const (
// APIVersion is the version of the Containerregistry
APIVersion = "2016-06-27-preview"
// DefaultBaseURI is the default URI used for the service Containerregistry // DefaultBaseURI is the default URI used for the service Containerregistry
DefaultBaseURI = "https://management.azure.com" DefaultBaseURI = "https://management.azure.com"
) )
@ -37,7 +35,6 @@ const (
type ManagementClient struct { type ManagementClient struct {
autorest.Client autorest.Client
BaseURI string BaseURI string
APIVersion string
SubscriptionID string SubscriptionID string
} }
@ -51,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{ return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()), Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI, BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID, SubscriptionID: subscriptionID,
} }
} }

127
vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/models.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package containerregistry
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,6 +25,75 @@ import (
"net/http" "net/http"
) )
// PasswordName enumerates the values for password name.
type PasswordName string
const (
// Password specifies the password state for password name.
Password PasswordName = "password"
// Password2 specifies the password 2 state for password name.
Password2 PasswordName = "password2"
)
// ProvisioningState enumerates the values for provisioning state.
type ProvisioningState string
const (
// Creating specifies the creating state for provisioning state.
Creating ProvisioningState = "Creating"
// Succeeded specifies the succeeded state for provisioning state.
Succeeded ProvisioningState = "Succeeded"
)
// SkuTier enumerates the values for sku tier.
type SkuTier string
const (
// Basic specifies the basic state for sku tier.
Basic SkuTier = "Basic"
)
// OperationDefinition is the definition of a container registry operation.
type OperationDefinition struct {
Name *string `json:"name,omitempty"`
Display *OperationDisplayDefinition `json:"display,omitempty"`
}
// OperationDisplayDefinition is the display information for a container
// registry operation.
type OperationDisplayDefinition struct {
Provider *string `json:"provider,omitempty"`
Resource *string `json:"resource,omitempty"`
Operation *string `json:"operation,omitempty"`
Description *string `json:"description,omitempty"`
}
// OperationListResult is the result of a request to list container registry
// operations.
type OperationListResult struct {
autorest.Response `json:"-"`
Value *[]OperationDefinition `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// OperationListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client OperationListResult) OperationListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// RegenerateCredentialParameters is the parameters used to regenerate the
// login credential.
type RegenerateCredentialParameters struct {
Name PasswordName `json:"name,omitempty"`
}
// Registry is an object that represents a container registry. // Registry is an object that represents a container registry.
type Registry struct { type Registry struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
@ -33,15 +102,25 @@ type Registry struct {
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"` Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
Sku *Sku `json:"sku,omitempty"`
*RegistryProperties `json:"properties,omitempty"` *RegistryProperties `json:"properties,omitempty"`
} }
// RegistryCredentials is the result of a request to get the administrator // RegistryCreateParameters is the parameters for creating a container
// login credentials for a container registry. // registry.
type RegistryCredentials struct { type RegistryCreateParameters struct {
Tags *map[string]*string `json:"tags,omitempty"`
Location *string `json:"location,omitempty"`
Sku *Sku `json:"sku,omitempty"`
*RegistryPropertiesCreateParameters `json:"properties,omitempty"`
}
// RegistryListCredentialsResult is the response from the ListCredentials
// operation.
type RegistryListCredentialsResult struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
Username *string `json:"username,omitempty"` Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"` Passwords *[]RegistryPassword `json:"passwords,omitempty"`
} }
// RegistryListResult is the result of a request to list container registries. // RegistryListResult is the result of a request to list container registries.
@ -63,15 +142,15 @@ func (client RegistryListResult) RegistryListResultPreparer() (*http.Request, er
autorest.WithBaseURL(to.String(client.NextLink))) autorest.WithBaseURL(to.String(client.NextLink)))
} }
// RegistryNameCheckRequest is a request to check whether the container // RegistryNameCheckRequest is a request to check whether a container registry
// registry name is available. // name is available.
type RegistryNameCheckRequest struct { type RegistryNameCheckRequest struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
} }
// RegistryNameStatus is the result of a request to check the availability of // RegistryNameStatus is the result of a request to check the availability of a
// a container registry name. // container registry name.
type RegistryNameStatus struct { type RegistryNameStatus struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
NameAvailable *bool `json:"nameAvailable,omitempty"` NameAvailable *bool `json:"nameAvailable,omitempty"`
@ -79,19 +158,33 @@ type RegistryNameStatus struct {
Message *string `json:"message,omitempty"` Message *string `json:"message,omitempty"`
} }
// RegistryPassword is the login password for the container registry.
type RegistryPassword struct {
Name PasswordName `json:"name,omitempty"`
Value *string `json:"value,omitempty"`
}
// RegistryProperties is the properties of a container registry. // RegistryProperties is the properties of a container registry.
type RegistryProperties struct { type RegistryProperties struct {
LoginServer *string `json:"loginServer,omitempty"` LoginServer *string `json:"loginServer,omitempty"`
CreationDate *date.Time `json:"creationDate,omitempty"` CreationDate *date.Time `json:"creationDate,omitempty"`
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
} }
// RegistryPropertiesCreateParameters is the parameters for creating the
// properties of a container registry.
type RegistryPropertiesCreateParameters struct {
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"`
}
// RegistryPropertiesUpdateParameters is the parameters for updating the // RegistryPropertiesUpdateParameters is the parameters for updating the
// properties of a container registry. // properties of a container registry.
type RegistryPropertiesUpdateParameters struct { type RegistryPropertiesUpdateParameters struct {
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"` AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"` StorageAccount *StorageAccountParameters `json:"storageAccount,omitempty"`
} }
// RegistryUpdateParameters is the parameters for updating a container // RegistryUpdateParameters is the parameters for updating a container
@ -110,9 +203,21 @@ type Resource struct {
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
} }
// Sku is the SKU of a container registry.
type Sku struct {
Name *string `json:"name,omitempty"`
Tier SkuTier `json:"tier,omitempty"`
}
// StorageAccountParameters is the parameters of a storage account for a
// container registry.
type StorageAccountParameters struct {
Name *string `json:"name,omitempty"`
AccessKey *string `json:"accessKey,omitempty"`
}
// StorageAccountProperties is the properties of a storage account for a // StorageAccountProperties is the properties of a storage account for a
// container registry. // container registry.
type StorageAccountProperties struct { type StorageAccountProperties struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
AccessKey *string `json:"accessKey,omitempty"`
} }

406
vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/registries.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package containerregistry
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -51,20 +51,26 @@ func NewRegistriesClientWithBaseURI(baseURI string, subscriptionID string) Regis
func (client RegistriesClient) CheckNameAvailability(registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) { func (client RegistriesClient) CheckNameAvailability(registryNameCheckRequest RegistryNameCheckRequest) (result RegistryNameStatus, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: registryNameCheckRequest, {TargetValue: registryNameCheckRequest,
Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true, Chain: nil}, Constraints: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "registryNameCheckRequest.Name", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryNameCheckRequest.Name", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryNameCheckRequest.Name", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil},
}},
{Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { {Target: "registryNameCheckRequest.Type", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CheckNameAvailability") return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CheckNameAvailability")
} }
req, err := client.CheckNameAvailabilityPreparer(registryNameCheckRequest) req, err := client.CheckNameAvailabilityPreparer(registryNameCheckRequest)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", nil, "Failure preparing request")
return
} }
resp, err := client.CheckNameAvailabilitySender(req) resp, err := client.CheckNameAvailabilitySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CheckNameAvailability", resp, "Failure sending request")
return
} }
result, err = client.CheckNameAvailabilityResponder(resp) result, err = client.CheckNameAvailabilityResponder(resp)
@ -81,8 +87,9 @@ func (client RegistriesClient) CheckNameAvailabilityPreparer(registryNameCheckRe
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -114,55 +121,80 @@ func (client RegistriesClient) CheckNameAvailabilityResponder(resp *http.Respons
return return
} }
// CreateOrUpdate creates or updates a container registry with the specified // Create creates a container registry with the specified parameters. This
// parameters. // method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group to which the container // resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry. // registry belongs. registryName is the name of the container registry.
// registry is the parameters for creating or updating a container registry. // registryCreateParameters is the parameters for creating a container
func (client RegistriesClient) CreateOrUpdate(resourceGroupName string, registryName string, registry Registry) (result Registry, err error) { // registry.
func (client RegistriesClient) Create(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (<-chan Registry, <-chan error) {
resultChan := make(chan Registry, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: registry, {TargetValue: registryName,
Constraints: []validation.Constraint{{Target: "registry.RegistryProperties", Name: validation.Null, Rule: false, Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount", Name: validation.Null, Rule: true, {Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
Chain: []validation.Constraint{{Target: "registry.RegistryProperties.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil}, {Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}},
{Target: "registry.RegistryProperties.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil}, {TargetValue: registryCreateParameters,
Constraints: []validation.Constraint{{Target: "registryCreateParameters.Location", Name: validation.Null, Rule: true, Chain: nil},
{Target: "registryCreateParameters.Sku", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "registryCreateParameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "registryCreateParameters.RegistryPropertiesCreateParameters", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.Name", Name: validation.Null, Rule: true, Chain: nil},
{Target: "registryCreateParameters.RegistryPropertiesCreateParameters.StorageAccount.AccessKey", Name: validation.Null, Rule: true, Chain: nil},
}}, }},
{Target: "registry.RegistryProperties.LoginServer", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "registry.RegistryProperties.CreationDate", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "CreateOrUpdate") errChan <- validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Create")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
req, err := client.CreateOrUpdatePreparer(resourceGroupName, registryName, registry) go func() {
var err error
var result Registry
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreatePreparer(resourceGroupName, registryName, registryCreateParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return return
}
result, err = client.CreateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Create", resp, "Failure responding to request")
}
}()
return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreatePreparer prepares the Create request.
func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string, registryName string, registry Registry) (*http.Request, error) { func (client RegistriesClient) CreatePreparer(resourceGroupName string, registryName string, registryCreateParameters RegistryCreateParameters, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"registryName": autorest.Encode("path", registryName), "registryName": autorest.Encode("path", registryName),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -170,24 +202,26 @@ func (client RegistriesClient) CreateOrUpdatePreparer(resourceGroupName string,
autorest.AsPut(), autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI), autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}", pathParameters),
autorest.WithJSON(registry), autorest.WithJSON(registryCreateParameters),
autorest.WithQueryParameters(queryParameters)) autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{}) return preparer.Prepare(&http.Request{Cancel: cancel})
} }
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the // CreateSender sends the Create request. The method will close the
// http.Response Body if it receives an error. // http.Response Body if it receives an error.
func (client RegistriesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { func (client RegistriesClient) CreateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req) return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
} }
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (result Registry, err error) { func (client RegistriesClient) CreateResponder(resp *http.Response) (result Registry, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result), autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
@ -199,15 +233,25 @@ func (client RegistriesClient) CreateOrUpdateResponder(resp *http.Response) (res
// resourceGroupName is the name of the resource group to which the container // resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry. // registry belongs. registryName is the name of the container registry.
func (client RegistriesClient) Delete(resourceGroupName string, registryName string) (result autorest.Response, err error) { func (client RegistriesClient) Delete(resourceGroupName string, registryName string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: registryName,
Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Delete")
}
req, err := client.DeletePreparer(resourceGroupName, registryName) req, err := client.DeletePreparer(resourceGroupName, registryName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
@ -226,8 +270,9 @@ func (client RegistriesClient) DeletePreparer(resourceGroupName string, registry
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -250,110 +295,57 @@ func (client RegistriesClient) DeleteResponder(resp *http.Response) (result auto
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = resp
return return
} }
// GetCredentials gets the administrator login credentials for the specified // Get gets the properties of the specified container registry.
// container registry.
// //
// resourceGroupName is the name of the resource group to which the container // resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry. // registry belongs. registryName is the name of the container registry.
func (client RegistriesClient) GetCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { func (client RegistriesClient) Get(resourceGroupName string, registryName string) (result Registry, err error) {
req, err := client.GetCredentialsPreparer(resourceGroupName, registryName) if err := validation.Validate([]validation.Validation{
if err != nil { {TargetValue: registryName,
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", nil, "Failure preparing request") Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Get")
} }
resp, err := client.GetCredentialsSender(req) req, err := client.GetPreparer(resourceGroupName, registryName)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", nil, "Failure preparing request")
return
}
resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetCredentialsResponder(resp) result, err = client.GetResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetCredentials", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Get", resp, "Failure responding to request")
} }
return return
} }
// GetCredentialsPreparer prepares the GetCredentials request. // GetPreparer prepares the Get request.
func (client RegistriesClient) GetCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { func (client RegistriesClient) GetPreparer(resourceGroupName string, registryName string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"registryName": autorest.Encode("path", registryName), "registryName": autorest.Encode("path", registryName),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/getCredentials", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetCredentialsSender sends the GetCredentials request. The method will close the
// http.Response Body if it receives an error.
func (client RegistriesClient) GetCredentialsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetCredentialsResponder handles the response to the GetCredentials request. The method always
// closes the http.Response Body.
func (client RegistriesClient) GetCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// GetProperties gets the properties of the specified container registry.
//
// resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry.
func (client RegistriesClient) GetProperties(resourceGroupName string, registryName string) (result Registry, err error) {
req, err := client.GetPropertiesPreparer(resourceGroupName, registryName)
if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", nil, "Failure preparing request")
}
resp, err := client.GetPropertiesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure sending request")
}
result, err = client.GetPropertiesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "GetProperties", resp, "Failure responding to request")
}
return
}
// GetPropertiesPreparer prepares the GetProperties request.
func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, registryName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"registryName": autorest.Encode("path", registryName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -364,15 +356,15 @@ func (client RegistriesClient) GetPropertiesPreparer(resourceGroupName string, r
return preparer.Prepare(&http.Request{}) return preparer.Prepare(&http.Request{})
} }
// GetPropertiesSender sends the GetProperties request. The method will close the // GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error. // http.Response Body if it receives an error.
func (client RegistriesClient) GetPropertiesSender(req *http.Request) (*http.Response, error) { func (client RegistriesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req) return autorest.SendWithSender(client, req)
} }
// GetPropertiesResponder handles the response to the GetProperties request. The method always // GetResponder handles the response to the Get request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (result Registry, err error) { func (client RegistriesClient) GetResponder(resp *http.Response) (result Registry, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
@ -383,18 +375,19 @@ func (client RegistriesClient) GetPropertiesResponder(resp *http.Response) (resu
return return
} }
// List lists all the available container registries under the specified // List lists all the container registries under the specified subscription.
// subscription.
func (client RegistriesClient) List() (result RegistryListResult, err error) { func (client RegistriesClient) List() (result RegistryListResult, err error) {
req, err := client.ListPreparer() req, err := client.ListPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -411,8 +404,9 @@ func (client RegistriesClient) ListPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -466,21 +460,23 @@ func (client RegistriesClient) ListNextResults(lastResults RegistryListResult) (
return return
} }
// ListByResourceGroup lists all the available container registries under the // ListByResourceGroup lists all the container registries under the specified
// specified resource group. // resource group.
// //
// resourceGroupName is the name of the resource group to which the container // resourceGroupName is the name of the resource group to which the container
// registry belongs. // registry belongs.
func (client RegistriesClient) ListByResourceGroup(resourceGroupName string) (result RegistryListResult, err error) { func (client RegistriesClient) ListByResourceGroup(resourceGroupName string) (result RegistryListResult, err error) {
req, err := client.ListByResourceGroupPreparer(resourceGroupName) req, err := client.ListByResourceGroupPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", nil, "Failure preparing request")
return
} }
resp, err := client.ListByResourceGroupSender(req) resp, err := client.ListByResourceGroupSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListByResourceGroup", resp, "Failure sending request")
return
} }
result, err = client.ListByResourceGroupResponder(resp) result, err = client.ListByResourceGroupResponder(resp)
@ -498,8 +494,9 @@ func (client RegistriesClient) ListByResourceGroupPreparer(resourceGroupName str
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -553,60 +550,150 @@ func (client RegistriesClient) ListByResourceGroupNextResults(lastResults Regist
return return
} }
// RegenerateCredentials regenerates the administrator login credentials for // ListCredentials lists the login credentials for the specified container
// the specified container registry. // registry.
// //
// resourceGroupName is the name of the resource group to which the container // resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry. // registry belongs. registryName is the name of the container registry.
func (client RegistriesClient) RegenerateCredentials(resourceGroupName string, registryName string) (result RegistryCredentials, err error) { func (client RegistriesClient) ListCredentials(resourceGroupName string, registryName string) (result RegistryListCredentialsResult, err error) {
req, err := client.RegenerateCredentialsPreparer(resourceGroupName, registryName) if err := validation.Validate([]validation.Validation{
if err != nil { {TargetValue: registryName,
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", nil, "Failure preparing request") Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "ListCredentials")
} }
resp, err := client.RegenerateCredentialsSender(req) req, err := client.ListCredentialsPreparer(resourceGroupName, registryName)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", nil, "Failure preparing request")
return
}
resp, err := client.ListCredentialsSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure sending request")
return
} }
result, err = client.RegenerateCredentialsResponder(resp) result, err = client.ListCredentialsResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredentials", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "ListCredentials", resp, "Failure responding to request")
} }
return return
} }
// RegenerateCredentialsPreparer prepares the RegenerateCredentials request. // ListCredentialsPreparer prepares the ListCredentials request.
func (client RegistriesClient) RegenerateCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) { func (client RegistriesClient) ListCredentialsPreparer(resourceGroupName string, registryName string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"registryName": autorest.Encode("path", registryName), "registryName": autorest.Encode("path", registryName),
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
autorest.AsPost(), autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI), autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredentials", pathParameters), autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/listCredentials", pathParameters),
autorest.WithQueryParameters(queryParameters)) autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{}) return preparer.Prepare(&http.Request{})
} }
// RegenerateCredentialsSender sends the RegenerateCredentials request. The method will close the // ListCredentialsSender sends the ListCredentials request. The method will close the
// http.Response Body if it receives an error. // http.Response Body if it receives an error.
func (client RegistriesClient) RegenerateCredentialsSender(req *http.Request) (*http.Response, error) { func (client RegistriesClient) ListCredentialsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req) return autorest.SendWithSender(client, req)
} }
// RegenerateCredentialsResponder handles the response to the RegenerateCredentials request. The method always // ListCredentialsResponder handles the response to the ListCredentials request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Response) (result RegistryCredentials, err error) { func (client RegistriesClient) ListCredentialsResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// RegenerateCredential regenerates one of the login credentials for the
// specified container registry.
//
// resourceGroupName is the name of the resource group to which the container
// registry belongs. registryName is the name of the container registry.
// regenerateCredentialParameters is specifies name of the password which
// should be regenerated -- password or password2.
func (client RegistriesClient) RegenerateCredential(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (result RegistryListCredentialsResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: registryName,
Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "RegenerateCredential")
}
req, err := client.RegenerateCredentialPreparer(resourceGroupName, registryName, regenerateCredentialParameters)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", nil, "Failure preparing request")
return
}
resp, err := client.RegenerateCredentialSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure sending request")
return
}
result, err = client.RegenerateCredentialResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "RegenerateCredential", resp, "Failure responding to request")
}
return
}
// RegenerateCredentialPreparer prepares the RegenerateCredential request.
func (client RegistriesClient) RegenerateCredentialPreparer(resourceGroupName string, registryName string, regenerateCredentialParameters RegenerateCredentialParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"registryName": autorest.Encode("path", registryName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerRegistry/registries/{registryName}/regenerateCredential", pathParameters),
autorest.WithJSON(regenerateCredentialParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// RegenerateCredentialSender sends the RegenerateCredential request. The method will close the
// http.Response Body if it receives an error.
func (client RegistriesClient) RegenerateCredentialSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// RegenerateCredentialResponder handles the response to the RegenerateCredential request. The method always
// closes the http.Response Body.
func (client RegistriesClient) RegenerateCredentialResponder(resp *http.Response) (result RegistryListCredentialsResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
@ -624,15 +711,25 @@ func (client RegistriesClient) RegenerateCredentialsResponder(resp *http.Respons
// registryUpdateParameters is the parameters for updating a container // registryUpdateParameters is the parameters for updating a container
// registry. // registry.
func (client RegistriesClient) Update(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) { func (client RegistriesClient) Update(resourceGroupName string, registryName string, registryUpdateParameters RegistryUpdateParameters) (result Registry, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: registryName,
Constraints: []validation.Constraint{{Target: "registryName", Name: validation.MaxLength, Rule: 50, Chain: nil},
{Target: "registryName", Name: validation.MinLength, Rule: 5, Chain: nil},
{Target: "registryName", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]*$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerregistry.RegistriesClient", "Update")
}
req, err := client.UpdatePreparer(resourceGroupName, registryName, registryUpdateParameters) req, err := client.UpdatePreparer(resourceGroupName, registryName, registryUpdateParameters)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", nil, "Failure preparing request")
return
} }
resp, err := client.UpdateSender(req) resp, err := client.UpdateSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "containerregistry.RegistriesClient", "Update", resp, "Failure sending request")
return
} }
result, err = client.UpdateResponder(resp) result, err = client.UpdateResponder(resp)
@ -651,8 +748,9 @@ func (client RegistriesClient) UpdatePreparer(resourceGroupName string, registry
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

20
vendor/github.com/Azure/azure-sdk-for-go/arm/containerregistry/version.go generated vendored Normal file → Executable file
View File

@ -14,30 +14,16 @@ package containerregistry
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests. // UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string { func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "containerregistry", "2016-06-27-preview") return "Azure-SDK-For-Go/v10.0.2-beta arm-containerregistry/2017-03-01"
} }
// Version returns the semantic version (see http://semver.org) of the client. // Version returns the semantic version (see http://semver.org) of the client.
func Version() string { func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag) return "v10.0.2-beta"
} }

View File

@ -1,56 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"applicationgateways.go",
"client.go",
"expressroutecircuitauthorizations.go",
"expressroutecircuitpeerings.go",
"expressroutecircuits.go",
"expressrouteserviceproviders.go",
"interfaces.go",
"loadbalancers.go",
"localnetworkgateways.go",
"models.go",
"publicipaddresses.go",
"routes.go",
"routetables.go",
"securitygroups.go",
"securityrules.go",
"subnets.go",
"usages.go",
"version.go",
"virtualnetworkgatewayconnections.go",
"virtualnetworkgateways.go",
"virtualnetworkpeerings.go",
"virtualnetworks.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/to:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/validation:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

284
vendor/github.com/Azure/azure-sdk-for-go/arm/network/applicationgateways.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// ApplicationGatewaysClient is the the Microsoft Azure Network management API // ApplicationGatewaysClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type ApplicationGatewaysClient struct { type ApplicationGatewaysClient struct {
ManagementClient ManagementClient
} }
@ -48,30 +44,43 @@ func NewApplicationGatewaysClientWithBaseURI(baseURI string, subscriptionID stri
// BackendHealth gets the backend health of the specified application gateway // BackendHealth gets the backend health of the specified application gateway
// in a resource group. This method may poll for completion. Polling can be // in a resource group. This method may poll for completion. Polling can be
// canceled by passing the cancel channel argument. The channel will be used // canceled by passing the cancel channel argument. The channel will be used to
// to cancel polling and any outstanding HTTP requests. // cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. applicationGatewayName // resourceGroupName is the name of the resource group. applicationGatewayName
// is the name of the application gateway. expand is expands // is the name of the application gateway. expand is expands BackendAddressPool
// BackendAddressPool and BackendHttpSettings referenced in backend health. // and BackendHttpSettings referenced in backend health.
func (client ApplicationGatewaysClient) BackendHealth(resourceGroupName string, applicationGatewayName string, expand string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) BackendHealth(resourceGroupName string, applicationGatewayName string, expand string, cancel <-chan struct{}) (<-chan ApplicationGatewayBackendHealth, <-chan error) {
resultChan := make(chan ApplicationGatewayBackendHealth, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ApplicationGatewayBackendHealth
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.BackendHealthPreparer(resourceGroupName, applicationGatewayName, expand, cancel) req, err := client.BackendHealthPreparer(resourceGroupName, applicationGatewayName, expand, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", nil, "Failure preparing request")
return
} }
resp, err := client.BackendHealthSender(req) resp, err := client.BackendHealthSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure sending request")
return
} }
result, err = client.BackendHealthResponder(resp) result, err = client.BackendHealthResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "BackendHealth", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// BackendHealthPreparer prepares the BackendHealth request. // BackendHealthPreparer prepares the BackendHealth request.
@ -82,8 +91,9 @@ func (client ApplicationGatewaysClient) BackendHealthPreparer(resourceGroupName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -107,52 +117,71 @@ func (client ApplicationGatewaysClient) BackendHealthSender(req *http.Request) (
// BackendHealthResponder handles the response to the BackendHealth request. The method always // BackendHealthResponder handles the response to the BackendHealth request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ApplicationGatewaysClient) BackendHealthResponder(resp *http.Response) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) BackendHealthResponder(resp *http.Response) (result ApplicationGatewayBackendHealth, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// CreateOrUpdate creates or updates the specified application gateway. This // CreateOrUpdate creates or updates the specified application gateway. This
// method may poll for completion. Polling can be canceled by passing the // method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and // cancel channel argument. The channel will be used to cancel polling and any
// any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. applicationGatewayName // resourceGroupName is the name of the resource group. applicationGatewayName
// is the name of the application gateway. parameters is parameters supplied // is the name of the application gateway. parameters is parameters supplied to
// to the create or update application gateway operation. // the create or update application gateway operation.
func (client ApplicationGatewaysClient) CreateOrUpdate(resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) CreateOrUpdate(resourceGroupName string, applicationGatewayName string, parameters ApplicationGateway, cancel <-chan struct{}) (<-chan ApplicationGateway, <-chan error) {
resultChan := make(chan ApplicationGateway, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat", Name: validation.Null, Rule: false, Constraints: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.Enabled", Name: validation.Null, Rule: true, Chain: nil}}}, Chain: []validation.Constraint{{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.Enabled", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.ApplicationGatewayPropertiesFormat.OperationalState", Name: validation.ReadOnly, Rule: true, Chain: nil}, {Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.RuleSetType", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.ApplicationGatewayPropertiesFormat.WebApplicationFirewallConfiguration.RuleSetVersion", Name: validation.Null, Rule: true, Chain: nil},
}},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate") errChan <- validation.NewErrorWithValidationError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result ApplicationGateway
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, applicationGatewayName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, applicationGatewayName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -163,8 +192,9 @@ func (client ApplicationGatewaysClient) CreateOrUpdatePreparer(resourceGroupName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -187,41 +217,55 @@ func (client ApplicationGatewaysClient) CreateOrUpdateSender(req *http.Request)
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ApplicationGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result ApplicationGateway, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified application gateway. This method may poll for // Delete deletes the specified application gateway. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. applicationGatewayName // resourceGroupName is the name of the resource group. applicationGatewayName
// is the name of the application gateway. // is the name of the application gateway.
func (client ApplicationGatewaysClient) Delete(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) Delete(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, applicationGatewayName, cancel) req, err := client.DeletePreparer(resourceGroupName, applicationGatewayName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -232,8 +276,9 @@ func (client ApplicationGatewaysClient) DeletePreparer(resourceGroupName string,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -271,13 +316,15 @@ func (client ApplicationGatewaysClient) DeleteResponder(resp *http.Response) (re
func (client ApplicationGatewaysClient) Get(resourceGroupName string, applicationGatewayName string) (result ApplicationGateway, err error) { func (client ApplicationGatewaysClient) Get(resourceGroupName string, applicationGatewayName string) (result ApplicationGateway, err error) {
req, err := client.GetPreparer(resourceGroupName, applicationGatewayName) req, err := client.GetPreparer(resourceGroupName, applicationGatewayName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -296,8 +343,9 @@ func (client ApplicationGatewaysClient) GetPreparer(resourceGroupName string, ap
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -333,13 +381,15 @@ func (client ApplicationGatewaysClient) GetResponder(resp *http.Response) (resul
func (client ApplicationGatewaysClient) List(resourceGroupName string) (result ApplicationGatewayListResult, err error) { func (client ApplicationGatewaysClient) List(resourceGroupName string) (result ApplicationGatewayListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -357,8 +407,9 @@ func (client ApplicationGatewaysClient) ListPreparer(resourceGroupName string) (
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -416,13 +467,15 @@ func (client ApplicationGatewaysClient) ListNextResults(lastResults ApplicationG
func (client ApplicationGatewaysClient) ListAll() (result ApplicationGatewayListResult, err error) { func (client ApplicationGatewaysClient) ListAll() (result ApplicationGatewayListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -439,8 +492,9 @@ func (client ApplicationGatewaysClient) ListAllPreparer() (*http.Request, error)
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -494,31 +548,106 @@ func (client ApplicationGatewaysClient) ListAllNextResults(lastResults Applicati
return return
} }
// ListAvailableWafRuleSets lists all available web application firewall rule
// sets.
func (client ApplicationGatewaysClient) ListAvailableWafRuleSets() (result ApplicationGatewayAvailableWafRuleSetsResult, err error) {
req, err := client.ListAvailableWafRuleSetsPreparer()
if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", nil, "Failure preparing request")
return
}
resp, err := client.ListAvailableWafRuleSetsSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", resp, "Failure sending request")
return
}
result, err = client.ListAvailableWafRuleSetsResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "ListAvailableWafRuleSets", resp, "Failure responding to request")
}
return
}
// ListAvailableWafRuleSetsPreparer prepares the ListAvailableWafRuleSets request.
func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Network/applicationGatewayAvailableWafRuleSets", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAvailableWafRuleSetsSender sends the ListAvailableWafRuleSets request. The method will close the
// http.Response Body if it receives an error.
func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAvailableWafRuleSetsResponder handles the response to the ListAvailableWafRuleSets request. The method always
// closes the http.Response Body.
func (client ApplicationGatewaysClient) ListAvailableWafRuleSetsResponder(resp *http.Response) (result ApplicationGatewayAvailableWafRuleSetsResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// Start starts the specified application gateway. This method may poll for // Start starts the specified application gateway. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. applicationGatewayName // resourceGroupName is the name of the resource group. applicationGatewayName
// is the name of the application gateway. // is the name of the application gateway.
func (client ApplicationGatewaysClient) Start(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) Start(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.StartPreparer(resourceGroupName, applicationGatewayName, cancel) req, err := client.StartPreparer(resourceGroupName, applicationGatewayName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", nil, "Failure preparing request")
return
} }
resp, err := client.StartSender(req) resp, err := client.StartSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure sending request")
return
} }
result, err = client.StartResponder(resp) result, err = client.StartResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Start", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// StartPreparer prepares the Start request. // StartPreparer prepares the Start request.
@ -529,8 +658,9 @@ func (client ApplicationGatewaysClient) StartPreparer(resourceGroupName string,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -563,29 +693,42 @@ func (client ApplicationGatewaysClient) StartResponder(resp *http.Response) (res
// Stop stops the specified application gateway in a resource group. This // Stop stops the specified application gateway in a resource group. This
// method may poll for completion. Polling can be canceled by passing the // method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and // cancel channel argument. The channel will be used to cancel polling and any
// any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. applicationGatewayName // resourceGroupName is the name of the resource group. applicationGatewayName
// is the name of the application gateway. // is the name of the application gateway.
func (client ApplicationGatewaysClient) Stop(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ApplicationGatewaysClient) Stop(resourceGroupName string, applicationGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.StopPreparer(resourceGroupName, applicationGatewayName, cancel) req, err := client.StopPreparer(resourceGroupName, applicationGatewayName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", nil, "Failure preparing request")
return
} }
resp, err := client.StopSender(req) resp, err := client.StopSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure sending request")
return
} }
result, err = client.StopResponder(resp) result, err = client.StopResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ApplicationGatewaysClient", "Stop", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// StopPreparer prepares the Stop request. // StopPreparer prepares the Stop request.
@ -596,8 +739,9 @@ func (client ApplicationGatewaysClient) StopPreparer(resourceGroupName string, a
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

24
vendor/github.com/Azure/azure-sdk-for-go/arm/network/client.go generated vendored Normal file → Executable file
View File

@ -1,10 +1,6 @@
// Package network implements the Azure ARM Network service API version // Package network implements the Azure ARM Network service API version .
// 2016-09-01.
// //
// The Microsoft Azure Network management API provides a RESTful set of web // Composite Swagger for Network Client
// services that interact with Microsoft Azure Networks service to manage
// your network resources. The API has entities that capture the relationship
// between an end user and the Microsoft Azure Networks service.
package network package network
// Copyright (c) Microsoft and contributors. All rights reserved. // Copyright (c) Microsoft and contributors. All rights reserved.
@ -21,7 +17,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -32,9 +28,6 @@ import (
) )
const ( const (
// APIVersion is the version of the Network
APIVersion = "2016-09-01"
// DefaultBaseURI is the default URI used for the service Network // DefaultBaseURI is the default URI used for the service Network
DefaultBaseURI = "https://management.azure.com" DefaultBaseURI = "https://management.azure.com"
) )
@ -43,7 +36,6 @@ const (
type ManagementClient struct { type ManagementClient struct {
autorest.Client autorest.Client
BaseURI string BaseURI string
APIVersion string
SubscriptionID string SubscriptionID string
} }
@ -57,7 +49,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{ return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()), Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI, BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID, SubscriptionID: subscriptionID,
} }
} }
@ -71,13 +62,15 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) {
req, err := client.CheckDNSNameAvailabilityPreparer(location, domainNameLabel) req, err := client.CheckDNSNameAvailabilityPreparer(location, domainNameLabel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", nil, "Failure preparing request")
return
} }
resp, err := client.CheckDNSNameAvailabilitySender(req) resp, err := client.CheckDNSNameAvailabilitySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ManagementClient", "CheckDNSNameAvailability", resp, "Failure sending request")
return
} }
result, err = client.CheckDNSNameAvailabilityResponder(resp) result, err = client.CheckDNSNameAvailabilityResponder(resp)
@ -95,8 +88,9 @@ func (client ManagementClient) CheckDNSNameAvailabilityPreparer(location string,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(domainNameLabel) > 0 { if len(domainNameLabel) > 0 {
queryParameters["domainNameLabel"] = autorest.Encode("query", domainNameLabel) queryParameters["domainNameLabel"] = autorest.Encode("query", domainNameLabel)

View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,8 @@ import (
"net/http" "net/http"
) )
// ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network // ExpressRouteCircuitAuthorizationsClient is the composite Swagger for Network
// management API provides a RESTful set of web services that interact with // Client
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteCircuitAuthorizationsClient struct { type ExpressRouteCircuitAuthorizationsClient struct {
ManagementClient ManagementClient
} }
@ -39,39 +36,52 @@ func NewExpressRouteCircuitAuthorizationsClient(subscriptionID string) ExpressRo
return NewExpressRouteCircuitAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID) return NewExpressRouteCircuitAuthorizationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
} }
// NewExpressRouteCircuitAuthorizationsClientWithBaseURI creates an instance // NewExpressRouteCircuitAuthorizationsClientWithBaseURI creates an instance of
// of the ExpressRouteCircuitAuthorizationsClient client. // the ExpressRouteCircuitAuthorizationsClient client.
func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) ExpressRouteCircuitAuthorizationsClient { func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subscriptionID string) ExpressRouteCircuitAuthorizationsClient {
return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate creates or updates an authorization in the specified express // CreateOrUpdate creates or updates an authorization in the specified express
// route circuit. This method may poll for completion. Polling can be // route circuit. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. authorizationName is the name of the // of the express route circuit. authorizationName is the name of the
// authorization. authorizationParameters is parameters supplied to the // authorization. authorizationParameters is parameters supplied to the create
// create or update express route circuit authorization operation. // or update express route circuit authorization operation.
func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdate(resourceGroupName string, circuitName string, authorizationName string, authorizationParameters ExpressRouteCircuitAuthorization, cancel <-chan struct{}) (<-chan ExpressRouteCircuitAuthorization, <-chan error) {
resultChan := make(chan ExpressRouteCircuitAuthorization, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuitAuthorization
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -83,8 +93,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdatePreparer(res
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -107,13 +118,14 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateSender(req *
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitAuthorization, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -122,27 +134,40 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(re
// passing the cancel channel argument. The channel will be used to cancel // passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. authorizationName is the name of the // of the express route circuit. authorizationName is the name of the
// authorization. // authorization.
func (client ExpressRouteCircuitAuthorizationsClient) Delete(resourceGroupName string, circuitName string, authorizationName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitAuthorizationsClient) Delete(resourceGroupName string, circuitName string, authorizationName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, circuitName, authorizationName, cancel) req, err := client.DeletePreparer(resourceGroupName, circuitName, authorizationName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -154,8 +179,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeletePreparer(resourceGro
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -189,19 +215,21 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeleteResponder(resp *http
// Get gets the specified authorization from the specified express route // Get gets the specified authorization from the specified express route
// circuit. // circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. authorizationName is the name of the // of the express route circuit. authorizationName is the name of the
// authorization. // authorization.
func (client ExpressRouteCircuitAuthorizationsClient) Get(resourceGroupName string, circuitName string, authorizationName string) (result ExpressRouteCircuitAuthorization, err error) { func (client ExpressRouteCircuitAuthorizationsClient) Get(resourceGroupName string, circuitName string, authorizationName string) (result ExpressRouteCircuitAuthorization, err error) {
req, err := client.GetPreparer(resourceGroupName, circuitName, authorizationName) req, err := client.GetPreparer(resourceGroupName, circuitName, authorizationName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -221,8 +249,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetPreparer(resourceGroupN
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -254,18 +283,20 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetResponder(resp *http.Re
// List gets all authorizations in an express route circuit. // List gets all authorizations in an express route circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the circuit. // of the circuit.
func (client ExpressRouteCircuitAuthorizationsClient) List(resourceGroupName string, circuitName string) (result AuthorizationListResult, err error) { func (client ExpressRouteCircuitAuthorizationsClient) List(resourceGroupName string, circuitName string) (result AuthorizationListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, circuitName) req, err := client.ListPreparer(resourceGroupName, circuitName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -284,8 +315,9 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListPreparer(resourceGroup
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

102
vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuitpeerings.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,8 @@ import (
"net/http" "net/http"
) )
// ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network // ExpressRouteCircuitPeeringsClient is the composite Swagger for Network
// management API provides a RESTful set of web services that interact with // Client
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteCircuitPeeringsClient struct { type ExpressRouteCircuitPeeringsClient struct {
ManagementClient ManagementClient
} }
@ -50,28 +47,41 @@ func NewExpressRouteCircuitPeeringsClientWithBaseURI(baseURI string, subscriptio
// passing the cancel channel argument. The channel will be used to cancel // passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
// peeringParameters is parameters supplied to the create or update express // peeringParameters is parameters supplied to the create or update express
// route circuit peering operation. // route circuit peering operation.
func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdate(resourceGroupName string, circuitName string, peeringName string, peeringParameters ExpressRouteCircuitPeering, cancel <-chan struct{}) (<-chan ExpressRouteCircuitPeering, <-chan error) {
resultChan := make(chan ExpressRouteCircuitPeering, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuitPeering
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -83,8 +93,9 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdatePreparer(resourceG
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -107,13 +118,14 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateSender(req *http.R
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuitPeering, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -122,26 +134,39 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *ht
// passing the cancel channel argument. The channel will be used to cancel // passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
func (client ExpressRouteCircuitPeeringsClient) Delete(resourceGroupName string, circuitName string, peeringName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitPeeringsClient) Delete(resourceGroupName string, circuitName string, peeringName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, circuitName, peeringName, cancel) req, err := client.DeletePreparer(resourceGroupName, circuitName, peeringName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -153,8 +178,9 @@ func (client ExpressRouteCircuitPeeringsClient) DeletePreparer(resourceGroupName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -188,18 +214,20 @@ func (client ExpressRouteCircuitPeeringsClient) DeleteResponder(resp *http.Respo
// Get gets the specified authorization from the specified express route // Get gets the specified authorization from the specified express route
// circuit. // circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
func (client ExpressRouteCircuitPeeringsClient) Get(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitPeering, err error) { func (client ExpressRouteCircuitPeeringsClient) Get(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitPeering, err error) {
req, err := client.GetPreparer(resourceGroupName, circuitName, peeringName) req, err := client.GetPreparer(resourceGroupName, circuitName, peeringName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -219,8 +247,9 @@ func (client ExpressRouteCircuitPeeringsClient) GetPreparer(resourceGroupName st
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -252,18 +281,20 @@ func (client ExpressRouteCircuitPeeringsClient) GetResponder(resp *http.Response
// List gets all peerings in a specified express route circuit. // List gets all peerings in a specified express route circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. // of the express route circuit.
func (client ExpressRouteCircuitPeeringsClient) List(resourceGroupName string, circuitName string) (result ExpressRouteCircuitPeeringListResult, err error) { func (client ExpressRouteCircuitPeeringsClient) List(resourceGroupName string, circuitName string) (result ExpressRouteCircuitPeeringListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, circuitName) req, err := client.ListPreparer(resourceGroupName, circuitName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -282,8 +313,9 @@ func (client ExpressRouteCircuitPeeringsClient) ListPreparer(resourceGroupName s
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

265
vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressroutecircuits.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,7 @@ import (
"net/http" "net/http"
) )
// ExpressRouteCircuitsClient is the the Microsoft Azure Network management // ExpressRouteCircuitsClient is the composite Swagger for Network Client
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteCircuitsClient struct { type ExpressRouteCircuitsClient struct {
ManagementClient ManagementClient
} }
@ -50,27 +46,40 @@ func NewExpressRouteCircuitsClientWithBaseURI(baseURI string, subscriptionID str
// argument. The channel will be used to cancel polling and any outstanding // argument. The channel will be used to cancel polling and any outstanding
// HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the circuit. parameters is parameters supplied to the create or // of the circuit. parameters is parameters supplied to the create or update
// update express route circuit operation. // express route circuit operation.
func (client ExpressRouteCircuitsClient) CreateOrUpdate(resourceGroupName string, circuitName string, parameters ExpressRouteCircuit, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) CreateOrUpdate(resourceGroupName string, circuitName string, parameters ExpressRouteCircuit, cancel <-chan struct{}) (<-chan ExpressRouteCircuit, <-chan error) {
resultChan := make(chan ExpressRouteCircuit, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuit
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -81,8 +90,9 @@ func (client ExpressRouteCircuitsClient) CreateOrUpdatePreparer(resourceGroupNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -105,41 +115,55 @@ func (client ExpressRouteCircuitsClient) CreateOrUpdateSender(req *http.Request)
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) CreateOrUpdateResponder(resp *http.Response) (result ExpressRouteCircuit, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified express route circuit. This method may poll // Delete deletes the specified express route circuit. This method may poll for
// for completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. // of the express route circuit.
func (client ExpressRouteCircuitsClient) Delete(resourceGroupName string, circuitName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) Delete(resourceGroupName string, circuitName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, circuitName, cancel) req, err := client.DeletePreparer(resourceGroupName, circuitName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -150,8 +174,9 @@ func (client ExpressRouteCircuitsClient) DeletePreparer(resourceGroupName string
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -184,18 +209,20 @@ func (client ExpressRouteCircuitsClient) DeleteResponder(resp *http.Response) (r
// Get gets information about the specified express route circuit. // Get gets information about the specified express route circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of express route circuit. // of express route circuit.
func (client ExpressRouteCircuitsClient) Get(resourceGroupName string, circuitName string) (result ExpressRouteCircuit, err error) { func (client ExpressRouteCircuitsClient) Get(resourceGroupName string, circuitName string) (result ExpressRouteCircuit, err error) {
req, err := client.GetPreparer(resourceGroupName, circuitName) req, err := client.GetPreparer(resourceGroupName, circuitName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -214,8 +241,9 @@ func (client ExpressRouteCircuitsClient) GetPreparer(resourceGroupName string, c
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -248,18 +276,20 @@ func (client ExpressRouteCircuitsClient) GetResponder(resp *http.Response) (resu
// GetPeeringStats gets all stats from an express route circuit in a resource // GetPeeringStats gets all stats from an express route circuit in a resource
// group. // group.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
func (client ExpressRouteCircuitsClient) GetPeeringStats(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitStats, err error) { func (client ExpressRouteCircuitsClient) GetPeeringStats(resourceGroupName string, circuitName string, peeringName string) (result ExpressRouteCircuitStats, err error) {
req, err := client.GetPeeringStatsPreparer(resourceGroupName, circuitName, peeringName) req, err := client.GetPeeringStatsPreparer(resourceGroupName, circuitName, peeringName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", nil, "Failure preparing request")
return
} }
resp, err := client.GetPeeringStatsSender(req) resp, err := client.GetPeeringStatsSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetPeeringStats", resp, "Failure sending request")
return
} }
result, err = client.GetPeeringStatsResponder(resp) result, err = client.GetPeeringStatsResponder(resp)
@ -279,8 +309,9 @@ func (client ExpressRouteCircuitsClient) GetPeeringStatsPreparer(resourceGroupNa
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -313,18 +344,20 @@ func (client ExpressRouteCircuitsClient) GetPeeringStatsResponder(resp *http.Res
// GetStats gets all the stats from an express route circuit in a resource // GetStats gets all the stats from an express route circuit in a resource
// group. // group.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. // of the express route circuit.
func (client ExpressRouteCircuitsClient) GetStats(resourceGroupName string, circuitName string) (result ExpressRouteCircuitStats, err error) { func (client ExpressRouteCircuitsClient) GetStats(resourceGroupName string, circuitName string) (result ExpressRouteCircuitStats, err error) {
req, err := client.GetStatsPreparer(resourceGroupName, circuitName) req, err := client.GetStatsPreparer(resourceGroupName, circuitName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", nil, "Failure preparing request")
return
} }
resp, err := client.GetStatsSender(req) resp, err := client.GetStatsSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "GetStats", resp, "Failure sending request")
return
} }
result, err = client.GetStatsResponder(resp) result, err = client.GetStatsResponder(resp)
@ -343,8 +376,9 @@ func (client ExpressRouteCircuitsClient) GetStatsPreparer(resourceGroupName stri
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -380,13 +414,15 @@ func (client ExpressRouteCircuitsClient) GetStatsResponder(resp *http.Response)
func (client ExpressRouteCircuitsClient) List(resourceGroupName string) (result ExpressRouteCircuitListResult, err error) { func (client ExpressRouteCircuitsClient) List(resourceGroupName string) (result ExpressRouteCircuitListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -404,8 +440,9 @@ func (client ExpressRouteCircuitsClient) ListPreparer(resourceGroupName string)
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -463,13 +500,15 @@ func (client ExpressRouteCircuitsClient) ListNextResults(lastResults ExpressRout
func (client ExpressRouteCircuitsClient) ListAll() (result ExpressRouteCircuitListResult, err error) { func (client ExpressRouteCircuitsClient) ListAll() (result ExpressRouteCircuitListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -486,8 +525,9 @@ func (client ExpressRouteCircuitsClient) ListAllPreparer() (*http.Request, error
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -543,31 +583,44 @@ func (client ExpressRouteCircuitsClient) ListAllNextResults(lastResults ExpressR
// ListArpTable gets the currently advertised ARP table associated with the // ListArpTable gets the currently advertised ARP table associated with the
// express route circuit in a resource group. This method may poll for // express route circuit in a resource group. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
// devicePath is the path of the device. // devicePath is the path of the device.
func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListArpTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsArpTableListResult, <-chan error) {
resultChan := make(chan ExpressRouteCircuitsArpTableListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuitsArpTableListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ListArpTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) req, err := client.ListArpTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", nil, "Failure preparing request")
return
} }
resp, err := client.ListArpTableSender(req) resp, err := client.ListArpTableSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure sending request")
return
} }
result, err = client.ListArpTableResponder(resp) result, err = client.ListArpTableResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListArpTable", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ListArpTablePreparer prepares the ListArpTable request. // ListArpTablePreparer prepares the ListArpTable request.
@ -580,8 +633,9 @@ func (client ExpressRouteCircuitsClient) ListArpTablePreparer(resourceGroupName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -602,43 +656,57 @@ func (client ExpressRouteCircuitsClient) ListArpTableSender(req *http.Request) (
// ListArpTableResponder handles the response to the ListArpTable request. The method always // ListArpTableResponder handles the response to the ListArpTable request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListArpTableResponder(resp *http.Response) (result ExpressRouteCircuitsArpTableListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// ListRoutesTable gets the currently advertised routes table associated with // ListRoutesTable gets the currently advertised routes table associated with
// the express route circuit in a resource group. This method may poll for // the express route circuit in a resource group. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
// devicePath is the path of the device. // devicePath is the path of the device.
func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListRoutesTable(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsRoutesTableListResult, <-chan error) {
resultChan := make(chan ExpressRouteCircuitsRoutesTableListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuitsRoutesTableListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) req, err := client.ListRoutesTablePreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", nil, "Failure preparing request")
return
} }
resp, err := client.ListRoutesTableSender(req) resp, err := client.ListRoutesTableSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure sending request")
return
} }
result, err = client.ListRoutesTableResponder(resp) result, err = client.ListRoutesTableResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTable", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ListRoutesTablePreparer prepares the ListRoutesTable request. // ListRoutesTablePreparer prepares the ListRoutesTable request.
@ -651,8 +719,9 @@ func (client ExpressRouteCircuitsClient) ListRoutesTablePreparer(resourceGroupNa
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -673,13 +742,14 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSender(req *http.Request
// ListRoutesTableResponder handles the response to the ListRoutesTable request. The method always // ListRoutesTableResponder handles the response to the ListRoutesTable request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Response) (result ExpressRouteCircuitsRoutesTableListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -689,27 +759,40 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableResponder(resp *http.Res
// channel argument. The channel will be used to cancel polling and any // channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the name
// name of the express route circuit. peeringName is the name of the peering. // of the express route circuit. peeringName is the name of the peering.
// devicePath is the path of the device. // devicePath is the path of the device.
func (client ExpressRouteCircuitsClient) ListRoutesTableSummary(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListRoutesTableSummary(resourceGroupName string, circuitName string, peeringName string, devicePath string, cancel <-chan struct{}) (<-chan ExpressRouteCircuitsRoutesTableSummaryListResult, <-chan error) {
resultChan := make(chan ExpressRouteCircuitsRoutesTableSummaryListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result ExpressRouteCircuitsRoutesTableSummaryListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ListRoutesTableSummaryPreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel) req, err := client.ListRoutesTableSummaryPreparer(resourceGroupName, circuitName, peeringName, devicePath, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", nil, "Failure preparing request")
return
} }
resp, err := client.ListRoutesTableSummarySender(req) resp, err := client.ListRoutesTableSummarySender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure sending request")
return
} }
result, err = client.ListRoutesTableSummaryResponder(resp) result, err = client.ListRoutesTableSummaryResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitsClient", "ListRoutesTableSummary", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ListRoutesTableSummaryPreparer prepares the ListRoutesTableSummary request. // ListRoutesTableSummaryPreparer prepares the ListRoutesTableSummary request.
@ -722,8 +805,9 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryPreparer(resource
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -744,12 +828,13 @@ func (client ExpressRouteCircuitsClient) ListRoutesTableSummarySender(req *http.
// ListRoutesTableSummaryResponder handles the response to the ListRoutesTableSummary request. The method always // ListRoutesTableSummaryResponder handles the response to the ListRoutesTableSummary request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryResponder(resp *http.Response) (result autorest.Response, err error) { func (client ExpressRouteCircuitsClient) ListRoutesTableSummaryResponder(resp *http.Response) (result ExpressRouteCircuitsRoutesTableSummaryListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }

18
vendor/github.com/Azure/azure-sdk-for-go/arm/network/expressrouteserviceproviders.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,8 @@ import (
"net/http" "net/http"
) )
// ExpressRouteServiceProvidersClient is the the Microsoft Azure Network // ExpressRouteServiceProvidersClient is the composite Swagger for Network
// management API provides a RESTful set of web services that interact with // Client
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type ExpressRouteServiceProvidersClient struct { type ExpressRouteServiceProvidersClient struct {
ManagementClient ManagementClient
} }
@ -49,13 +46,15 @@ func NewExpressRouteServiceProvidersClientWithBaseURI(baseURI string, subscripti
func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServiceProviderListResult, err error) { func (client ExpressRouteServiceProvidersClient) List() (result ExpressRouteServiceProviderListResult, err error) {
req, err := client.ListPreparer() req, err := client.ListPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -72,8 +71,9 @@ func (client ExpressRouteServiceProvidersClient) ListPreparer() (*http.Request,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

248
vendor/github.com/Azure/azure-sdk-for-go/arm/network/interfaces.go generated vendored Normal file → Executable file
View File

@ -14,22 +14,17 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
// InterfacesClient is the the Microsoft Azure Network management API provides // InterfacesClient is the composite Swagger for Network Client
// a RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type InterfacesClient struct { type InterfacesClient struct {
ManagementClient ManagementClient
} }
@ -50,40 +45,40 @@ func NewInterfacesClientWithBaseURI(baseURI string, subscriptionID string) Inter
// argument. The channel will be used to cancel polling and any outstanding // argument. The channel will be used to cancel polling and any outstanding
// HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. networkInterfaceName // resourceGroupName is the name of the resource group. networkInterfaceName is
// is the name of the network interface. parameters is parameters supplied to // the name of the network interface. parameters is parameters supplied to the
// the create or update network interface operation. // create or update network interface operation.
func (client InterfacesClient) CreateOrUpdate(resourceGroupName string, networkInterfaceName string, parameters Interface, cancel <-chan struct{}) (result autorest.Response, err error) { func (client InterfacesClient) CreateOrUpdate(resourceGroupName string, networkInterfaceName string, parameters Interface, cancel <-chan struct{}) (<-chan Interface, <-chan error) {
if err := validation.Validate([]validation.Validation{ resultChan := make(chan Interface, 1)
{TargetValue: parameters, errChan := make(chan error, 1)
Constraints: []validation.Constraint{{Target: "parameters.InterfacePropertiesFormat", Name: validation.Null, Rule: false, go func() {
Chain: []validation.Constraint{{Target: "parameters.InterfacePropertiesFormat.NetworkSecurityGroup", Name: validation.Null, Rule: false, var err error
Chain: []validation.Constraint{{Target: "parameters.InterfacePropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false, var result Interface
Chain: []validation.Constraint{{Target: "parameters.InterfacePropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil}, defer func() {
{Target: "parameters.InterfacePropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}, resultChan <- result
}}, errChan <- err
}}, close(resultChan)
}}}}}); err != nil { close(errChan)
return result, validation.NewErrorWithValidationError(err, "network.InterfacesClient", "CreateOrUpdate") }()
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkInterfaceName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkInterfaceName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -94,8 +89,9 @@ func (client InterfacesClient) CreateOrUpdatePreparer(resourceGroupName string,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -118,41 +114,55 @@ func (client InterfacesClient) CreateOrUpdateSender(req *http.Request) (*http.Re
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client InterfacesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client InterfacesClient) CreateOrUpdateResponder(resp *http.Response) (result Interface, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified network interface. This method may poll for // Delete deletes the specified network interface. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. networkInterfaceName // resourceGroupName is the name of the resource group. networkInterfaceName is
// is the name of the network interface. // the name of the network interface.
func (client InterfacesClient) Delete(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client InterfacesClient) Delete(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, networkInterfaceName, cancel) req, err := client.DeletePreparer(resourceGroupName, networkInterfaceName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -163,8 +173,9 @@ func (client InterfacesClient) DeletePreparer(resourceGroupName string, networkI
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -197,19 +208,20 @@ func (client InterfacesClient) DeleteResponder(resp *http.Response) (result auto
// Get gets information about the specified network interface. // Get gets information about the specified network interface.
// //
// resourceGroupName is the name of the resource group. networkInterfaceName // resourceGroupName is the name of the resource group. networkInterfaceName is
// is the name of the network interface. expand is expands referenced // the name of the network interface. expand is expands referenced resources.
// resources.
func (client InterfacesClient) Get(resourceGroupName string, networkInterfaceName string, expand string) (result Interface, err error) { func (client InterfacesClient) Get(resourceGroupName string, networkInterfaceName string, expand string) (result Interface, err error) {
req, err := client.GetPreparer(resourceGroupName, networkInterfaceName, expand) req, err := client.GetPreparer(resourceGroupName, networkInterfaceName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -228,8 +240,9 @@ func (client InterfacesClient) GetPreparer(resourceGroupName string, networkInte
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -262,31 +275,44 @@ func (client InterfacesClient) GetResponder(resp *http.Response) (result Interfa
return return
} }
// GetEffectiveRouteTable gets all route tables applied to a network // GetEffectiveRouteTable gets all route tables applied to a network interface.
// interface. This method may poll for completion. Polling can be canceled by // This method may poll for completion. Polling can be canceled by passing the
// passing the cancel channel argument. The channel will be used to cancel // cancel channel argument. The channel will be used to cancel polling and any
// polling and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. networkInterfaceName // resourceGroupName is the name of the resource group. networkInterfaceName is
// is the name of the network interface. // the name of the network interface.
func (client InterfacesClient) GetEffectiveRouteTable(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client InterfacesClient) GetEffectiveRouteTable(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan EffectiveRouteListResult, <-chan error) {
resultChan := make(chan EffectiveRouteListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result EffectiveRouteListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.GetEffectiveRouteTablePreparer(resourceGroupName, networkInterfaceName, cancel) req, err := client.GetEffectiveRouteTablePreparer(resourceGroupName, networkInterfaceName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", nil, "Failure preparing request")
return
} }
resp, err := client.GetEffectiveRouteTableSender(req) resp, err := client.GetEffectiveRouteTableSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure sending request")
return
} }
result, err = client.GetEffectiveRouteTableResponder(resp) result, err = client.GetEffectiveRouteTableResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetEffectiveRouteTable", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// GetEffectiveRouteTablePreparer prepares the GetEffectiveRouteTable request. // GetEffectiveRouteTablePreparer prepares the GetEffectiveRouteTable request.
@ -297,8 +323,9 @@ func (client InterfacesClient) GetEffectiveRouteTablePreparer(resourceGroupName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -319,13 +346,14 @@ func (client InterfacesClient) GetEffectiveRouteTableSender(req *http.Request) (
// GetEffectiveRouteTableResponder handles the response to the GetEffectiveRouteTable request. The method always // GetEffectiveRouteTableResponder handles the response to the GetEffectiveRouteTable request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Response) (result autorest.Response, err error) { func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Response) (result EffectiveRouteListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -339,13 +367,15 @@ func (client InterfacesClient) GetEffectiveRouteTableResponder(resp *http.Respon
func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterface(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (result Interface, err error) { func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterface(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string, networkInterfaceName string, expand string) (result Interface, err error) {
req, err := client.GetVirtualMachineScaleSetNetworkInterfacePreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand) req, err := client.GetVirtualMachineScaleSetNetworkInterfacePreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex, networkInterfaceName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", nil, "Failure preparing request")
return
} }
resp, err := client.GetVirtualMachineScaleSetNetworkInterfaceSender(req) resp, err := client.GetVirtualMachineScaleSetNetworkInterfaceSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "GetVirtualMachineScaleSetNetworkInterface", resp, "Failure sending request")
return
} }
result, err = client.GetVirtualMachineScaleSetNetworkInterfaceResponder(resp) result, err = client.GetVirtualMachineScaleSetNetworkInterfaceResponder(resp)
@ -366,8 +396,9 @@ func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterfacePreparer
"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
} }
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -406,13 +437,15 @@ func (client InterfacesClient) GetVirtualMachineScaleSetNetworkInterfaceResponde
func (client InterfacesClient) List(resourceGroupName string) (result InterfaceListResult, err error) { func (client InterfacesClient) List(resourceGroupName string) (result InterfaceListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -430,8 +463,9 @@ func (client InterfacesClient) ListPreparer(resourceGroupName string) (*http.Req
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -489,13 +523,15 @@ func (client InterfacesClient) ListNextResults(lastResults InterfaceListResult)
func (client InterfacesClient) ListAll() (result InterfaceListResult, err error) { func (client InterfacesClient) ListAll() (result InterfaceListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -512,8 +548,9 @@ func (client InterfacesClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -568,30 +605,43 @@ func (client InterfacesClient) ListAllNextResults(lastResults InterfaceListResul
} }
// ListEffectiveNetworkSecurityGroups gets all network security groups applied // ListEffectiveNetworkSecurityGroups gets all network security groups applied
// to a network interface. This method may poll for completion. Polling can // to a network interface. This method may poll for completion. Polling can be
// be canceled by passing the cancel channel argument. The channel will be // canceled by passing the cancel channel argument. The channel will be used to
// used to cancel polling and any outstanding HTTP requests. // cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. networkInterfaceName // resourceGroupName is the name of the resource group. networkInterfaceName is
// is the name of the network interface. // the name of the network interface.
func (client InterfacesClient) ListEffectiveNetworkSecurityGroups(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client InterfacesClient) ListEffectiveNetworkSecurityGroups(resourceGroupName string, networkInterfaceName string, cancel <-chan struct{}) (<-chan EffectiveNetworkSecurityGroupListResult, <-chan error) {
resultChan := make(chan EffectiveNetworkSecurityGroupListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result EffectiveNetworkSecurityGroupListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ListEffectiveNetworkSecurityGroupsPreparer(resourceGroupName, networkInterfaceName, cancel) req, err := client.ListEffectiveNetworkSecurityGroupsPreparer(resourceGroupName, networkInterfaceName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", nil, "Failure preparing request")
return
} }
resp, err := client.ListEffectiveNetworkSecurityGroupsSender(req) resp, err := client.ListEffectiveNetworkSecurityGroupsSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure sending request")
return
} }
result, err = client.ListEffectiveNetworkSecurityGroupsResponder(resp) result, err = client.ListEffectiveNetworkSecurityGroupsResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListEffectiveNetworkSecurityGroups", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ListEffectiveNetworkSecurityGroupsPreparer prepares the ListEffectiveNetworkSecurityGroups request. // ListEffectiveNetworkSecurityGroupsPreparer prepares the ListEffectiveNetworkSecurityGroups request.
@ -602,8 +652,9 @@ func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsPreparer(resour
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -624,31 +675,34 @@ func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsSender(req *htt
// ListEffectiveNetworkSecurityGroupsResponder handles the response to the ListEffectiveNetworkSecurityGroups request. The method always // ListEffectiveNetworkSecurityGroupsResponder handles the response to the ListEffectiveNetworkSecurityGroups request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsResponder(resp *http.Response) (result autorest.Response, err error) { func (client InterfacesClient) ListEffectiveNetworkSecurityGroupsResponder(resp *http.Response) (result EffectiveNetworkSecurityGroupListResult, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// ListVirtualMachineScaleSetNetworkInterfaces gets all network interfaces in // ListVirtualMachineScaleSetNetworkInterfaces gets all network interfaces in a
// a virtual machine scale set. // virtual machine scale set.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualMachineScaleSetName is the name of the virtual machine scale set. // virtualMachineScaleSetName is the name of the virtual machine scale set.
func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string) (result InterfaceListResult, err error) { func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string) (result InterfaceListResult, err error) {
req, err := client.ListVirtualMachineScaleSetNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName) req, err := client.ListVirtualMachineScaleSetNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", nil, "Failure preparing request")
return
} }
resp, err := client.ListVirtualMachineScaleSetNetworkInterfacesSender(req) resp, err := client.ListVirtualMachineScaleSetNetworkInterfacesSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetNetworkInterfaces", resp, "Failure sending request")
return
} }
result, err = client.ListVirtualMachineScaleSetNetworkInterfacesResponder(resp) result, err = client.ListVirtualMachineScaleSetNetworkInterfacesResponder(resp)
@ -667,8 +721,9 @@ func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesPrepar
"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
} }
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -731,13 +786,15 @@ func (client InterfacesClient) ListVirtualMachineScaleSetNetworkInterfacesNextRe
func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string) (result InterfaceListResult, err error) { func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfaces(resourceGroupName string, virtualMachineScaleSetName string, virtualmachineIndex string) (result InterfaceListResult, err error) {
req, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex) req, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesPreparer(resourceGroupName, virtualMachineScaleSetName, virtualmachineIndex)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", nil, "Failure preparing request")
return
} }
resp, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesSender(req) resp, err := client.ListVirtualMachineScaleSetVMNetworkInterfacesSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.InterfacesClient", "ListVirtualMachineScaleSetVMNetworkInterfaces", resp, "Failure sending request")
return
} }
result, err = client.ListVirtualMachineScaleSetVMNetworkInterfacesResponder(resp) result, err = client.ListVirtualMachineScaleSetVMNetworkInterfacesResponder(resp)
@ -757,8 +814,9 @@ func (client InterfacesClient) ListVirtualMachineScaleSetVMNetworkInterfacesPrep
"virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName), "virtualMachineScaleSetName": autorest.Encode("path", virtualMachineScaleSetName),
} }
const APIVersion = "2016-09-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

120
vendor/github.com/Azure/azure-sdk-for-go/arm/network/loadbalancers.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,7 @@ import (
"net/http" "net/http"
) )
// LoadBalancersClient is the the Microsoft Azure Network management API // LoadBalancersClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type LoadBalancersClient struct { type LoadBalancersClient struct {
ManagementClient ManagementClient
} }
@ -46,31 +42,44 @@ func NewLoadBalancersClientWithBaseURI(baseURI string, subscriptionID string) Lo
} }
// CreateOrUpdate creates or updates a load balancer. This method may poll for // CreateOrUpdate creates or updates a load balancer. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is the
// the name of the load balancer. parameters is parameters supplied to the // name of the load balancer. parameters is parameters supplied to the create
// create or update load balancer operation. // or update load balancer operation.
func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (result autorest.Response, err error) { func (client LoadBalancersClient) CreateOrUpdate(resourceGroupName string, loadBalancerName string, parameters LoadBalancer, cancel <-chan struct{}) (<-chan LoadBalancer, <-chan error) {
resultChan := make(chan LoadBalancer, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result LoadBalancer
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -81,8 +90,9 @@ func (client LoadBalancersClient) CreateOrUpdatePreparer(resourceGroupName strin
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -105,41 +115,55 @@ func (client LoadBalancersClient) CreateOrUpdateSender(req *http.Request) (*http
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (result LoadBalancer, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified load balancer. This method may poll for // Delete deletes the specified load balancer. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is the
// the name of the load balancer. // name of the load balancer.
func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client LoadBalancersClient) Delete(resourceGroupName string, loadBalancerName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel) req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -150,8 +174,9 @@ func (client LoadBalancersClient) DeletePreparer(resourceGroupName string, loadB
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -184,18 +209,20 @@ func (client LoadBalancersClient) DeleteResponder(resp *http.Response) (result a
// Get gets the specified load balancer. // Get gets the specified load balancer.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is the
// the name of the load balancer. expand is expands referenced resources. // name of the load balancer. expand is expands referenced resources.
func (client LoadBalancersClient) Get(resourceGroupName string, loadBalancerName string, expand string) (result LoadBalancer, err error) { func (client LoadBalancersClient) Get(resourceGroupName string, loadBalancerName string, expand string) (result LoadBalancer, err error) {
req, err := client.GetPreparer(resourceGroupName, loadBalancerName, expand) req, err := client.GetPreparer(resourceGroupName, loadBalancerName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -214,8 +241,9 @@ func (client LoadBalancersClient) GetPreparer(resourceGroupName string, loadBala
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -254,13 +282,15 @@ func (client LoadBalancersClient) GetResponder(resp *http.Response) (result Load
func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) { func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -278,8 +308,9 @@ func (client LoadBalancersClient) ListPreparer(resourceGroupName string) (*http.
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -337,13 +368,15 @@ func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListRe
func (client LoadBalancersClient) ListAll() (result LoadBalancerListResult, err error) { func (client LoadBalancersClient) ListAll() (result LoadBalancerListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -360,8 +393,9 @@ func (client LoadBalancersClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

141
vendor/github.com/Azure/azure-sdk-for-go/arm/network/localnetworkgateways.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// LocalNetworkGatewaysClient is the the Microsoft Azure Network management // LocalNetworkGatewaysClient is the composite Swagger for Network Client
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type LocalNetworkGatewaysClient struct { type LocalNetworkGatewaysClient struct {
ManagementClient ManagementClient
} }
@ -47,41 +43,55 @@ func NewLocalNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID str
} }
// CreateOrUpdate creates or updates a local network gateway in the specified // CreateOrUpdate creates or updates a local network gateway in the specified
// resource group. This method may poll for completion. Polling can be // resource group. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group. localNetworkGatewayName
// localNetworkGatewayName is the name of the local network gateway. // is the name of the local network gateway. parameters is parameters supplied
// parameters is parameters supplied to the create or update local network // to the create or update local network gateway operation.
// gateway operation. func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (<-chan LocalNetworkGateway, <-chan error) {
func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) { resultChan := make(chan LocalNetworkGateway, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: localNetworkGatewayName,
Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}},
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
Chain: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil}, errChan <- validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate")
{Target: "parameters.LocalNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil}, close(errChan)
}}}}}); err != nil { close(resultChan)
return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate") return resultChan, errChan
} }
go func() {
var err error
var result LocalNetworkGateway
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, localNetworkGatewayName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, localNetworkGatewayName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -92,8 +102,9 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -116,41 +127,64 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdateSender(req *http.Request)
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result LocalNetworkGateway, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified local network gateway. This method may poll // Delete deletes the specified local network gateway. This method may poll for
// for completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group. localNetworkGatewayName
// localNetworkGatewayName is the name of the local network gateway. // is the name of the local network gateway.
func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localNetworkGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client LocalNetworkGatewaysClient) Delete(resourceGroupName string, localNetworkGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{
{TargetValue: localNetworkGatewayName,
Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
errChan <- validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "Delete")
close(errChan)
close(resultChan)
return resultChan, errChan
}
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, localNetworkGatewayName, cancel) req, err := client.DeletePreparer(resourceGroupName, localNetworkGatewayName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -161,8 +195,9 @@ func (client LocalNetworkGatewaysClient) DeletePreparer(resourceGroupName string
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -195,18 +230,26 @@ func (client LocalNetworkGatewaysClient) DeleteResponder(resp *http.Response) (r
// Get gets the specified local network gateway in a resource group. // Get gets the specified local network gateway in a resource group.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group. localNetworkGatewayName
// localNetworkGatewayName is the name of the local network gateway. // is the name of the local network gateway.
func (client LocalNetworkGatewaysClient) Get(resourceGroupName string, localNetworkGatewayName string) (result LocalNetworkGateway, err error) { func (client LocalNetworkGatewaysClient) Get(resourceGroupName string, localNetworkGatewayName string) (result LocalNetworkGateway, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: localNetworkGatewayName,
Constraints: []validation.Constraint{{Target: "localNetworkGatewayName", Name: validation.MinLength, Rule: 1, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "Get")
}
req, err := client.GetPreparer(resourceGroupName, localNetworkGatewayName) req, err := client.GetPreparer(resourceGroupName, localNetworkGatewayName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -225,8 +268,9 @@ func (client LocalNetworkGatewaysClient) GetPreparer(resourceGroupName string, l
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -262,13 +306,15 @@ func (client LocalNetworkGatewaysClient) GetResponder(resp *http.Response) (resu
func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) { func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -286,8 +332,9 @@ func (client LocalNetworkGatewaysClient) ListPreparer(resourceGroupName string)
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

984
vendor/github.com/Azure/azure-sdk-for-go/arm/network/models.go generated vendored Normal file → Executable file

File diff suppressed because it is too large Load Diff

134
vendor/github.com/Azure/azure-sdk-for-go/arm/network/publicipaddresses.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// PublicIPAddressesClient is the the Microsoft Azure Network management API // PublicIPAddressesClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type PublicIPAddressesClient struct { type PublicIPAddressesClient struct {
ManagementClient ManagementClient
} }
@ -47,59 +43,58 @@ func NewPublicIPAddressesClientWithBaseURI(baseURI string, subscriptionID string
} }
// CreateOrUpdate creates or updates a static or dynamic public IP address. // CreateOrUpdate creates or updates a static or dynamic public IP address.
// This method may poll for completion. Polling can be canceled by passing // This method may poll for completion. Polling can be canceled by passing the
// the cancel channel argument. The channel will be used to cancel polling // cancel channel argument. The channel will be used to cancel polling and any
// and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. publicIPAddressName is // resourceGroupName is the name of the resource group. publicIPAddressName is
// the name of the public IP address. parameters is parameters supplied to // the name of the public IP address. parameters is parameters supplied to the
// the create or update public IP address operation. // create or update public IP address operation.
func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, cancel <-chan struct{}) (result autorest.Response, err error) { func (client PublicIPAddressesClient) CreateOrUpdate(resourceGroupName string, publicIPAddressName string, parameters PublicIPAddress, cancel <-chan struct{}) (<-chan PublicIPAddress, <-chan error) {
resultChan := make(chan PublicIPAddress, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false, Constraints: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil}}},
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.NetworkSecurityGroup", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}, }},
}},
{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.RouteTable", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}},
}},
{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.Subnet.SubnetPropertiesFormat.IPConfigurations", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration.IPConfigurationPropertiesFormat.PublicIPAddress", Name: validation.Null, Rule: false, Chain: nil},
}},
}},
{Target: "parameters.PublicIPAddressPropertiesFormat.IPConfiguration", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.PublicIPAddressesClient", "CreateOrUpdate") errChan <- validation.NewErrorWithValidationError(err, "network.PublicIPAddressesClient", "CreateOrUpdate")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result PublicIPAddress
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, publicIPAddressName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, publicIPAddressName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -110,8 +105,9 @@ func (client PublicIPAddressesClient) CreateOrUpdatePreparer(resourceGroupName s
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -134,41 +130,55 @@ func (client PublicIPAddressesClient) CreateOrUpdateSender(req *http.Request) (*
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client PublicIPAddressesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client PublicIPAddressesClient) CreateOrUpdateResponder(resp *http.Response) (result PublicIPAddress, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified public IP address. This method may poll for // Delete deletes the specified public IP address. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. publicIPAddressName is // resourceGroupName is the name of the resource group. publicIPAddressName is
// the name of the subnet. // the name of the subnet.
func (client PublicIPAddressesClient) Delete(resourceGroupName string, publicIPAddressName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client PublicIPAddressesClient) Delete(resourceGroupName string, publicIPAddressName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, publicIPAddressName, cancel) req, err := client.DeletePreparer(resourceGroupName, publicIPAddressName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -179,8 +189,9 @@ func (client PublicIPAddressesClient) DeletePreparer(resourceGroupName string, p
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -218,13 +229,15 @@ func (client PublicIPAddressesClient) DeleteResponder(resp *http.Response) (resu
func (client PublicIPAddressesClient) Get(resourceGroupName string, publicIPAddressName string, expand string) (result PublicIPAddress, err error) { func (client PublicIPAddressesClient) Get(resourceGroupName string, publicIPAddressName string, expand string) (result PublicIPAddress, err error) {
req, err := client.GetPreparer(resourceGroupName, publicIPAddressName, expand) req, err := client.GetPreparer(resourceGroupName, publicIPAddressName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -243,8 +256,9 @@ func (client PublicIPAddressesClient) GetPreparer(resourceGroupName string, publ
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -283,13 +297,15 @@ func (client PublicIPAddressesClient) GetResponder(resp *http.Response) (result
func (client PublicIPAddressesClient) List(resourceGroupName string) (result PublicIPAddressListResult, err error) { func (client PublicIPAddressesClient) List(resourceGroupName string) (result PublicIPAddressListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -307,8 +323,9 @@ func (client PublicIPAddressesClient) ListPreparer(resourceGroupName string) (*h
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -366,13 +383,15 @@ func (client PublicIPAddressesClient) ListNextResults(lastResults PublicIPAddres
func (client PublicIPAddressesClient) ListAll() (result PublicIPAddressListResult, err error) { func (client PublicIPAddressesClient) ListAll() (result PublicIPAddressListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.PublicIPAddressesClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -389,8 +408,9 @@ func (client PublicIPAddressesClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

98
vendor/github.com/Azure/azure-sdk-for-go/arm/network/routes.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,7 @@ import (
"net/http" "net/http"
) )
// RoutesClient is the the Microsoft Azure Network management API provides a // RoutesClient is the composite Swagger for Network Client
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type RoutesClient struct { type RoutesClient struct {
ManagementClient ManagementClient
} }
@ -43,33 +39,45 @@ func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesCli
return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)} return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate creates or updates a route in the specified route table. // CreateOrUpdate creates or updates a route in the specified route table. This
// This method may poll for completion. Polling can be canceled by passing // method may poll for completion. Polling can be canceled by passing the
// the cancel channel argument. The channel will be used to cancel polling // cancel channel argument. The channel will be used to cancel polling and any
// and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. routeTableName is the // resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. routeName is the name of the route. // name of the route table. routeName is the name of the route. routeParameters
// routeParameters is parameters supplied to the create or update route // is parameters supplied to the create or update route operation.
// operation. func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (<-chan Route, <-chan error) {
func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (result autorest.Response, err error) { resultChan := make(chan Route, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result Route
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -81,8 +89,9 @@ func (client RoutesClient) CreateOrUpdatePreparer(resourceGroupName string, rout
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -105,13 +114,14 @@ func (client RoutesClient) CreateOrUpdateSender(req *http.Request) (*http.Respon
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result Route, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -122,24 +132,37 @@ func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result
// //
// resourceGroupName is the name of the resource group. routeTableName is the // resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. routeName is the name of the route. // name of the route table. routeName is the name of the route.
func (client RoutesClient) Delete(resourceGroupName string, routeTableName string, routeName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client RoutesClient) Delete(resourceGroupName string, routeTableName string, routeName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, routeTableName, routeName, cancel) req, err := client.DeletePreparer(resourceGroupName, routeTableName, routeName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -151,8 +174,9 @@ func (client RoutesClient) DeletePreparer(resourceGroupName string, routeTableNa
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -190,13 +214,15 @@ func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest
func (client RoutesClient) Get(resourceGroupName string, routeTableName string, routeName string) (result Route, err error) { func (client RoutesClient) Get(resourceGroupName string, routeTableName string, routeName string) (result Route, err error) {
req, err := client.GetPreparer(resourceGroupName, routeTableName, routeName) req, err := client.GetPreparer(resourceGroupName, routeTableName, routeName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -216,8 +242,9 @@ func (client RoutesClient) GetPreparer(resourceGroupName string, routeTableName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -254,13 +281,15 @@ func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err
func (client RoutesClient) List(resourceGroupName string, routeTableName string) (result RouteListResult, err error) { func (client RoutesClient) List(resourceGroupName string, routeTableName string) (result RouteListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, routeTableName) req, err := client.ListPreparer(resourceGroupName, routeTableName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -279,8 +308,9 @@ func (client RoutesClient) ListPreparer(resourceGroupName string, routeTableName
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

116
vendor/github.com/Azure/azure-sdk-for-go/arm/network/routetables.go generated vendored Normal file → Executable file
View File

@ -14,22 +14,17 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
// RouteTablesClient is the the Microsoft Azure Network management API // RouteTablesClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type RouteTablesClient struct { type RouteTablesClient struct {
ManagementClient ManagementClient
} }
@ -39,8 +34,8 @@ func NewRouteTablesClient(subscriptionID string) RouteTablesClient {
return NewRouteTablesClientWithBaseURI(DefaultBaseURI, subscriptionID) return NewRouteTablesClientWithBaseURI(DefaultBaseURI, subscriptionID)
} }
// NewRouteTablesClientWithBaseURI creates an instance of the // NewRouteTablesClientWithBaseURI creates an instance of the RouteTablesClient
// RouteTablesClient client. // client.
func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) RouteTablesClient { func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) RouteTablesClient {
return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)} return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
@ -51,33 +46,39 @@ func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) Rout
// polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. routeTableName is the // resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. parameters is parameters supplied to the create // name of the route table. parameters is parameters supplied to the create or
// or update route table operation. // update route table operation.
func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (result autorest.Response, err error) { func (client RouteTablesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, parameters RouteTable, cancel <-chan struct{}) (<-chan RouteTable, <-chan error) {
if err := validation.Validate([]validation.Validation{ resultChan := make(chan RouteTable, 1)
{TargetValue: parameters, errChan := make(chan error, 1)
Constraints: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat", Name: validation.Null, Rule: false, go func() {
Chain: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil { var err error
return result, validation.NewErrorWithValidationError(err, "network.RouteTablesClient", "CreateOrUpdate") var result RouteTable
} defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -88,8 +89,9 @@ func (client RouteTablesClient) CreateOrUpdatePreparer(resourceGroupName string,
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -112,41 +114,55 @@ func (client RouteTablesClient) CreateOrUpdateSender(req *http.Request) (*http.R
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (result RouteTable, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified route table. This method may poll for // Delete deletes the specified route table. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. routeTableName is the // resourceGroupName is the name of the resource group. routeTableName is the
// name of the route table. // name of the route table.
func (client RouteTablesClient) Delete(resourceGroupName string, routeTableName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client RouteTablesClient) Delete(resourceGroupName string, routeTableName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, routeTableName, cancel) req, err := client.DeletePreparer(resourceGroupName, routeTableName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -157,8 +173,9 @@ func (client RouteTablesClient) DeletePreparer(resourceGroupName string, routeTa
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -196,13 +213,15 @@ func (client RouteTablesClient) DeleteResponder(resp *http.Response) (result aut
func (client RouteTablesClient) Get(resourceGroupName string, routeTableName string, expand string) (result RouteTable, err error) { func (client RouteTablesClient) Get(resourceGroupName string, routeTableName string, expand string) (result RouteTable, err error) {
req, err := client.GetPreparer(resourceGroupName, routeTableName, expand) req, err := client.GetPreparer(resourceGroupName, routeTableName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -221,8 +240,9 @@ func (client RouteTablesClient) GetPreparer(resourceGroupName string, routeTable
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -261,13 +281,15 @@ func (client RouteTablesClient) GetResponder(resp *http.Response) (result RouteT
func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) { func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -285,8 +307,9 @@ func (client RouteTablesClient) ListPreparer(resourceGroupName string) (*http.Re
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -344,13 +367,15 @@ func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult
func (client RouteTablesClient) ListAll() (result RouteTableListResult, err error) { func (client RouteTablesClient) ListAll() (result RouteTableListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -367,8 +392,9 @@ func (client RouteTablesClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

110
vendor/github.com/Azure/azure-sdk-for-go/arm/network/securitygroups.go generated vendored Normal file → Executable file
View File

@ -14,22 +14,17 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
// SecurityGroupsClient is the the Microsoft Azure Network management API // SecurityGroupsClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SecurityGroupsClient struct { type SecurityGroupsClient struct {
ManagementClient ManagementClient
} }
@ -47,41 +42,45 @@ func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) S
} }
// CreateOrUpdate creates or updates a network security group in the specified // CreateOrUpdate creates or updates a network security group in the specified
// resource group. This method may poll for completion. Polling can be // resource group. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group. // networkSecurityGroupName is the name of the network security group.
// parameters is parameters supplied to the create or update network security // parameters is parameters supplied to the create or update network security
// group operation. // group operation.
func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (result autorest.Response, err error) { func (client SecurityGroupsClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, parameters SecurityGroup, cancel <-chan struct{}) (<-chan SecurityGroup, <-chan error) {
if err := validation.Validate([]validation.Validation{ resultChan := make(chan SecurityGroup, 1)
{TargetValue: parameters, errChan := make(chan error, 1)
Constraints: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false, go func() {
Chain: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil}, var err error
{Target: "parameters.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}, var result SecurityGroup
}}}}}); err != nil { defer func() {
return result, validation.NewErrorWithValidationError(err, "network.SecurityGroupsClient", "CreateOrUpdate") resultChan <- result
} errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -92,8 +91,9 @@ func (client SecurityGroupsClient) CreateOrUpdatePreparer(resourceGroupName stri
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -116,13 +116,14 @@ func (client SecurityGroupsClient) CreateOrUpdateSender(req *http.Request) (*htt
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) (result SecurityGroup, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -133,24 +134,37 @@ func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response)
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group. // networkSecurityGroupName is the name of the network security group.
func (client SecurityGroupsClient) Delete(resourceGroupName string, networkSecurityGroupName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client SecurityGroupsClient) Delete(resourceGroupName string, networkSecurityGroupName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, cancel) req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -161,8 +175,9 @@ func (client SecurityGroupsClient) DeletePreparer(resourceGroupName string, netw
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -201,13 +216,15 @@ func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result
func (client SecurityGroupsClient) Get(resourceGroupName string, networkSecurityGroupName string, expand string) (result SecurityGroup, err error) { func (client SecurityGroupsClient) Get(resourceGroupName string, networkSecurityGroupName string, expand string) (result SecurityGroup, err error) {
req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, expand) req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -226,8 +243,9 @@ func (client SecurityGroupsClient) GetPreparer(resourceGroupName string, network
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -266,13 +284,15 @@ func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result Sec
func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) { func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -290,8 +310,9 @@ func (client SecurityGroupsClient) ListPreparer(resourceGroupName string) (*http
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -349,13 +370,15 @@ func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupList
func (client SecurityGroupsClient) ListAll() (result SecurityGroupListResult, err error) { func (client SecurityGroupsClient) ListAll() (result SecurityGroupListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -372,8 +395,9 @@ func (client SecurityGroupsClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

109
vendor/github.com/Azure/azure-sdk-for-go/arm/network/securityrules.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// SecurityRulesClient is the the Microsoft Azure Network management API // SecurityRulesClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SecurityRulesClient struct { type SecurityRulesClient struct {
ManagementClient ManagementClient
} }
@ -47,42 +43,57 @@ func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) Se
} }
// CreateOrUpdate creates or updates a security rule in the specified network // CreateOrUpdate creates or updates a security rule in the specified network
// security group. This method may poll for completion. Polling can be // security group. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group. // networkSecurityGroupName is the name of the network security group.
// securityRuleName is the name of the security rule. securityRuleParameters // securityRuleName is the name of the security rule. securityRuleParameters is
// is parameters supplied to the create or update network security rule // parameters supplied to the create or update network security rule operation.
// operation. func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (<-chan SecurityRule, <-chan error) {
func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (result autorest.Response, err error) { resultChan := make(chan SecurityRule, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: securityRuleParameters, {TargetValue: securityRuleParameters,
Constraints: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat", Name: validation.Null, Rule: false, Constraints: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat.SourceAddressPrefix", Name: validation.Null, Rule: true, Chain: nil}, Chain: []validation.Constraint{{Target: "securityRuleParameters.SecurityRulePropertiesFormat.SourceAddressPrefix", Name: validation.Null, Rule: true, Chain: nil},
{Target: "securityRuleParameters.SecurityRulePropertiesFormat.DestinationAddressPrefix", Name: validation.Null, Rule: true, Chain: nil}, {Target: "securityRuleParameters.SecurityRulePropertiesFormat.DestinationAddressPrefix", Name: validation.Null, Rule: true, Chain: nil},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate") errChan <- validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result SecurityRule
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, securityRuleParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -94,8 +105,9 @@ func (client SecurityRulesClient) CreateOrUpdatePreparer(resourceGroupName strin
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -118,42 +130,56 @@ func (client SecurityRulesClient) CreateOrUpdateSender(req *http.Request) (*http
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (result SecurityRule, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified network security rule. This method may poll // Delete deletes the specified network security rule. This method may poll for
// for completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// networkSecurityGroupName is the name of the network security group. // networkSecurityGroupName is the name of the network security group.
// securityRuleName is the name of the security rule. // securityRuleName is the name of the security rule.
func (client SecurityRulesClient) Delete(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client SecurityRulesClient) Delete(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, cancel) req, err := client.DeletePreparer(resourceGroupName, networkSecurityGroupName, securityRuleName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -165,8 +191,9 @@ func (client SecurityRulesClient) DeletePreparer(resourceGroupName string, netwo
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -205,13 +232,15 @@ func (client SecurityRulesClient) DeleteResponder(resp *http.Response) (result a
func (client SecurityRulesClient) Get(resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (result SecurityRule, err error) { func (client SecurityRulesClient) Get(resourceGroupName string, networkSecurityGroupName string, securityRuleName string) (result SecurityRule, err error) {
req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, securityRuleName) req, err := client.GetPreparer(resourceGroupName, networkSecurityGroupName, securityRuleName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -231,8 +260,9 @@ func (client SecurityRulesClient) GetPreparer(resourceGroupName string, networkS
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -269,13 +299,15 @@ func (client SecurityRulesClient) GetResponder(resp *http.Response) (result Secu
func (client SecurityRulesClient) List(resourceGroupName string, networkSecurityGroupName string) (result SecurityRuleListResult, err error) { func (client SecurityRulesClient) List(resourceGroupName string, networkSecurityGroupName string) (result SecurityRuleListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, networkSecurityGroupName) req, err := client.ListPreparer(resourceGroupName, networkSecurityGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -294,8 +326,9 @@ func (client SecurityRulesClient) ListPreparer(resourceGroupName string, network
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

116
vendor/github.com/Azure/azure-sdk-for-go/arm/network/subnets.go generated vendored Normal file → Executable file
View File

@ -14,22 +14,17 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import ( import (
"github.com/Azure/go-autorest/autorest" "github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure" "github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http" "net/http"
) )
// SubnetsClient is the the Microsoft Azure Network management API provides a // SubnetsClient is the composite Swagger for Network Client
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type SubnetsClient struct { type SubnetsClient struct {
ManagementClient ManagementClient
} }
@ -44,51 +39,46 @@ func NewSubnetsClientWithBaseURI(baseURI string, subscriptionID string) SubnetsC
return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)} return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate creates or updates a subnet in the specified virtual // CreateOrUpdate creates or updates a subnet in the specified virtual network.
// network. This method may poll for completion. Polling can be canceled by // This method may poll for completion. Polling can be canceled by passing the
// passing the cancel channel argument. The channel will be used to cancel // cancel channel argument. The channel will be used to cancel polling and any
// polling and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. subnetName is the name of the subnet. // the name of the virtual network. subnetName is the name of the subnet.
// subnetParameters is parameters supplied to the create or update subnet // subnetParameters is parameters supplied to the create or update subnet
// operation. // operation.
func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (result autorest.Response, err error) { func (client SubnetsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, subnetName string, subnetParameters Subnet, cancel <-chan struct{}) (<-chan Subnet, <-chan error) {
if err := validation.Validate([]validation.Validation{ resultChan := make(chan Subnet, 1)
{TargetValue: subnetParameters, errChan := make(chan error, 1)
Constraints: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat", Name: validation.Null, Rule: false, go func() {
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup", Name: validation.Null, Rule: false, var err error
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false, var result Subnet
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil}, defer func() {
{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}, resultChan <- result
}}, errChan <- err
}}, close(resultChan)
{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable", Name: validation.Null, Rule: false, close(errChan)
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat", Name: validation.Null, Rule: false, }()
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}},
}},
{Target: "subnetParameters.SubnetPropertiesFormat.IPConfigurations", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SubnetsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, subnetName, subnetParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -100,8 +90,9 @@ func (client SubnetsClient) CreateOrUpdatePreparer(resourceGroupName string, vir
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -124,40 +115,54 @@ func (client SubnetsClient) CreateOrUpdateSender(req *http.Request) (*http.Respo
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result Subnet, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified subnet. This method may poll for completion. // Delete deletes the specified subnet. This method may poll for completion.
// Polling can be canceled by passing the cancel channel argument. The // Polling can be canceled by passing the cancel channel argument. The channel
// channel will be used to cancel polling and any outstanding HTTP requests. // will be used to cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. subnetName is the name of the subnet. // the name of the virtual network. subnetName is the name of the subnet.
func (client SubnetsClient) Delete(resourceGroupName string, virtualNetworkName string, subnetName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client SubnetsClient) Delete(resourceGroupName string, virtualNetworkName string, subnetName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, subnetName, cancel) req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, subnetName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -169,8 +174,9 @@ func (client SubnetsClient) DeletePreparer(resourceGroupName string, virtualNetw
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -209,13 +215,15 @@ func (client SubnetsClient) DeleteResponder(resp *http.Response) (result autores
func (client SubnetsClient) Get(resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (result Subnet, err error) { func (client SubnetsClient) Get(resourceGroupName string, virtualNetworkName string, subnetName string, expand string) (result Subnet, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, subnetName, expand) req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, subnetName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -235,8 +243,9 @@ func (client SubnetsClient) GetPreparer(resourceGroupName string, virtualNetwork
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -276,13 +285,15 @@ func (client SubnetsClient) GetResponder(resp *http.Response) (result Subnet, er
func (client SubnetsClient) List(resourceGroupName string, virtualNetworkName string) (result SubnetListResult, err error) { func (client SubnetsClient) List(resourceGroupName string, virtualNetworkName string) (result SubnetListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, virtualNetworkName) req, err := client.ListPreparer(resourceGroupName, virtualNetworkName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -301,8 +312,9 @@ func (client SubnetsClient) ListPreparer(resourceGroupName string, virtualNetwor
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

17
vendor/github.com/Azure/azure-sdk-for-go/arm/network/usages.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// UsagesClient is the the Microsoft Azure Network management API provides a // UsagesClient is the composite Swagger for Network Client
// RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure
// Networks service.
type UsagesClient struct { type UsagesClient struct {
ManagementClient ManagementClient
} }
@ -56,13 +52,15 @@ func (client UsagesClient) List(location string) (result UsagesListResult, err e
req, err := client.ListPreparer(location) req, err := client.ListPreparer(location)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -80,8 +78,9 @@ func (client UsagesClient) ListPreparer(location string) (*http.Request, error)
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

20
vendor/github.com/Azure/azure-sdk-for-go/arm/network/version.go generated vendored Normal file → Executable file
View File

@ -14,30 +14,16 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests. // UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string { func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "network", "2016-09-01") return "Azure-SDK-For-Go/v10.0.2-beta arm-network/"
} }
// Version returns the semantic version (see http://semver.org) of the client. // Version returns the semantic version (see http://semver.org) of the client.
func Version() string { func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag) return "v10.0.2-beta"
} }

View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,8 @@ import (
"net/http" "net/http"
) )
// VirtualNetworkGatewayConnectionsClient is the the Microsoft Azure Network // VirtualNetworkGatewayConnectionsClient is the composite Swagger for Network
// management API provides a RESTful set of web services that interact with // Client
// Microsoft Azure Networks service to manage your network resources. The API
// has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type VirtualNetworkGatewayConnectionsClient struct { type VirtualNetworkGatewayConnectionsClient struct {
ManagementClient ManagementClient
} }
@ -48,61 +45,60 @@ func NewVirtualNetworkGatewayConnectionsClientWithBaseURI(baseURI string, subscr
// CreateOrUpdate creates or updates a virtual network gateway connection in // CreateOrUpdate creates or updates a virtual network gateway connection in
// the specified resource group. This method may poll for completion. Polling // the specified resource group. This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will // can be canceled by passing the cancel channel argument. The channel will be
// be used to cancel polling and any outstanding HTTP requests. // used to cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayConnectionName is the name of the virtual network // virtualNetworkGatewayConnectionName is the name of the virtual network
// gateway connection. parameters is parameters supplied to the create or // gateway connection. parameters is parameters supplied to the create or
// update virtual network gateway connection operation. // update virtual network gateway connection operation.
func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters VirtualNetworkGatewayConnection, cancel <-chan struct{}) (<-chan VirtualNetworkGatewayConnection, <-chan error) {
resultChan := make(chan VirtualNetworkGatewayConnection, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}},
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway1.VirtualNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2", Name: validation.Null, Rule: false, {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}},
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.VirtualNetworkGateway2.VirtualNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2", Name: validation.Null, Rule: false, {Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}},
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.LocalNetworkGateway2.LocalNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.ConnectionStatus", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.TunnelConnectionStatus", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.EgressBytesTransferred", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.IngressBytesTransferred", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.VirtualNetworkGatewayConnectionPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate") errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result VirtualNetworkGatewayConnection
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -113,8 +109,9 @@ func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdatePreparer(reso
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -137,42 +134,56 @@ func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateSender(req *h
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGatewayConnection, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified virtual network Gateway connection. This // Delete deletes the specified virtual network Gateway connection. This method
// method may poll for completion. Polling can be canceled by passing the // may poll for completion. Polling can be canceled by passing the cancel
// cancel channel argument. The channel will be used to cancel polling and // channel argument. The channel will be used to cancel polling and any
// any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayConnectionName is the name of the virtual network // virtualNetworkGatewayConnectionName is the name of the virtual network
// gateway connection. // gateway connection.
func (client VirtualNetworkGatewayConnectionsClient) Delete(resourceGroupName string, virtualNetworkGatewayConnectionName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) Delete(resourceGroupName string, virtualNetworkGatewayConnectionName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, cancel) req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayConnectionName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -183,8 +194,9 @@ func (client VirtualNetworkGatewayConnectionsClient) DeletePreparer(resourceGrou
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -223,13 +235,15 @@ func (client VirtualNetworkGatewayConnectionsClient) DeleteResponder(resp *http.
func (client VirtualNetworkGatewayConnectionsClient) Get(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnection, err error) { func (client VirtualNetworkGatewayConnectionsClient) Get(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result VirtualNetworkGatewayConnection, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayConnectionName) req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayConnectionName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -248,8 +262,9 @@ func (client VirtualNetworkGatewayConnectionsClient) GetPreparer(resourceGroupNa
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -280,8 +295,8 @@ func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Res
} }
// GetSharedKey the Get VirtualNetworkGatewayConnectionSharedKey operation // GetSharedKey the Get VirtualNetworkGatewayConnectionSharedKey operation
// retrieves information about the specified virtual network gateway // retrieves information about the specified virtual network gateway connection
// connection shared key through Network resource provider. // shared key through Network resource provider.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayConnectionName is the virtual network gateway // virtualNetworkGatewayConnectionName is the virtual network gateway
@ -289,13 +304,15 @@ func (client VirtualNetworkGatewayConnectionsClient) GetResponder(resp *http.Res
func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result ConnectionSharedKey, err error) { func (client VirtualNetworkGatewayConnectionsClient) GetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string) (result ConnectionSharedKey, err error) {
req, err := client.GetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName) req, err := client.GetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", nil, "Failure preparing request")
return
} }
resp, err := client.GetSharedKeySender(req) resp, err := client.GetSharedKeySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "GetSharedKey", resp, "Failure sending request")
return
} }
result, err = client.GetSharedKeyResponder(resp) result, err = client.GetSharedKeyResponder(resp)
@ -314,8 +331,9 @@ func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyPreparer(resour
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -352,13 +370,15 @@ func (client VirtualNetworkGatewayConnectionsClient) GetSharedKeyResponder(resp
func (client VirtualNetworkGatewayConnectionsClient) List(resourceGroupName string) (result VirtualNetworkGatewayConnectionListResult, err error) { func (client VirtualNetworkGatewayConnectionsClient) List(resourceGroupName string) (result VirtualNetworkGatewayConnectionListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -376,8 +396,9 @@ func (client VirtualNetworkGatewayConnectionsClient) ListPreparer(resourceGroupN
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -432,44 +453,60 @@ func (client VirtualNetworkGatewayConnectionsClient) ListNextResults(lastResults
} }
// ResetSharedKey the VirtualNetworkGatewayConnectionResetSharedKey operation // ResetSharedKey the VirtualNetworkGatewayConnectionResetSharedKey operation
// resets the virtual network gateway connection shared key for passed // resets the virtual network gateway connection shared key for passed virtual
// virtual network gateway connection in the specified resource group through // network gateway connection in the specified resource group through Network
// Network resource provider. This method may poll for completion. Polling // resource provider. This method may poll for completion. Polling can be
// can be canceled by passing the cancel channel argument. The channel will // canceled by passing the cancel channel argument. The channel will be used to
// be used to cancel polling and any outstanding HTTP requests. // cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayConnectionName is the virtual network gateway // virtualNetworkGatewayConnectionName is the virtual network gateway
// connection reset shared key Name. parameters is parameters supplied to the // connection reset shared key Name. parameters is parameters supplied to the
// begin reset virtual network gateway connection shared key operation // begin reset virtual network gateway connection shared key operation through
// through network resource provider. // network resource provider.
func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionResetSharedKey, cancel <-chan struct{}) (<-chan ConnectionResetSharedKey, <-chan error) {
resultChan := make(chan ConnectionResetSharedKey, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.InclusiveMaximum, Rule: 128, Chain: nil}, Chain: []validation.Constraint{{Target: "parameters.KeyLength", Name: validation.InclusiveMaximum, Rule: 128, Chain: nil},
{Target: "parameters.KeyLength", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil}, {Target: "parameters.KeyLength", Name: validation.InclusiveMinimum, Rule: 1, Chain: nil},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey") errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result ConnectionResetSharedKey
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ResetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) req, err := client.ResetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", nil, "Failure preparing request")
return
} }
resp, err := client.ResetSharedKeySender(req) resp, err := client.ResetSharedKeySender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure sending request")
return
} }
result, err = client.ResetSharedKeyResponder(resp) result, err = client.ResetSharedKeyResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "ResetSharedKey", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ResetSharedKeyPreparer prepares the ResetSharedKey request. // ResetSharedKeyPreparer prepares the ResetSharedKey request.
@ -480,8 +517,9 @@ func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyPreparer(reso
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -504,52 +542,69 @@ func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeySender(req *h
// ResetSharedKeyResponder handles the response to the ResetSharedKey request. The method always // ResetSharedKeyResponder handles the response to the ResetSharedKey request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) ResetSharedKeyResponder(resp *http.Response) (result ConnectionResetSharedKey, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation // SetSharedKey the Put VirtualNetworkGatewayConnectionSharedKey operation sets
// sets the virtual network gateway connection shared key for passed virtual // the virtual network gateway connection shared key for passed virtual network
// network gateway connection in the specified resource group through Network // gateway connection in the specified resource group through Network resource
// resource provider. This method may poll for completion. Polling can be // provider. This method may poll for completion. Polling can be canceled by
// canceled by passing the cancel channel argument. The channel will be used // passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayConnectionName is the virtual network gateway // virtualNetworkGatewayConnectionName is the virtual network gateway
// connection name. parameters is parameters supplied to the Begin Set // connection name. parameters is parameters supplied to the Begin Set Virtual
// Virtual Network Gateway connection Shared key operation throughNetwork // Network Gateway connection Shared key operation throughNetwork resource
// resource provider. // provider.
func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) SetSharedKey(resourceGroupName string, virtualNetworkGatewayConnectionName string, parameters ConnectionSharedKey, cancel <-chan struct{}) (<-chan ConnectionSharedKey, <-chan error) {
resultChan := make(chan ConnectionSharedKey, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Value", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil { Constraints: []validation.Constraint{{Target: "parameters.Value", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey") errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result ConnectionSharedKey
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.SetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel) req, err := client.SetSharedKeyPreparer(resourceGroupName, virtualNetworkGatewayConnectionName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", nil, "Failure preparing request")
return
} }
resp, err := client.SetSharedKeySender(req) resp, err := client.SetSharedKeySender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure sending request")
return
} }
result, err = client.SetSharedKeyResponder(resp) result, err = client.SetSharedKeyResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewayConnectionsClient", "SetSharedKey", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// SetSharedKeyPreparer prepares the SetSharedKey request. // SetSharedKeyPreparer prepares the SetSharedKey request.
@ -560,8 +615,9 @@ func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyPreparer(resour
"virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName), "virtualNetworkGatewayConnectionName": autorest.Encode("path", virtualNetworkGatewayConnectionName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -584,12 +640,13 @@ func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeySender(req *htt
// SetSharedKeyResponder handles the response to the SetSharedKey request. The method always // SetSharedKeyResponder handles the response to the SetSharedKey request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkGatewayConnectionsClient) SetSharedKeyResponder(resp *http.Response) (result ConnectionSharedKey, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusCreated, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }

405
vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkgateways.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,11 +25,7 @@ import (
"net/http" "net/http"
) )
// VirtualNetworkGatewaysClient is the the Microsoft Azure Network management // VirtualNetworkGatewaysClient is the composite Swagger for Network Client
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type VirtualNetworkGatewaysClient struct { type VirtualNetworkGatewaysClient struct {
ManagementClient ManagementClient
} }
@ -46,42 +42,55 @@ func NewVirtualNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID s
return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} return VirtualNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate creates or updates a virtual network gateway in the // CreateOrUpdate creates or updates a virtual network gateway in the specified
// specified resource group. This method may poll for completion. Polling can // resource group. This method may poll for completion. Polling can be canceled
// be canceled by passing the cancel channel argument. The channel will be // by passing the cancel channel argument. The channel will be used to cancel
// used to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway. // virtualNetworkGatewayName is the name of the virtual network gateway.
// parameters is parameters supplied to create or update virtual network // parameters is parameters supplied to create or update virtual network
// gateway operation. // gateway operation.
func (client VirtualNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, virtualNetworkGatewayName string, parameters VirtualNetworkGateway, cancel <-chan struct{}) (<-chan VirtualNetworkGateway, <-chan error) {
resultChan := make(chan VirtualNetworkGateway, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
Chain: []validation.Constraint{{Target: "parameters.VirtualNetworkGatewayPropertiesFormat.IPConfigurations", Name: validation.Null, Rule: true, Chain: nil}, errChan <- validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate")
{Target: "parameters.VirtualNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil}, close(errChan)
}}}}}); err != nil { close(resultChan)
return result, validation.NewErrorWithValidationError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate") return resultChan, errChan
} }
go func() {
var err error
var result VirtualNetworkGateway
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkGatewayName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -92,8 +101,9 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdatePreparer(resourceGroupN
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -116,13 +126,14 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdateSender(req *http.Reques
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -133,24 +144,37 @@ func (client VirtualNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Re
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway. // virtualNetworkGatewayName is the name of the virtual network gateway.
func (client VirtualNetworkGatewaysClient) Delete(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewaysClient) Delete(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayName, cancel) req, err := client.DeletePreparer(resourceGroupName, virtualNetworkGatewayName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -161,8 +185,9 @@ func (client VirtualNetworkGatewaysClient) DeletePreparer(resourceGroupName stri
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -203,13 +228,15 @@ func (client VirtualNetworkGatewaysClient) DeleteResponder(resp *http.Response)
func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result String, err error) { func (client VirtualNetworkGatewaysClient) Generatevpnclientpackage(resourceGroupName string, virtualNetworkGatewayName string, parameters VpnClientParameters) (result String, err error) {
req, err := client.GeneratevpnclientpackagePreparer(resourceGroupName, virtualNetworkGatewayName, parameters) req, err := client.GeneratevpnclientpackagePreparer(resourceGroupName, virtualNetworkGatewayName, parameters)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", nil, "Failure preparing request")
return
} }
resp, err := client.GeneratevpnclientpackageSender(req) resp, err := client.GeneratevpnclientpackageSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Generatevpnclientpackage", resp, "Failure sending request")
return
} }
result, err = client.GeneratevpnclientpackageResponder(resp) result, err = client.GeneratevpnclientpackageResponder(resp)
@ -228,8 +255,9 @@ func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackagePreparer(reso
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -268,13 +296,15 @@ func (client VirtualNetworkGatewaysClient) GeneratevpnclientpackageResponder(res
func (client VirtualNetworkGatewaysClient) Get(resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) { func (client VirtualNetworkGatewaysClient) Get(resourceGroupName string, virtualNetworkGatewayName string) (result VirtualNetworkGateway, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayName) req, err := client.GetPreparer(resourceGroupName, virtualNetworkGatewayName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -293,8 +323,9 @@ func (client VirtualNetworkGatewaysClient) GetPreparer(resourceGroupName string,
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -324,19 +355,275 @@ func (client VirtualNetworkGatewaysClient) GetResponder(resp *http.Response) (re
return return
} }
// GetAdvertisedRoutes this operation retrieves a list of routes the virtual
// network gateway is advertising to the specified peer. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway. peer
// is the IP address of the peer
func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutes(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (<-chan GatewayRouteListResult, <-chan error) {
resultChan := make(chan GatewayRouteListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result GatewayRouteListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.GetAdvertisedRoutesPreparer(resourceGroupName, virtualNetworkGatewayName, peer, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", nil, "Failure preparing request")
return
}
resp, err := client.GetAdvertisedRoutesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", resp, "Failure sending request")
return
}
result, err = client.GetAdvertisedRoutesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetAdvertisedRoutes", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// GetAdvertisedRoutesPreparer prepares the GetAdvertisedRoutes request.
func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesPreparer(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
}
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
"peer": autorest.Encode("query", peer),
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getAdvertisedRoutes", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// GetAdvertisedRoutesSender sends the GetAdvertisedRoutes request. The method will close the
// http.Response Body if it receives an error.
func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// GetAdvertisedRoutesResponder handles the response to the GetAdvertisedRoutes request. The method always
// closes the http.Response Body.
func (client VirtualNetworkGatewaysClient) GetAdvertisedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, 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
}
// GetBgpPeerStatus the GetBgpPeerStatus operation retrieves the status of all
// BGP peers. This method may poll for completion. Polling can be canceled by
// passing the cancel channel argument. The channel will be used to cancel
// polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway. peer
// is the IP address of the peer to retrieve the status of.
func (client VirtualNetworkGatewaysClient) GetBgpPeerStatus(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (<-chan BgpPeerStatusListResult, <-chan error) {
resultChan := make(chan BgpPeerStatusListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result BgpPeerStatusListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.GetBgpPeerStatusPreparer(resourceGroupName, virtualNetworkGatewayName, peer, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", nil, "Failure preparing request")
return
}
resp, err := client.GetBgpPeerStatusSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", resp, "Failure sending request")
return
}
result, err = client.GetBgpPeerStatusResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetBgpPeerStatus", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// GetBgpPeerStatusPreparer prepares the GetBgpPeerStatus request.
func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusPreparer(resourceGroupName string, virtualNetworkGatewayName string, peer string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
}
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
if len(peer) > 0 {
queryParameters["peer"] = autorest.Encode("query", peer)
}
preparer := autorest.CreatePreparer(
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getBgpPeerStatus", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// GetBgpPeerStatusSender sends the GetBgpPeerStatus request. The method will close the
// http.Response Body if it receives an error.
func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// GetBgpPeerStatusResponder handles the response to the GetBgpPeerStatus request. The method always
// closes the http.Response Body.
func (client VirtualNetworkGatewaysClient) GetBgpPeerStatusResponder(resp *http.Response) (result BgpPeerStatusListResult, 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
}
// GetLearnedRoutes this operation retrieves a list of routes the virtual
// network gateway has learned, including routes learned from BGP peers. This
// method may poll for completion. Polling can be canceled by passing the
// cancel channel argument. The channel will be used to cancel polling and any
// outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway.
func (client VirtualNetworkGatewaysClient) GetLearnedRoutes(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (<-chan GatewayRouteListResult, <-chan error) {
resultChan := make(chan GatewayRouteListResult, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result GatewayRouteListResult
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.GetLearnedRoutesPreparer(resourceGroupName, virtualNetworkGatewayName, cancel)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", nil, "Failure preparing request")
return
}
resp, err := client.GetLearnedRoutesSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", resp, "Failure sending request")
return
}
result, err = client.GetLearnedRoutesResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "GetLearnedRoutes", resp, "Failure responding to request")
}
}()
return resultChan, errChan
}
// GetLearnedRoutesPreparer prepares the GetLearnedRoutes request.
func (client VirtualNetworkGatewaysClient) GetLearnedRoutesPreparer(resourceGroupName string, virtualNetworkGatewayName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
}
const APIVersion = "2017-03-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.Network/virtualNetworkGateways/{virtualNetworkGatewayName}/getLearnedRoutes", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// GetLearnedRoutesSender sends the GetLearnedRoutes request. The method will close the
// http.Response Body if it receives an error.
func (client VirtualNetworkGatewaysClient) GetLearnedRoutesSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// GetLearnedRoutesResponder handles the response to the GetLearnedRoutes request. The method always
// closes the http.Response Body.
func (client VirtualNetworkGatewaysClient) GetLearnedRoutesResponder(resp *http.Response) (result GatewayRouteListResult, 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 gets all virtual network gateways by resource group. // List gets all virtual network gateways by resource group.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client VirtualNetworkGatewaysClient) List(resourceGroupName string) (result VirtualNetworkGatewayListResult, err error) { func (client VirtualNetworkGatewaysClient) List(resourceGroupName string) (result VirtualNetworkGatewayListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -354,8 +641,9 @@ func (client VirtualNetworkGatewaysClient) ListPreparer(resourceGroupName string
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -410,32 +698,45 @@ func (client VirtualNetworkGatewaysClient) ListNextResults(lastResults VirtualNe
} }
// Reset resets the primary of the virtual network gateway in the specified // Reset resets the primary of the virtual network gateway in the specified
// resource group. This method may poll for completion. Polling can be // resource group. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// virtualNetworkGatewayName is the name of the virtual network gateway. // virtualNetworkGatewayName is the name of the virtual network gateway.
// gatewayVip is virtual network gateway vip address supplied to the begin // gatewayVip is virtual network gateway vip address supplied to the begin
// reset of the active-active feature enabled gateway. // reset of the active-active feature enabled gateway.
func (client VirtualNetworkGatewaysClient) Reset(resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkGatewaysClient) Reset(resourceGroupName string, virtualNetworkGatewayName string, gatewayVip string, cancel <-chan struct{}) (<-chan VirtualNetworkGateway, <-chan error) {
resultChan := make(chan VirtualNetworkGateway, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result VirtualNetworkGateway
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.ResetPreparer(resourceGroupName, virtualNetworkGatewayName, gatewayVip, cancel) req, err := client.ResetPreparer(resourceGroupName, virtualNetworkGatewayName, gatewayVip, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", nil, "Failure preparing request")
return
} }
resp, err := client.ResetSender(req) resp, err := client.ResetSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure sending request")
return
} }
result, err = client.ResetResponder(resp) result, err = client.ResetResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkGatewaysClient", "Reset", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// ResetPreparer prepares the Reset request. // ResetPreparer prepares the Reset request.
@ -446,8 +747,9 @@ func (client VirtualNetworkGatewaysClient) ResetPreparer(resourceGroupName strin
"virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName), "virtualNetworkGatewayName": autorest.Encode("path", virtualNetworkGatewayName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(gatewayVip) > 0 { if len(gatewayVip) > 0 {
queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip) queryParameters["gatewayVip"] = autorest.Encode("query", gatewayVip)
@ -471,12 +773,13 @@ func (client VirtualNetworkGatewaysClient) ResetSender(req *http.Request) (*http
// ResetResponder handles the response to the Reset request. The method always // ResetResponder handles the response to the Reset request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkGatewaysClient) ResetResponder(resp *http.Response) (result VirtualNetworkGateway, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK), azure.WithErrorUnlessStatusCode(http.StatusAccepted, http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }

85
vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworkpeerings.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,7 @@ import (
"net/http" "net/http"
) )
// VirtualNetworkPeeringsClient is the the Microsoft Azure Network management // VirtualNetworkPeeringsClient is the composite Swagger for Network Client
// API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the
// Microsoft Azure Networks service.
type VirtualNetworkPeeringsClient struct { type VirtualNetworkPeeringsClient struct {
ManagementClient ManagementClient
} }
@ -54,24 +50,37 @@ func NewVirtualNetworkPeeringsClientWithBaseURI(baseURI string, subscriptionID s
// the name of the virtual network. virtualNetworkPeeringName is the name of // the name of the virtual network. virtualNetworkPeeringName is the name of
// the peering. virtualNetworkPeeringParameters is parameters supplied to the // the peering. virtualNetworkPeeringParameters is parameters supplied to the
// create or update virtual network peering operation. // create or update virtual network peering operation.
func (client VirtualNetworkPeeringsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkPeeringsClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, virtualNetworkPeeringParameters VirtualNetworkPeering, cancel <-chan struct{}) (<-chan VirtualNetworkPeering, <-chan error) {
resultChan := make(chan VirtualNetworkPeering, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result VirtualNetworkPeering
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -83,8 +92,9 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdatePreparer(resourceGroupN
"virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -107,13 +117,14 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateSender(req *http.Reques
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetworkPeering, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
@ -125,24 +136,37 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Re
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. virtualNetworkPeeringName is the name of // the name of the virtual network. virtualNetworkPeeringName is the name of
// the virtual network peering. // the virtual network peering.
func (client VirtualNetworkPeeringsClient) Delete(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworkPeeringsClient) Delete(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cancel) req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -154,8 +178,9 @@ func (client VirtualNetworkPeeringsClient) DeletePreparer(resourceGroupName stri
"virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -194,13 +219,15 @@ func (client VirtualNetworkPeeringsClient) DeleteResponder(resp *http.Response)
func (client VirtualNetworkPeeringsClient) Get(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) (result VirtualNetworkPeering, err error) { func (client VirtualNetworkPeeringsClient) Get(resourceGroupName string, virtualNetworkName string, virtualNetworkPeeringName string) (result VirtualNetworkPeering, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName) req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -220,8 +247,9 @@ func (client VirtualNetworkPeeringsClient) GetPreparer(resourceGroupName string,
"virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName), "virtualNetworkPeeringName": autorest.Encode("path", virtualNetworkPeeringName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -258,13 +286,15 @@ func (client VirtualNetworkPeeringsClient) GetResponder(resp *http.Response) (re
func (client VirtualNetworkPeeringsClient) List(resourceGroupName string, virtualNetworkName string) (result VirtualNetworkPeeringListResult, err error) { func (client VirtualNetworkPeeringsClient) List(resourceGroupName string, virtualNetworkName string) (result VirtualNetworkPeeringListResult, err error) {
req, err := client.ListPreparer(resourceGroupName, virtualNetworkName) req, err := client.ListPreparer(resourceGroupName, virtualNetworkName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -283,8 +313,9 @@ func (client VirtualNetworkPeeringsClient) ListPreparer(resourceGroupName string
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

127
vendor/github.com/Azure/azure-sdk-for-go/arm/network/virtualnetworks.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package network
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -24,11 +24,7 @@ import (
"net/http" "net/http"
) )
// VirtualNetworksClient is the the Microsoft Azure Network management API // VirtualNetworksClient is the composite Swagger for Network Client
// provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure
// Networks service.
type VirtualNetworksClient struct { type VirtualNetworksClient struct {
ManagementClient ManagementClient
} }
@ -49,18 +45,20 @@ func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string)
// for use. // for use.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. ipAddress is the private IP address to be // the name of the virtual network. IPAddress is the private IP address to be
// verified. // verified.
func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName string, virtualNetworkName string, ipAddress string) (result IPAddressAvailabilityResult, err error) { func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName string, virtualNetworkName string, IPAddress string) (result IPAddressAvailabilityResult, err error) {
req, err := client.CheckIPAddressAvailabilityPreparer(resourceGroupName, virtualNetworkName, ipAddress) req, err := client.CheckIPAddressAvailabilityPreparer(resourceGroupName, virtualNetworkName, IPAddress)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", nil, "Failure preparing request")
return
} }
resp, err := client.CheckIPAddressAvailabilitySender(req) resp, err := client.CheckIPAddressAvailabilitySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CheckIPAddressAvailability", resp, "Failure sending request")
return
} }
result, err = client.CheckIPAddressAvailabilityResponder(resp) result, err = client.CheckIPAddressAvailabilityResponder(resp)
@ -72,18 +70,19 @@ func (client VirtualNetworksClient) CheckIPAddressAvailability(resourceGroupName
} }
// CheckIPAddressAvailabilityPreparer prepares the CheckIPAddressAvailability request. // CheckIPAddressAvailabilityPreparer prepares the CheckIPAddressAvailability request.
func (client VirtualNetworksClient) CheckIPAddressAvailabilityPreparer(resourceGroupName string, virtualNetworkName string, ipAddress string) (*http.Request, error) { func (client VirtualNetworksClient) CheckIPAddressAvailabilityPreparer(resourceGroupName string, virtualNetworkName string, IPAddress string) (*http.Request, error) {
pathParameters := map[string]interface{}{ pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(ipAddress) > 0 { if len(IPAddress) > 0 {
queryParameters["ipAddress"] = autorest.Encode("query", ipAddress) queryParameters["ipAddress"] = autorest.Encode("query", IPAddress)
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -114,31 +113,44 @@ func (client VirtualNetworksClient) CheckIPAddressAvailabilityResponder(resp *ht
} }
// CreateOrUpdate creates or updates a virtual network in the specified // CreateOrUpdate creates or updates a virtual network in the specified
// resource group. This method may poll for completion. Polling can be // resource group. This method may poll for completion. Polling can be canceled
// canceled by passing the cancel channel argument. The channel will be used // by passing the cancel channel argument. The channel will be used to cancel
// to cancel polling and any outstanding HTTP requests. // polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. parameters is parameters supplied to the // the name of the virtual network. parameters is parameters supplied to the
// create or update virtual network operation // create or update virtual network operation
func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworksClient) CreateOrUpdate(resourceGroupName string, virtualNetworkName string, parameters VirtualNetwork, cancel <-chan struct{}) (<-chan VirtualNetwork, <-chan error) {
resultChan := make(chan VirtualNetwork, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result VirtualNetwork
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", nil, "Failure preparing request")
return
} }
resp, err := client.CreateOrUpdateSender(req) resp, err := client.CreateOrUpdateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure sending request")
return
} }
result, err = client.CreateOrUpdateResponder(resp) result, err = client.CreateOrUpdateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "CreateOrUpdate", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreateOrUpdatePreparer prepares the CreateOrUpdate request. // CreateOrUpdatePreparer prepares the CreateOrUpdate request.
@ -149,8 +161,9 @@ func (client VirtualNetworksClient) CreateOrUpdatePreparer(resourceGroupName str
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -173,41 +186,55 @@ func (client VirtualNetworksClient) CreateOrUpdateSender(req *http.Request) (*ht
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always // CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) { func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) (result VirtualNetwork, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes the specified virtual network. This method may poll for // Delete deletes the specified virtual network. This method may poll for
// completion. Polling can be canceled by passing the cancel channel // completion. Polling can be canceled by passing the cancel channel argument.
// argument. The channel will be used to cancel polling and any outstanding // The channel will be used to cancel polling and any outstanding HTTP
// HTTP requests. // requests.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
// the name of the virtual network. // the name of the virtual network.
func (client VirtualNetworksClient) Delete(resourceGroupName string, virtualNetworkName string, cancel <-chan struct{}) (result autorest.Response, err error) { func (client VirtualNetworksClient) Delete(resourceGroupName string, virtualNetworkName string, cancel <-chan struct{}) (<-chan autorest.Response, <-chan error) {
resultChan := make(chan autorest.Response, 1)
errChan := make(chan error, 1)
go func() {
var err error
var result autorest.Response
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, cancel) req, err := client.DeletePreparer(resourceGroupName, virtualNetworkName, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Delete", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// DeletePreparer prepares the Delete request. // DeletePreparer prepares the Delete request.
@ -218,8 +245,9 @@ func (client VirtualNetworksClient) DeletePreparer(resourceGroupName string, vir
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -257,13 +285,15 @@ func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result
func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetworkName string, expand string) (result VirtualNetwork, err error) { func (client VirtualNetworksClient) Get(resourceGroupName string, virtualNetworkName string, expand string) (result VirtualNetwork, err error) {
req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, expand) req, err := client.GetPreparer(resourceGroupName, virtualNetworkName, expand)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", nil, "Failure preparing request")
return
} }
resp, err := client.GetSender(req) resp, err := client.GetSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "Get", resp, "Failure sending request")
return
} }
result, err = client.GetResponder(resp) result, err = client.GetResponder(resp)
@ -282,8 +312,9 @@ func (client VirtualNetworksClient) GetPreparer(resourceGroupName string, virtua
"virtualNetworkName": autorest.Encode("path", virtualNetworkName), "virtualNetworkName": autorest.Encode("path", virtualNetworkName),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
if len(expand) > 0 { if len(expand) > 0 {
queryParameters["$expand"] = autorest.Encode("query", expand) queryParameters["$expand"] = autorest.Encode("query", expand)
@ -322,13 +353,15 @@ func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result Vi
func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) { func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) {
req, err := client.ListPreparer(resourceGroupName) req, err := client.ListPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -346,8 +379,9 @@ func (client VirtualNetworksClient) ListPreparer(resourceGroupName string) (*htt
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -405,13 +439,15 @@ func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkLi
func (client VirtualNetworksClient) ListAll() (result VirtualNetworkListResult, err error) { func (client VirtualNetworksClient) ListAll() (result VirtualNetworkListResult, err error) {
req, err := client.ListAllPreparer() req, err := client.ListAllPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing request")
return
} }
resp, err := client.ListAllSender(req) resp, err := client.ListAllSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending request")
return
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
@ -428,8 +464,9 @@ func (client VirtualNetworksClient) ListAllPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2017-03-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

View File

@ -1,39 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"accounts.go",
"client.go",
"models.go",
"usageoperations.go",
"version.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/azure:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/date:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/validation:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

421
vendor/github.com/Azure/azure-sdk-for-go/arm/storage/accounts.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package storage
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -25,7 +25,7 @@ import (
"net/http" "net/http"
) )
// AccountsClient is the the Storage Management Client. // AccountsClient is the the Azure Storage Management API.
type AccountsClient struct { type AccountsClient struct {
ManagementClient ManagementClient
} }
@ -44,9 +44,9 @@ func NewAccountsClientWithBaseURI(baseURI string, subscriptionID string) Account
// CheckNameAvailability checks that the storage account name is valid and is // CheckNameAvailability checks that the storage account name is valid and is
// not already in use. // not already in use.
// //
// accountName is the name of the storage account within the specified // accountName is the name of the storage account within the specified resource
// resource group. Storage account names must be between 3 and 24 characters // group. Storage account names must be between 3 and 24 characters in length
// in length and use numbers and lower-case letters only. // and use numbers and lower-case letters only.
func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) { func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameAvailabilityParameters) (result CheckNameAvailabilityResult, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: accountName, {TargetValue: accountName,
@ -57,13 +57,15 @@ func (client AccountsClient) CheckNameAvailability(accountName AccountCheckNameA
req, err := client.CheckNameAvailabilityPreparer(accountName) req, err := client.CheckNameAvailabilityPreparer(accountName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", nil, "Failure preparing request")
return
} }
resp, err := client.CheckNameAvailabilitySender(req) resp, err := client.CheckNameAvailabilitySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "CheckNameAvailability", resp, "Failure sending request")
return
} }
result, err = client.CheckNameAvailabilityResponder(resp) result, err = client.CheckNameAvailabilityResponder(resp)
@ -80,8 +82,9 @@ func (client AccountsClient) CheckNameAvailabilityPreparer(accountName AccountCh
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -114,59 +117,74 @@ func (client AccountsClient) CheckNameAvailabilityResponder(resp *http.Response)
} }
// Create asynchronously creates a new storage account with the specified // Create asynchronously creates a new storage account with the specified
// parameters. If an account is already created and a subsequent create // parameters. If an account is already created and a subsequent create request
// request is issued with different properties, the account properties will // is issued with different properties, the account properties will be updated.
// be updated. If an account is already created and a subsequent create or // If an account is already created and a subsequent create or update request
// update request is issued with the exact same set of properties, the // is issued with the exact same set of properties, the request will succeed.
// request will succeed. This method may poll for completion. Polling can be // This method may poll for completion. Polling can be canceled by passing the
// canceled by passing the cancel channel argument. The channel will be used // cancel channel argument. The channel will be used to cancel polling and any
// to cancel polling and any outstanding HTTP requests. // outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// parameters is the parameters to provide for the created account. // letters only. parameters is the parameters to provide for the created
func (client AccountsClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (result autorest.Response, err error) { // account.
func (client AccountsClient) Create(resourceGroupName string, accountName string, parameters AccountCreateParameters, cancel <-chan struct{}) (<-chan Account, <-chan error) {
resultChan := make(chan Account, 1)
errChan := make(chan error, 1)
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
{TargetValue: parameters, {TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Constraints: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: true, Chain: nil},
Chain: []validation.Constraint{{Target: "parameters.Sku.Tier", Name: validation.ReadOnly, Rule: true, Chain: nil}}},
{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}, {Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.AccountPropertiesCreateParameters", Name: validation.Null, Rule: false, {Target: "parameters.AccountPropertiesCreateParameters", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain.Name", Name: validation.Null, Rule: true, Chain: nil}}}, Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.CustomDomain.Name", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "parameters.AccountPropertiesCreateParameters.Encryption", Name: validation.Null, Rule: false, {Target: "parameters.AccountPropertiesCreateParameters.Encryption", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.Encryption.Services", Name: validation.Null, Rule: false, Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.Encryption.KeySource", Name: validation.Null, Rule: true, Chain: nil}}},
Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.Encryption.Services.Blob", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.AccountPropertiesCreateParameters.Encryption.Services.Blob.LastEnabledTime", Name: validation.ReadOnly, Rule: true, Chain: nil}}},
}},
{Target: "parameters.AccountPropertiesCreateParameters.Encryption.KeySource", Name: validation.Null, Rule: true, Chain: nil},
}},
}}}}}); err != nil { }}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Create") errChan <- validation.NewErrorWithValidationError(err, "storage.AccountsClient", "Create")
close(errChan)
close(resultChan)
return resultChan, errChan
} }
go func() {
var err error
var result Account
defer func() {
resultChan <- result
errChan <- err
close(resultChan)
close(errChan)
}()
req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel) req, err := client.CreatePreparer(resourceGroupName, accountName, parameters, cancel)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", nil, "Failure preparing request")
return
} }
resp, err := client.CreateSender(req) resp, err := client.CreateSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure sending request")
return
} }
result, err = client.CreateResponder(resp) result, err = client.CreateResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure responding to request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Create", resp, "Failure responding to request")
} }
}()
return return resultChan, errChan
} }
// CreatePreparer prepares the Create request. // CreatePreparer prepares the Create request.
@ -177,8 +195,9 @@ func (client AccountsClient) CreatePreparer(resourceGroupName string, accountNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -201,24 +220,30 @@ func (client AccountsClient) CreateSender(req *http.Request) (*http.Response, er
// CreateResponder handles the response to the Create request. The method always // CreateResponder handles the response to the Create request. The method always
// closes the http.Response Body. // closes the http.Response Body.
func (client AccountsClient) CreateResponder(resp *http.Response) (result autorest.Response, err error) { func (client AccountsClient) CreateResponder(resp *http.Response) (result Account, err error) {
err = autorest.Respond( err = autorest.Respond(
resp, resp,
client.ByInspecting(), client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing()) autorest.ByClosing())
result.Response = resp result.Response = autorest.Response{Response: resp}
return return
} }
// Delete deletes a storage account in Microsoft Azure. // Delete deletes a storage account in Microsoft Azure.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// letters only.
func (client AccountsClient) Delete(resourceGroupName string, accountName string) (result autorest.Response, err error) { func (client AccountsClient) Delete(resourceGroupName string, accountName string) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
@ -227,13 +252,15 @@ func (client AccountsClient) Delete(resourceGroupName string, accountName string
req, err := client.DeletePreparer(resourceGroupName, accountName) req, err := client.DeletePreparer(resourceGroupName, accountName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", nil, "Failure preparing request")
return
} }
resp, err := client.DeleteSender(req) resp, err := client.DeleteSender(req)
if err != nil { if err != nil {
result.Response = resp result.Response = resp
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Delete", resp, "Failure sending request")
return
} }
result, err = client.DeleteResponder(resp) result, err = client.DeleteResponder(resp)
@ -252,8 +279,9 @@ func (client AccountsClient) DeletePreparer(resourceGroupName string, accountNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -287,11 +315,16 @@ func (client AccountsClient) DeleteResponder(resp *http.Response) (result autore
// The ListKeys operation should be used to retrieve storage keys. // The ListKeys operation should be used to retrieve storage keys.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// letters only.
func (client AccountsClient) GetProperties(resourceGroupName string, accountName string) (result Account, err error) { func (client AccountsClient) GetProperties(resourceGroupName string, accountName string) (result Account, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
@ -300,13 +333,15 @@ func (client AccountsClient) GetProperties(resourceGroupName string, accountName
req, err := client.GetPropertiesPreparer(resourceGroupName, accountName) req, err := client.GetPropertiesPreparer(resourceGroupName, accountName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", nil, "Failure preparing request")
return
} }
resp, err := client.GetPropertiesSender(req) resp, err := client.GetPropertiesSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "GetProperties", resp, "Failure sending request")
return
} }
result, err = client.GetPropertiesResponder(resp) result, err = client.GetPropertiesResponder(resp)
@ -325,8 +360,9 @@ func (client AccountsClient) GetPropertiesPreparer(resourceGroupName string, acc
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -361,13 +397,15 @@ func (client AccountsClient) GetPropertiesResponder(resp *http.Response) (result
func (client AccountsClient) List() (result AccountListResult, err error) { func (client AccountsClient) List() (result AccountListResult, err error) {
req, err := client.ListPreparer() req, err := client.ListPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", nil, "Failure preparing request")
return
} }
resp, err := client.ListSender(req) resp, err := client.ListSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "List", resp, "Failure sending request")
return
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
@ -384,8 +422,9 @@ func (client AccountsClient) ListPreparer() (*http.Request, error) {
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -415,22 +454,117 @@ func (client AccountsClient) ListResponder(resp *http.Response) (result AccountL
return return
} }
// ListByResourceGroup lists all the storage accounts available under the // ListAccountSAS list SAS credentials of a storage account.
// given resource group. Note that storage keys are not returned; use the
// ListKeys operation for this.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. // subscription. The name is case insensitive. accountName is the name of the
// storage account within the specified resource group. Storage account names
// must be between 3 and 24 characters in length and use numbers and lower-case
// letters only. parameters is the parameters to provide to list SAS
// credentials for the storage account.
func (client AccountsClient) ListAccountSAS(resourceGroupName string, accountName string, parameters AccountSasParameters) (result ListAccountSasResponse, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.SharedAccessExpiryTime", Name: validation.Null, Rule: true, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListAccountSAS")
}
req, err := client.ListAccountSASPreparer(resourceGroupName, accountName, parameters)
if err != nil {
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", nil, "Failure preparing request")
return
}
resp, err := client.ListAccountSASSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure sending request")
return
}
result, err = client.ListAccountSASResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListAccountSAS", resp, "Failure responding to request")
}
return
}
// ListAccountSASPreparer prepares the ListAccountSAS request.
func (client AccountsClient) ListAccountSASPreparer(resourceGroupName string, accountName string, parameters AccountSasParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"accountName": autorest.Encode("path", accountName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListAccountSASSender sends the ListAccountSAS request. The method will close the
// http.Response Body if it receives an error.
func (client AccountsClient) ListAccountSASSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListAccountSASResponder handles the response to the ListAccountSAS request. The method always
// closes the http.Response Body.
func (client AccountsClient) ListAccountSASResponder(resp *http.Response) (result ListAccountSasResponse, 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 the storage accounts available under the given
// resource group. Note that storage keys are not returned; use the ListKeys
// operation for this.
//
// resourceGroupName is the name of the resource group within the user's
// subscription. The name is case insensitive.
func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) { func (client AccountsClient) ListByResourceGroup(resourceGroupName string) (result AccountListResult, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListByResourceGroup")
}
req, err := client.ListByResourceGroupPreparer(resourceGroupName) req, err := client.ListByResourceGroupPreparer(resourceGroupName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", nil, "Failure preparing request")
return
} }
resp, err := client.ListByResourceGroupSender(req) resp, err := client.ListByResourceGroupSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListByResourceGroup", resp, "Failure sending request")
return
} }
result, err = client.ListByResourceGroupResponder(resp) result, err = client.ListByResourceGroupResponder(resp)
@ -448,8 +582,9 @@ func (client AccountsClient) ListByResourceGroupPreparer(resourceGroupName strin
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -482,11 +617,16 @@ func (client AccountsClient) ListByResourceGroupResponder(resp *http.Response) (
// ListKeys lists the access keys for the specified storage account. // ListKeys lists the access keys for the specified storage account.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// letters only.
func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountListKeysResult, err error) { func (client AccountsClient) ListKeys(resourceGroupName string, accountName string) (result AccountListKeysResult, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
@ -495,13 +635,15 @@ func (client AccountsClient) ListKeys(resourceGroupName string, accountName stri
req, err := client.ListKeysPreparer(resourceGroupName, accountName) req, err := client.ListKeysPreparer(resourceGroupName, accountName)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", nil, "Failure preparing request")
return
} }
resp, err := client.ListKeysSender(req) resp, err := client.ListKeysSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListKeys", resp, "Failure sending request")
return
} }
result, err = client.ListKeysResponder(resp) result, err = client.ListKeysResponder(resp)
@ -520,8 +662,9 @@ func (client AccountsClient) ListKeysPreparer(resourceGroupName string, accountN
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -551,17 +694,108 @@ func (client AccountsClient) ListKeysResponder(resp *http.Response) (result Acco
return return
} }
// ListServiceSAS list service SAS credentials of a specific resource.
//
// resourceGroupName is the name of the resource group within the user's
// subscription. The name is case insensitive. accountName is the name of the
// storage account within the specified resource group. Storage account names
// must be between 3 and 24 characters in length and use numbers and lower-case
// letters only. parameters is the parameters to provide to list service SAS
// credentials.
func (client AccountsClient) ListServiceSAS(resourceGroupName string, accountName string, parameters ServiceSasParameters) (result ListServiceSasResponse, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.CanonicalizedResource", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Identifier", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Identifier", Name: validation.MaxLength, Rule: 64, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "storage.AccountsClient", "ListServiceSAS")
}
req, err := client.ListServiceSASPreparer(resourceGroupName, accountName, parameters)
if err != nil {
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", nil, "Failure preparing request")
return
}
resp, err := client.ListServiceSASSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure sending request")
return
}
result, err = client.ListServiceSASResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "storage.AccountsClient", "ListServiceSAS", resp, "Failure responding to request")
}
return
}
// ListServiceSASPreparer prepares the ListServiceSAS request.
func (client AccountsClient) ListServiceSASPreparer(resourceGroupName string, accountName string, parameters ServiceSasParameters) (*http.Request, error) {
pathParameters := map[string]interface{}{
"accountName": autorest.Encode("path", accountName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{
"api-version": APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPost(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListServiceSASSender sends the ListServiceSAS request. The method will close the
// http.Response Body if it receives an error.
func (client AccountsClient) ListServiceSASSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListServiceSASResponder handles the response to the ListServiceSAS request. The method always
// closes the http.Response Body.
func (client AccountsClient) ListServiceSASResponder(resp *http.Response) (result ListServiceSasResponse, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// RegenerateKey regenerates one of the access keys for the specified storage // RegenerateKey regenerates one of the access keys for the specified storage
// account. // account.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// regenerateKey is specifies name of the key which should be regenerated -- // letters only. regenerateKey is specifies name of the key which should be
// key1 or key2. // regenerated -- key1 or key2.
func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, err error) { func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName string, regenerateKey AccountRegenerateKeyParameters) (result AccountListKeysResult, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}, {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}},
@ -572,13 +806,15 @@ func (client AccountsClient) RegenerateKey(resourceGroupName string, accountName
req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, regenerateKey) req, err := client.RegenerateKeyPreparer(resourceGroupName, accountName, regenerateKey)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", nil, "Failure preparing request")
return
} }
resp, err := client.RegenerateKeySender(req) resp, err := client.RegenerateKeySender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "RegenerateKey", resp, "Failure sending request")
return
} }
result, err = client.RegenerateKeyResponder(resp) result, err = client.RegenerateKeyResponder(resp)
@ -597,8 +833,9 @@ func (client AccountsClient) RegenerateKeyPreparer(resourceGroupName string, acc
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(
@ -632,22 +869,27 @@ func (client AccountsClient) RegenerateKeyResponder(resp *http.Response) (result
// Update the update operation can be used to update the SKU, encryption, // Update the update operation can be used to update the SKU, encryption,
// access tier, or tags for a storage account. It can also be used to map the // access tier, or tags for a storage account. It can also be used to map the
// account to a custom domain. Only one custom domain is supported per // account to a custom domain. Only one custom domain is supported per storage
// storage account; the replacement/change of custom domain is not supported. // account; the replacement/change of custom domain is not supported. In order
// In order to replace an old custom domain, the old value must be // to replace an old custom domain, the old value must be cleared/unregistered
// cleared/unregistered before a new value can be set. The update of multiple // before a new value can be set. The update of multiple properties is
// properties is supported. This call does not change the storage keys for // supported. This call does not change the storage keys for the account. If
// the account. If you want to change the storage account keys, use the // you want to change the storage account keys, use the regenerate keys
// regenerate keys operation. The location and name of the storage account // operation. The location and name of the storage account cannot be changed
// cannot be changed after creation. // after creation.
// //
// resourceGroupName is the name of the resource group within the user's // resourceGroupName is the name of the resource group within the user's
// subscription. accountName is the name of the storage account within the // subscription. The name is case insensitive. accountName is the name of the
// specified resource group. Storage account names must be between 3 and 24 // storage account within the specified resource group. Storage account names
// characters in length and use numbers and lower-case letters only. // must be between 3 and 24 characters in length and use numbers and lower-case
// parameters is the parameters to provide for the updated account. // letters only. parameters is the parameters to provide for the updated
// account.
func (client AccountsClient) Update(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) { func (client AccountsClient) Update(resourceGroupName string, accountName string, parameters AccountUpdateParameters) (result Account, err error) {
if err := validation.Validate([]validation.Validation{ if err := validation.Validate([]validation.Validation{
{TargetValue: resourceGroupName,
Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil},
{Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil},
{Target: "resourceGroupName", Name: validation.Pattern, Rule: `^[-\w\._\(\)]+$`, Chain: nil}}},
{TargetValue: accountName, {TargetValue: accountName,
Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil}, Constraints: []validation.Constraint{{Target: "accountName", Name: validation.MaxLength, Rule: 24, Chain: nil},
{Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil { {Target: "accountName", Name: validation.MinLength, Rule: 3, Chain: nil}}}}); err != nil {
@ -656,13 +898,15 @@ func (client AccountsClient) Update(resourceGroupName string, accountName string
req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters) req, err := client.UpdatePreparer(resourceGroupName, accountName, parameters)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", nil, "Failure preparing request")
return
} }
resp, err := client.UpdateSender(req) resp, err := client.UpdateSender(req)
if err != nil { if err != nil {
result.Response = autorest.Response{Response: resp} result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request") err = autorest.NewErrorWithError(err, "storage.AccountsClient", "Update", resp, "Failure sending request")
return
} }
result, err = client.UpdateResponder(resp) result, err = client.UpdateResponder(resp)
@ -681,8 +925,9 @@ func (client AccountsClient) UpdatePreparer(resourceGroupName string, accountNam
"subscriptionId": autorest.Encode("path", client.SubscriptionID), "subscriptionId": autorest.Encode("path", client.SubscriptionID),
} }
const APIVersion = "2016-12-01"
queryParameters := map[string]interface{}{ queryParameters := map[string]interface{}{
"api-version": client.APIVersion, "api-version": APIVersion,
} }
preparer := autorest.CreatePreparer( preparer := autorest.CreatePreparer(

11
vendor/github.com/Azure/azure-sdk-for-go/arm/storage/client.go generated vendored Normal file → Executable file
View File

@ -1,7 +1,7 @@
// Package storage implements the Azure ARM Storage service API version // Package storage implements the Azure ARM Storage service API version
// 2016-01-01. // 2016-12-01.
// //
// The Storage Management Client. // The Azure Storage Management API.
package storage package storage
// Copyright (c) Microsoft and contributors. All rights reserved. // Copyright (c) Microsoft and contributors. All rights reserved.
@ -18,7 +18,7 @@ package storage
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -27,9 +27,6 @@ import (
) )
const ( const (
// APIVersion is the version of the Storage
APIVersion = "2016-01-01"
// DefaultBaseURI is the default URI used for the service Storage // DefaultBaseURI is the default URI used for the service Storage
DefaultBaseURI = "https://management.azure.com" DefaultBaseURI = "https://management.azure.com"
) )
@ -38,7 +35,6 @@ const (
type ManagementClient struct { type ManagementClient struct {
autorest.Client autorest.Client
BaseURI string BaseURI string
APIVersion string
SubscriptionID string SubscriptionID string
} }
@ -52,7 +48,6 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{ return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()), Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI, BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID, SubscriptionID: subscriptionID,
} }
} }

191
vendor/github.com/Azure/azure-sdk-for-go/arm/storage/models.go generated vendored Normal file → Executable file
View File

@ -14,7 +14,7 @@ package storage
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
@ -38,19 +38,29 @@ type AccountStatus string
const ( const (
// Available specifies the available state for account status. // Available specifies the available state for account status.
Available AccountStatus = "Available" Available AccountStatus = "available"
// Unavailable specifies the unavailable state for account status. // Unavailable specifies the unavailable state for account status.
Unavailable AccountStatus = "Unavailable" Unavailable AccountStatus = "unavailable"
)
// HTTPProtocol enumerates the values for http protocol.
type HTTPProtocol string
const (
// HTTPS specifies the https state for http protocol.
HTTPS HTTPProtocol = "https"
// Httpshttp specifies the httpshttp state for http protocol.
Httpshttp HTTPProtocol = "https,http"
) )
// KeyPermission enumerates the values for key permission. // KeyPermission enumerates the values for key permission.
type KeyPermission string type KeyPermission string
const ( const (
// FULL specifies the full state for key permission. // Full specifies the full state for key permission.
FULL KeyPermission = "FULL" Full KeyPermission = "Full"
// READ specifies the read state for key permission. // Read specifies the read state for key permission.
READ KeyPermission = "READ" Read KeyPermission = "Read"
) )
// Kind enumerates the values for kind. // Kind enumerates the values for kind.
@ -63,6 +73,50 @@ const (
Storage Kind = "Storage" Storage Kind = "Storage"
) )
// Permissions enumerates the values for permissions.
type Permissions string
const (
// A specifies the a state for permissions.
A Permissions = "a"
// C specifies the c state for permissions.
C Permissions = "c"
// D specifies the d state for permissions.
D Permissions = "d"
// L specifies the l state for permissions.
L Permissions = "l"
// P specifies the p state for permissions.
P Permissions = "p"
// R specifies the r state for permissions.
R Permissions = "r"
// U specifies the u state for permissions.
U Permissions = "u"
// W specifies the w state for permissions.
W Permissions = "w"
)
// Permissions1 enumerates the values for permissions 1.
type Permissions1 string
const (
// Permissions1A specifies the permissions 1a state for permissions 1.
Permissions1A Permissions1 = "a"
// Permissions1C specifies the permissions 1c state for permissions 1.
Permissions1C Permissions1 = "c"
// Permissions1D specifies the permissions 1d state for permissions 1.
Permissions1D Permissions1 = "d"
// Permissions1L specifies the permissions 1l state for permissions 1.
Permissions1L Permissions1 = "l"
// Permissions1P specifies the permissions 1p state for permissions 1.
Permissions1P Permissions1 = "p"
// Permissions1R specifies the permissions 1r state for permissions 1.
Permissions1R Permissions1 = "r"
// Permissions1U specifies the permissions 1u state for permissions 1.
Permissions1U Permissions1 = "u"
// Permissions1W specifies the permissions 1w state for permissions 1.
Permissions1W Permissions1 = "w"
)
// ProvisioningState enumerates the values for provisioning state. // ProvisioningState enumerates the values for provisioning state.
type ProvisioningState string type ProvisioningState string
@ -85,6 +139,46 @@ const (
AlreadyExists Reason = "AlreadyExists" AlreadyExists Reason = "AlreadyExists"
) )
// ResourceEnum enumerates the values for resource enum.
type ResourceEnum string
const (
// ResourceEnumB specifies the resource enum b state for resource enum.
ResourceEnumB ResourceEnum = "b"
// ResourceEnumC specifies the resource enum c state for resource enum.
ResourceEnumC ResourceEnum = "c"
// ResourceEnumF specifies the resource enum f state for resource enum.
ResourceEnumF ResourceEnum = "f"
// ResourceEnumS specifies the resource enum s state for resource enum.
ResourceEnumS ResourceEnum = "s"
)
// ResourceTypes enumerates the values for resource types.
type ResourceTypes string
const (
// ResourceTypesC specifies the resource types c state for resource types.
ResourceTypesC ResourceTypes = "c"
// ResourceTypesO specifies the resource types o state for resource types.
ResourceTypesO ResourceTypes = "o"
// ResourceTypesS specifies the resource types s state for resource types.
ResourceTypesS ResourceTypes = "s"
)
// Services enumerates the values for services.
type Services string
const (
// B specifies the b state for services.
B Services = "b"
// F specifies the f state for services.
F Services = "f"
// Q specifies the q state for services.
Q Services = "q"
// T specifies the t state for services.
T Services = "t"
)
// SkuName enumerates the values for sku name. // SkuName enumerates the values for sku name.
type SkuName string type SkuName string
@ -142,7 +236,8 @@ type Account struct {
*AccountProperties `json:"properties,omitempty"` *AccountProperties `json:"properties,omitempty"`
} }
// AccountCheckNameAvailabilityParameters is // AccountCheckNameAvailabilityParameters is the parameters used to check the
// availabity of the storage account name.
type AccountCheckNameAvailabilityParameters struct { type AccountCheckNameAvailabilityParameters struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
@ -177,7 +272,7 @@ type AccountListResult struct {
Value *[]Account `json:"value,omitempty"` Value *[]Account `json:"value,omitempty"`
} }
// AccountProperties is // AccountProperties is properties of the storage account.
type AccountProperties struct { type AccountProperties struct {
ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` ProvisioningState ProvisioningState `json:"provisioningState,omitempty"`
PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"` PrimaryEndpoints *Endpoints `json:"primaryEndpoints,omitempty"`
@ -191,29 +286,48 @@ type AccountProperties struct {
SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"` SecondaryEndpoints *Endpoints `json:"secondaryEndpoints,omitempty"`
Encryption *Encryption `json:"encryption,omitempty"` Encryption *Encryption `json:"encryption,omitempty"`
AccessTier AccessTier `json:"accessTier,omitempty"` AccessTier AccessTier `json:"accessTier,omitempty"`
EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"`
} }
// AccountPropertiesCreateParameters is // AccountPropertiesCreateParameters is the parameters used to create the
// storage account.
type AccountPropertiesCreateParameters struct { type AccountPropertiesCreateParameters struct {
CustomDomain *CustomDomain `json:"customDomain,omitempty"` CustomDomain *CustomDomain `json:"customDomain,omitempty"`
Encryption *Encryption `json:"encryption,omitempty"` Encryption *Encryption `json:"encryption,omitempty"`
AccessTier AccessTier `json:"accessTier,omitempty"` AccessTier AccessTier `json:"accessTier,omitempty"`
EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"`
} }
// AccountPropertiesUpdateParameters is // AccountPropertiesUpdateParameters is the parameters used when updating a
// storage account.
type AccountPropertiesUpdateParameters struct { type AccountPropertiesUpdateParameters struct {
CustomDomain *CustomDomain `json:"customDomain,omitempty"` CustomDomain *CustomDomain `json:"customDomain,omitempty"`
Encryption *Encryption `json:"encryption,omitempty"` Encryption *Encryption `json:"encryption,omitempty"`
AccessTier AccessTier `json:"accessTier,omitempty"` AccessTier AccessTier `json:"accessTier,omitempty"`
EnableHTTPSTrafficOnly *bool `json:"supportsHttpsTrafficOnly,omitempty"`
} }
// AccountRegenerateKeyParameters is // AccountRegenerateKeyParameters is the parameters used to regenerate the
// storage account key.
type AccountRegenerateKeyParameters struct { type AccountRegenerateKeyParameters struct {
KeyName *string `json:"keyName,omitempty"` KeyName *string `json:"keyName,omitempty"`
} }
// AccountUpdateParameters is the parameters that can be provided when // AccountSasParameters is the parameters to list SAS credentials of a storage
// updating the storage account properties. // account.
type AccountSasParameters struct {
Services Services `json:"signedServices,omitempty"`
ResourceTypes ResourceTypes `json:"signedResourceTypes,omitempty"`
Permissions Permissions `json:"signedPermission,omitempty"`
IPAddressOrRange *string `json:"signedIp,omitempty"`
Protocols HTTPProtocol `json:"signedProtocol,omitempty"`
SharedAccessStartTime *date.Time `json:"signedStart,omitempty"`
SharedAccessExpiryTime *date.Time `json:"signedExpiry,omitempty"`
KeyToSign *string `json:"keyToSign,omitempty"`
}
// AccountUpdateParameters is the parameters that can be provided when updating
// the storage account properties.
type AccountUpdateParameters struct { type AccountUpdateParameters struct {
Sku *Sku `json:"sku,omitempty"` Sku *Sku `json:"sku,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
@ -228,8 +342,8 @@ type CheckNameAvailabilityResult struct {
Message *string `json:"message,omitempty"` Message *string `json:"message,omitempty"`
} }
// CustomDomain is the custom domain assigned to this storage account. This // CustomDomain is the custom domain assigned to this storage account. This can
// can be set via Update. // be set via Update.
type CustomDomain struct { type CustomDomain struct {
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
UseSubDomain *bool `json:"useSubDomain,omitempty"` UseSubDomain *bool `json:"useSubDomain,omitempty"`
@ -251,10 +365,13 @@ type EncryptionService struct {
// EncryptionServices is a list of services that support encryption. // EncryptionServices is a list of services that support encryption.
type EncryptionServices struct { type EncryptionServices struct {
Blob *EncryptionService `json:"blob,omitempty"` Blob *EncryptionService `json:"blob,omitempty"`
File *EncryptionService `json:"file,omitempty"`
Table *EncryptionService `json:"table,omitempty"`
Queue *EncryptionService `json:"queue,omitempty"`
} }
// Endpoints is the URIs that are used to perform a retrieval of a public // Endpoints is the URIs that are used to perform a retrieval of a public blob,
// blob, queue, or table object. // queue, or table object.
type Endpoints struct { type Endpoints struct {
Blob *string `json:"blob,omitempty"` Blob *string `json:"blob,omitempty"`
Queue *string `json:"queue,omitempty"` Queue *string `json:"queue,omitempty"`
@ -262,7 +379,20 @@ type Endpoints struct {
File *string `json:"file,omitempty"` File *string `json:"file,omitempty"`
} }
// Resource is // ListAccountSasResponse is the List SAS credentials operation response.
type ListAccountSasResponse struct {
autorest.Response `json:"-"`
AccountSasToken *string `json:"accountSasToken,omitempty"`
}
// ListServiceSasResponse is the List service SAS credentials operation
// response.
type ListServiceSasResponse struct {
autorest.Response `json:"-"`
ServiceSasToken *string `json:"serviceSasToken,omitempty"`
}
// Resource is describes a storage resource.
type Resource struct { type Resource struct {
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
@ -271,6 +401,29 @@ type Resource struct {
Tags *map[string]*string `json:"tags,omitempty"` Tags *map[string]*string `json:"tags,omitempty"`
} }
// ServiceSasParameters is the parameters to list service SAS credentials of a
// speicific resource.
type ServiceSasParameters struct {
CanonicalizedResource *string `json:"canonicalizedResource,omitempty"`
Resource Resource `json:"signedResource,omitempty"`
Permissions Permissions `json:"signedPermission,omitempty"`
IPAddressOrRange *string `json:"signedIp,omitempty"`
Protocols HTTPProtocol `json:"signedProtocol,omitempty"`
SharedAccessStartTime *date.Time `json:"signedStart,omitempty"`
SharedAccessExpiryTime *date.Time `json:"signedExpiry,omitempty"`
Identifier *string `json:"signedIdentifier,omitempty"`
PartitionKeyStart *string `json:"startPk,omitempty"`
PartitionKeyEnd *string `json:"endPk,omitempty"`
RowKeyStart *string `json:"startRk,omitempty"`
RowKeyEnd *string `json:"endRk,omitempty"`
KeyToSign *string `json:"keyToSign,omitempty"`
CacheControl *string `json:"rscc,omitempty"`
ContentDisposition *string `json:"rscd,omitempty"`
ContentEncoding *string `json:"rsce,omitempty"`
ContentLanguage *string `json:"rscl,omitempty"`
ContentType *string `json:"rsct,omitempty"`
}
// Sku is the SKU of the storage account. // Sku is the SKU of the storage account.
type Sku struct { type Sku struct {
Name SkuName `json:"name,omitempty"` Name SkuName `json:"name,omitempty"`

View File

@ -1,101 +0,0 @@
package storage
// 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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"net/http"
)
// UsageOperationsClient is the the Storage Management Client.
type UsageOperationsClient struct {
ManagementClient
}
// NewUsageOperationsClient creates an instance of the UsageOperationsClient
// client.
func NewUsageOperationsClient(subscriptionID string) UsageOperationsClient {
return NewUsageOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewUsageOperationsClientWithBaseURI creates an instance of the
// UsageOperationsClient client.
func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) UsageOperationsClient {
return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// List gets the current usage count and the limit for the resources under the
// subscription.
func (client UsageOperationsClient) List() (result UsageListResult, err error) {
req, err := client.ListPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", nil, "Failure preparing request")
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", resp, "Failure sending request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "storage.UsageOperationsClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client UsageOperationsClient) ListPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client UsageOperationsClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client UsageOperationsClient) ListResponder(resp *http.Response) (result UsageListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}

20
vendor/github.com/Azure/azure-sdk-for-go/arm/storage/version.go generated vendored Normal file → Executable file
View File

@ -14,30 +14,16 @@ package storage
// See the License for the specific language governing permissions and // See the License for the specific language governing permissions and
// limitations under the License. // limitations under the License.
// //
// Code generated by Microsoft (R) AutoRest Code Generator 0.17.0.0 // Code generated by Microsoft (R) AutoRest Code Generator 1.0.1.0
// Changes may cause incorrect behavior and will be lost if the code is // Changes may cause incorrect behavior and will be lost if the code is
// regenerated. // regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests. // UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string { func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "storage", "2016-01-01") return "Azure-SDK-For-Go/v10.0.2-beta arm-storage/2016-12-01"
} }
// Version returns the semantic version (see http://semver.org) of the client. // Version returns the semantic version (see http://semver.org) of the client.
func Version() string { func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag) return "v10.0.2-beta"
} }

View File

@ -1,35 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"blob.go",
"client.go",
"file.go",
"queue.go",
"table.go",
"table_entities.go",
"util.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -1,5 +0,0 @@
# Azure Storage SDK for Go
The `github.com/Azure/azure-sdk-for-go/storage` package is used to perform operations in Azure Storage Service. To manage your storage accounts (Azure Resource Manager / ARM), use the [github.com/Azure/azure-sdk-for-go/arm/storage](../arm/storage) package. For your classic storage accounts (Azure Service Management / ASM), use [github.com/Azure/azure-sdk-for-go/management/storageservice](../management/storageservice) package.
This package includes support for [Azure Storage Emulator](https://azure.microsoft.com/documentation/articles/storage-use-emulator/)

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,7 @@
package storage package storage
import ( import (
"bufio"
"bytes" "bytes"
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
@ -10,22 +11,27 @@ import (
"fmt" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"mime"
"mime/multipart"
"net/http" "net/http"
"net/url" "net/url"
"regexp" "regexp"
"sort" "runtime"
"strconv"
"strings" "strings"
"time"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
) )
const ( const (
// DefaultBaseURL is the domain name used for storage requests when a // DefaultBaseURL is the domain name used for storage requests in the
// default client is created. // public cloud when a default client is created.
DefaultBaseURL = "core.windows.net" DefaultBaseURL = "core.windows.net"
// DefaultAPIVersion is the Azure Storage API version string used when a // DefaultAPIVersion is the Azure Storage API version string used when a
// basic client is created. // basic client is created.
DefaultAPIVersion = "2015-02-21" DefaultAPIVersion = "2016-05-31"
defaultUseHTTPS = true defaultUseHTTPS = true
@ -43,20 +49,75 @@ const (
storageEmulatorBlob = "127.0.0.1:10000" storageEmulatorBlob = "127.0.0.1:10000"
storageEmulatorTable = "127.0.0.1:10002" storageEmulatorTable = "127.0.0.1:10002"
storageEmulatorQueue = "127.0.0.1:10001" storageEmulatorQueue = "127.0.0.1:10001"
userAgentHeader = "User-Agent"
userDefinedMetadataHeaderPrefix = "x-ms-meta-"
) )
var (
validStorageAccount = regexp.MustCompile("^[0-9a-z]{3,24}$")
)
// Sender sends a request
type Sender interface {
Send(*Client, *http.Request) (*http.Response, error)
}
// DefaultSender is the default sender for the client. It implements
// an automatic retry strategy.
type DefaultSender struct {
RetryAttempts int
RetryDuration time.Duration
ValidStatusCodes []int
attempts int // used for testing
}
// Send is the default retry strategy in the client
func (ds *DefaultSender) Send(c *Client, req *http.Request) (resp *http.Response, err error) {
b := []byte{}
if req.Body != nil {
b, err = ioutil.ReadAll(req.Body)
if err != nil {
return resp, err
}
}
for attempts := 0; attempts < ds.RetryAttempts; attempts++ {
if len(b) > 0 {
req.Body = ioutil.NopCloser(bytes.NewBuffer(b))
}
resp, err = c.HTTPClient.Do(req)
if err != nil || !autorest.ResponseHasStatusCode(resp, ds.ValidStatusCodes...) {
return resp, err
}
autorest.DelayForBackoff(ds.RetryDuration, attempts, req.Cancel)
ds.attempts = attempts
}
ds.attempts++
return resp, err
}
// Client is the object that needs to be constructed to perform // Client is the object that needs to be constructed to perform
// operations on the storage account. // operations on the storage account.
type Client struct { type Client struct {
// HTTPClient is the http.Client used to initiate API // HTTPClient is the http.Client used to initiate API
// requests. If it is nil, http.DefaultClient is used. // requests. http.DefaultClient is used when creating a
// client.
HTTPClient *http.Client HTTPClient *http.Client
// Sender is an interface that sends the request. Clients are
// created with a DefaultSender. The DefaultSender has an
// automatic retry strategy built in. The Sender can be customized.
Sender Sender
accountName string accountName string
accountKey []byte accountKey []byte
useHTTPS bool useHTTPS bool
UseSharedKeyLite bool
baseURL string baseURL string
apiVersion string apiVersion string
userAgent string
} }
type storageResponse struct { type storageResponse struct {
@ -67,7 +128,7 @@ type storageResponse struct {
type odataResponse struct { type odataResponse struct {
storageResponse storageResponse
odata odataErrorMessage odata odataErrorWrapper
} }
// AzureStorageServiceError contains fields of the error response from // AzureStorageServiceError contains fields of the error response from
@ -80,22 +141,25 @@ type AzureStorageServiceError struct {
QueryParameterName string `xml:"QueryParameterName"` QueryParameterName string `xml:"QueryParameterName"`
QueryParameterValue string `xml:"QueryParameterValue"` QueryParameterValue string `xml:"QueryParameterValue"`
Reason string `xml:"Reason"` Reason string `xml:"Reason"`
Lang string
StatusCode int StatusCode int
RequestID string RequestID string
Date string
APIVersion string
} }
type odataErrorMessageMessage struct { type odataErrorMessage struct {
Lang string `json:"lang"` Lang string `json:"lang"`
Value string `json:"value"` Value string `json:"value"`
} }
type odataErrorMessageInternal struct { type odataError struct {
Code string `json:"code"` Code string `json:"code"`
Message odataErrorMessageMessage `json:"message"` Message odataErrorMessage `json:"message"`
} }
type odataErrorMessage struct { type odataErrorWrapper struct {
Err odataErrorMessageInternal `json:"odata.error"` Err odataError `json:"odata.error"`
} }
// UnexpectedStatusCodeError is returned when a storage service responds with neither an error // UnexpectedStatusCodeError is returned when a storage service responds with neither an error
@ -128,7 +192,15 @@ func NewBasicClient(accountName, accountKey string) (Client, error) {
return NewEmulatorClient() return NewEmulatorClient()
} }
return NewClient(accountName, accountKey, DefaultBaseURL, DefaultAPIVersion, defaultUseHTTPS) return NewClient(accountName, accountKey, DefaultBaseURL, DefaultAPIVersion, defaultUseHTTPS)
}
// NewBasicClientOnSovereignCloud constructs a Client with given storage service name and
// key in the referenced cloud.
func NewBasicClientOnSovereignCloud(accountName, accountKey string, env azure.Environment) (Client, error) {
if accountName == StorageEmulatorAccountName {
return NewEmulatorClient()
}
return NewClient(accountName, accountKey, env.StorageEndpointSuffix, DefaultAPIVersion, defaultUseHTTPS)
} }
//NewEmulatorClient contructs a Client intended to only work with Azure //NewEmulatorClient contructs a Client intended to only work with Azure
@ -142,8 +214,8 @@ func NewEmulatorClient() (Client, error) {
// storage endpoint than Azure Public Cloud. // storage endpoint than Azure Public Cloud.
func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error) { func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, useHTTPS bool) (Client, error) {
var c Client var c Client
if accountName == "" { if !IsValidStorageAccount(accountName) {
return c, fmt.Errorf("azure: account name required") return c, fmt.Errorf("azure: account name is not valid: it must be between 3 and 24 characters, and only may contain numbers and lowercase letters: %v", accountName)
} else if accountKey == "" { } else if accountKey == "" {
return c, fmt.Errorf("azure: account key required") return c, fmt.Errorf("azure: account key required")
} else if blobServiceBaseURL == "" { } else if blobServiceBaseURL == "" {
@ -155,16 +227,67 @@ func NewClient(accountName, accountKey, blobServiceBaseURL, apiVersion string, u
return c, fmt.Errorf("azure: malformed storage account key: %v", err) return c, fmt.Errorf("azure: malformed storage account key: %v", err)
} }
return Client{ c = Client{
HTTPClient: http.DefaultClient,
accountName: accountName, accountName: accountName,
accountKey: key, accountKey: key,
useHTTPS: useHTTPS, useHTTPS: useHTTPS,
baseURL: blobServiceBaseURL, baseURL: blobServiceBaseURL,
apiVersion: apiVersion, apiVersion: apiVersion,
}, nil UseSharedKeyLite: false,
Sender: &DefaultSender{
RetryAttempts: 5,
ValidStatusCodes: []int{
http.StatusRequestTimeout, // 408
http.StatusInternalServerError, // 500
http.StatusBadGateway, // 502
http.StatusServiceUnavailable, // 503
http.StatusGatewayTimeout, // 504
},
RetryDuration: time.Second * 5,
},
}
c.userAgent = c.getDefaultUserAgent()
return c, nil
} }
func (c Client) getBaseURL(service string) string { // IsValidStorageAccount checks if the storage account name is valid.
// See https://docs.microsoft.com/en-us/azure/storage/storage-create-storage-account
func IsValidStorageAccount(account string) bool {
return validStorageAccount.MatchString(account)
}
func (c Client) getDefaultUserAgent() string {
return fmt.Sprintf("Go/%s (%s-%s) azure-storage-go/%s api-version/%s",
runtime.Version(),
runtime.GOARCH,
runtime.GOOS,
sdkVersion,
c.apiVersion,
)
}
// AddToUserAgent adds an extension to the current user agent
func (c *Client) AddToUserAgent(extension string) error {
if extension != "" {
c.userAgent = fmt.Sprintf("%s %s", c.userAgent, extension)
return nil
}
return fmt.Errorf("Extension was empty, User Agent stayed as %s", c.userAgent)
}
// protectUserAgent is used in funcs that include extraheaders as a parameter.
// It prevents the User-Agent header to be overwritten, instead if it happens to
// be present, it gets added to the current User-Agent. Use it before getStandardHeaders
func (c *Client) protectUserAgent(extraheaders map[string]string) map[string]string {
if v, ok := extraheaders[userAgentHeader]; ok {
c.AddToUserAgent(v)
delete(extraheaders, userAgentHeader)
}
return extraheaders
}
func (c Client) getBaseURL(service string) *url.URL {
scheme := "http" scheme := "http"
if c.useHTTPS { if c.useHTTPS {
scheme = "https" scheme = "https"
@ -183,18 +306,14 @@ func (c Client) getBaseURL(service string) string {
host = fmt.Sprintf("%s.%s.%s", c.accountName, service, c.baseURL) host = fmt.Sprintf("%s.%s.%s", c.accountName, service, c.baseURL)
} }
u := &url.URL{ return &url.URL{
Scheme: scheme, Scheme: scheme,
Host: host} Host: host,
return u.String() }
} }
func (c Client) getEndpoint(service, path string, params url.Values) string { func (c Client) getEndpoint(service, path string, params url.Values) string {
u, err := url.Parse(c.getBaseURL(service)) u := c.getBaseURL(service)
if err != nil {
// really should not be happening
panic(err)
}
// API doesn't accept path segments not starting with '/' // API doesn't accept path segments not starting with '/'
if !strings.HasPrefix(path, "/") { if !strings.HasPrefix(path, "/") {
@ -213,181 +332,69 @@ func (c Client) getEndpoint(service, path string, params url.Values) string {
// GetBlobService returns a BlobStorageClient which can operate on the blob // GetBlobService returns a BlobStorageClient which can operate on the blob
// service of the storage account. // service of the storage account.
func (c Client) GetBlobService() BlobStorageClient { func (c Client) GetBlobService() BlobStorageClient {
return BlobStorageClient{c} b := BlobStorageClient{
client: c,
}
b.client.AddToUserAgent(blobServiceName)
b.auth = sharedKey
if c.UseSharedKeyLite {
b.auth = sharedKeyLite
}
return b
} }
// GetQueueService returns a QueueServiceClient which can operate on the queue // GetQueueService returns a QueueServiceClient which can operate on the queue
// service of the storage account. // service of the storage account.
func (c Client) GetQueueService() QueueServiceClient { func (c Client) GetQueueService() QueueServiceClient {
return QueueServiceClient{c} q := QueueServiceClient{
client: c,
}
q.client.AddToUserAgent(queueServiceName)
q.auth = sharedKey
if c.UseSharedKeyLite {
q.auth = sharedKeyLite
}
return q
} }
// GetTableService returns a TableServiceClient which can operate on the table // GetTableService returns a TableServiceClient which can operate on the table
// service of the storage account. // service of the storage account.
func (c Client) GetTableService() TableServiceClient { func (c Client) GetTableService() TableServiceClient {
return TableServiceClient{c} t := TableServiceClient{
client: c,
}
t.client.AddToUserAgent(tableServiceName)
t.auth = sharedKeyForTable
if c.UseSharedKeyLite {
t.auth = sharedKeyLiteForTable
}
return t
} }
// GetFileService returns a FileServiceClient which can operate on the file // GetFileService returns a FileServiceClient which can operate on the file
// service of the storage account. // service of the storage account.
func (c Client) GetFileService() FileServiceClient { func (c Client) GetFileService() FileServiceClient {
return FileServiceClient{c} f := FileServiceClient{
} client: c,
func (c Client) createAuthorizationHeader(canonicalizedString string) string {
signature := c.computeHmac256(canonicalizedString)
return fmt.Sprintf("%s %s:%s", "SharedKey", c.getCanonicalizedAccountName(), signature)
}
func (c Client) getAuthorizationHeader(verb, url string, headers map[string]string) (string, error) {
canonicalizedResource, err := c.buildCanonicalizedResource(url)
if err != nil {
return "", err
} }
f.client.AddToUserAgent(fileServiceName)
canonicalizedString := c.buildCanonicalizedString(verb, headers, canonicalizedResource) f.auth = sharedKey
return c.createAuthorizationHeader(canonicalizedString), nil if c.UseSharedKeyLite {
f.auth = sharedKeyLite
}
return f
} }
func (c Client) getStandardHeaders() map[string]string { func (c Client) getStandardHeaders() map[string]string {
return map[string]string{ return map[string]string{
userAgentHeader: c.userAgent,
"x-ms-version": c.apiVersion, "x-ms-version": c.apiVersion,
"x-ms-date": currentTimeRfc1123Formatted(), "x-ms-date": currentTimeRfc1123Formatted(),
} }
} }
func (c Client) getCanonicalizedAccountName() string { func (c Client) exec(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*storageResponse, error) {
// since we may be trying to access a secondary storage account, we need to headers, err := c.addAuthorizationHeader(verb, url, headers, auth)
// remove the -secondary part of the storage name
return strings.TrimSuffix(c.accountName, "-secondary")
}
func (c Client) buildCanonicalizedHeader(headers map[string]string) string {
cm := make(map[string]string)
for k, v := range headers {
headerName := strings.TrimSpace(strings.ToLower(k))
match, _ := regexp.MatchString("x-ms-", headerName)
if match {
cm[headerName] = v
}
}
if len(cm) == 0 {
return ""
}
keys := make([]string, 0, len(cm))
for key := range cm {
keys = append(keys, key)
}
sort.Strings(keys)
ch := ""
for i, key := range keys {
if i == len(keys)-1 {
ch += fmt.Sprintf("%s:%s", key, cm[key])
} else {
ch += fmt.Sprintf("%s:%s\n", key, cm[key])
}
}
return ch
}
func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) {
errMsg := "buildCanonicalizedResourceTable error: %s"
u, err := url.Parse(uri)
if err != nil {
return "", fmt.Errorf(errMsg, err.Error())
}
cr := "/" + c.getCanonicalizedAccountName()
if len(u.Path) > 0 {
cr += u.EscapedPath()
}
return cr, nil
}
func (c Client) buildCanonicalizedResource(uri string) (string, error) {
errMsg := "buildCanonicalizedResource error: %s"
u, err := url.Parse(uri)
if err != nil {
return "", fmt.Errorf(errMsg, err.Error())
}
cr := "/" + c.getCanonicalizedAccountName()
if len(u.Path) > 0 {
// Any portion of the CanonicalizedResource string that is derived from
// the resource's URI should be encoded exactly as it is in the URI.
// -- https://msdn.microsoft.com/en-gb/library/azure/dd179428.aspx
cr += u.EscapedPath()
}
params, err := url.ParseQuery(u.RawQuery)
if err != nil {
return "", fmt.Errorf(errMsg, err.Error())
}
if len(params) > 0 {
cr += "\n"
keys := make([]string, 0, len(params))
for key := range params {
keys = append(keys, key)
}
sort.Strings(keys)
for i, key := range keys {
if len(params[key]) > 1 {
sort.Strings(params[key])
}
if i == len(keys)-1 {
cr += fmt.Sprintf("%s:%s", key, strings.Join(params[key], ","))
} else {
cr += fmt.Sprintf("%s:%s\n", key, strings.Join(params[key], ","))
}
}
}
return cr, nil
}
func (c Client) buildCanonicalizedString(verb string, headers map[string]string, canonicalizedResource string) string {
contentLength := headers["Content-Length"]
if contentLength == "0" {
contentLength = ""
}
canonicalizedString := fmt.Sprintf("%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s",
verb,
headers["Content-Encoding"],
headers["Content-Language"],
contentLength,
headers["Content-MD5"],
headers["Content-Type"],
headers["Date"],
headers["If-Modified-Since"],
headers["If-Match"],
headers["If-None-Match"],
headers["If-Unmodified-Since"],
headers["Range"],
c.buildCanonicalizedHeader(headers),
canonicalizedResource)
return canonicalizedString
}
func (c Client) exec(verb, url string, headers map[string]string, body io.Reader) (*storageResponse, error) {
authHeader, err := c.getAuthorizationHeader(verb, url, headers)
if err != nil {
return nil, err
}
headers["Authorization"] = authHeader
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -397,46 +404,45 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader
return nil, errors.New("azure/storage: error creating request: " + err.Error()) return nil, errors.New("azure/storage: error creating request: " + err.Error())
} }
if clstr, ok := headers["Content-Length"]; ok {
// content length header is being signed, but completely ignored by golang.
// instead we have to use the ContentLength property on the request struct
// (see https://golang.org/src/net/http/request.go?s=18140:18370#L536 and
// https://golang.org/src/net/http/transfer.go?s=1739:2467#L49)
req.ContentLength, err = strconv.ParseInt(clstr, 10, 64)
if err != nil {
return nil, err
}
}
for k, v := range headers { for k, v := range headers {
req.Header.Add(k, v) req.Header.Add(k, v)
} }
httpClient := c.HTTPClient resp, err := c.Sender.Send(&c, req)
if httpClient == nil {
httpClient = http.DefaultClient
}
resp, err := httpClient.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err
} }
statusCode := resp.StatusCode if resp.StatusCode >= 400 && resp.StatusCode <= 505 {
if statusCode >= 400 && statusCode <= 505 {
var respBody []byte var respBody []byte
respBody, err = readResponseBody(resp) respBody, err = readAndCloseBody(resp.Body)
if err != nil { if err != nil {
return nil, err return nil, err
} }
requestID, date, version := getDebugHeaders(resp.Header)
if len(respBody) == 0 { if len(respBody) == 0 {
// no error in response body // no error in response body, might happen in HEAD requests
err = fmt.Errorf("storage: service returned without a response body (%s)", resp.Status) err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, requestID, date, version)
} else { } else {
storageErr := AzureStorageServiceError{
StatusCode: resp.StatusCode,
RequestID: requestID,
Date: date,
APIVersion: version,
}
// response contains storage service error object, unmarshal // response contains storage service error object, unmarshal
storageErr, errIn := serviceErrFromXML(respBody, resp.StatusCode, resp.Header.Get("x-ms-request-id")) if resp.Header.Get("Content-Type") == "application/xml" {
errIn := serviceErrFromXML(respBody, &storageErr)
if err != nil { // error unmarshaling the error response if err != nil { // error unmarshaling the error response
err = errIn err = errIn
} }
} else {
errIn := serviceErrFromJSON(respBody, &storageErr)
if err != nil { // error unmarshaling the error response
err = errIn
}
}
err = storageErr err = storageErr
} }
return &storageResponse{ return &storageResponse{
@ -452,20 +458,20 @@ func (c Client) exec(verb, url string, headers map[string]string, body io.Reader
body: resp.Body}, nil body: resp.Body}, nil
} }
func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) { func (c Client) execInternalJSONCommon(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, *http.Request, *http.Response, error) {
headers, err := c.addAuthorizationHeader(verb, url, headers, auth)
if err != nil {
return nil, nil, nil, err
}
req, err := http.NewRequest(verb, url, body) req, err := http.NewRequest(verb, url, body)
for k, v := range headers { for k, v := range headers {
req.Header.Add(k, v) req.Header.Add(k, v)
} }
httpClient := c.HTTPClient resp, err := c.Sender.Send(&c, req)
if httpClient == nil {
httpClient = http.DefaultClient
}
resp, err := httpClient.Do(req)
if err != nil { if err != nil {
return nil, err return nil, nil, nil, err
} }
respToRet := &odataResponse{} respToRet := &odataResponse{}
@ -476,68 +482,155 @@ func (c Client) execInternalJSON(verb, url string, headers map[string]string, bo
statusCode := resp.StatusCode statusCode := resp.StatusCode
if statusCode >= 400 && statusCode <= 505 { if statusCode >= 400 && statusCode <= 505 {
var respBody []byte var respBody []byte
respBody, err = readResponseBody(resp) respBody, err = readAndCloseBody(resp.Body)
if err != nil {
return nil, nil, nil, err
}
requestID, date, version := getDebugHeaders(resp.Header)
if len(respBody) == 0 {
// no error in response body, might happen in HEAD requests
err = serviceErrFromStatusCode(resp.StatusCode, resp.Status, requestID, date, version)
return respToRet, req, resp, err
}
// try unmarshal as odata.error json
err = json.Unmarshal(respBody, &respToRet.odata)
}
return respToRet, req, resp, err
}
func (c Client) execInternalJSON(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, error) {
respToRet, _, _, err := c.execInternalJSONCommon(verb, url, headers, body, auth)
return respToRet, err
}
func (c Client) execBatchOperationJSON(verb, url string, headers map[string]string, body io.Reader, auth authentication) (*odataResponse, error) {
// execute common query, get back generated request, response etc... for more processing.
respToRet, req, resp, err := c.execInternalJSONCommon(verb, url, headers, body, auth)
if err != nil { if err != nil {
return nil, err return nil, err
} }
if len(respBody) == 0 { // return the OData in the case of executing batch commands.
// no error in response body // In this case we need to read the outer batch boundary and contents.
err = fmt.Errorf("storage: service returned without a response body (%d)", resp.StatusCode) // Then we read the changeset information within the batch
return respToRet, err var respBody []byte
respBody, err = readAndCloseBody(resp.Body)
if err != nil {
return nil, err
} }
// try unmarshal as odata.error json
err = json.Unmarshal(respBody, &respToRet.odata) // outer multipart body
return respToRet, err _, batchHeader, err := mime.ParseMediaType(resp.Header["Content-Type"][0])
if err != nil {
return nil, err
}
// batch details.
batchBoundary := batchHeader["boundary"]
batchPartBuf, changesetBoundary, err := genBatchReader(batchBoundary, respBody)
if err != nil {
return nil, err
}
// changeset details.
err = genChangesetReader(req, respToRet, batchPartBuf, changesetBoundary)
if err != nil {
return nil, err
} }
return respToRet, nil return respToRet, nil
} }
func (c Client) createSharedKeyLite(url string, headers map[string]string) (string, error) { func genChangesetReader(req *http.Request, respToRet *odataResponse, batchPartBuf io.Reader, changesetBoundary string) error {
can, err := c.buildCanonicalizedResourceTable(url) changesetMultiReader := multipart.NewReader(batchPartBuf, changesetBoundary)
changesetPart, err := changesetMultiReader.NextPart()
if err != nil { if err != nil {
return "", err return err
}
strToSign := headers["x-ms-date"] + "\n" + can
hmac := c.computeHmac256(strToSign)
return fmt.Sprintf("SharedKeyLite %s:%s", c.accountName, hmac), nil
}
func (c Client) execTable(verb, url string, headers map[string]string, body io.Reader) (*odataResponse, error) {
var err error
headers["Authorization"], err = c.createSharedKeyLite(url, headers)
if err != nil {
return nil, err
} }
return c.execInternalJSON(verb, url, headers, body) changesetPartBufioReader := bufio.NewReader(changesetPart)
changesetResp, err := http.ReadResponse(changesetPartBufioReader, req)
if err != nil {
return err
}
if changesetResp.StatusCode != http.StatusNoContent {
changesetBody, err := readAndCloseBody(changesetResp.Body)
err = json.Unmarshal(changesetBody, &respToRet.odata)
if err != nil {
return err
}
respToRet.statusCode = changesetResp.StatusCode
}
return nil
} }
func readResponseBody(resp *http.Response) ([]byte, error) { func genBatchReader(batchBoundary string, respBody []byte) (io.Reader, string, error) {
defer resp.Body.Close() respBodyString := string(respBody)
out, err := ioutil.ReadAll(resp.Body) respBodyReader := strings.NewReader(respBodyString)
// reading batchresponse
batchMultiReader := multipart.NewReader(respBodyReader, batchBoundary)
batchPart, err := batchMultiReader.NextPart()
if err != nil {
return nil, "", err
}
batchPartBufioReader := bufio.NewReader(batchPart)
_, changesetHeader, err := mime.ParseMediaType(batchPart.Header.Get("Content-Type"))
if err != nil {
return nil, "", err
}
changesetBoundary := changesetHeader["boundary"]
return batchPartBufioReader, changesetBoundary, nil
}
func readAndCloseBody(body io.ReadCloser) ([]byte, error) {
defer body.Close()
out, err := ioutil.ReadAll(body)
if err == io.EOF { if err == io.EOF {
err = nil err = nil
} }
return out, err return out, err
} }
func serviceErrFromXML(body []byte, statusCode int, requestID string) (AzureStorageServiceError, error) { func serviceErrFromXML(body []byte, storageErr *AzureStorageServiceError) error {
var storageErr AzureStorageServiceError if err := xml.Unmarshal(body, storageErr); err != nil {
if err := xml.Unmarshal(body, &storageErr); err != nil { storageErr.Message = fmt.Sprintf("Response body could no be unmarshaled: %v. Body: %v.", err, string(body))
return storageErr, err return err
}
return nil
}
func serviceErrFromJSON(body []byte, storageErr *AzureStorageServiceError) error {
odataError := odataErrorWrapper{}
if err := json.Unmarshal(body, &odataError); err != nil {
storageErr.Message = fmt.Sprintf("Response body could no be unmarshaled: %v. Body: %v.", err, string(body))
return err
}
storageErr.Code = odataError.Err.Code
storageErr.Message = odataError.Err.Message.Value
storageErr.Lang = odataError.Err.Message.Lang
return nil
}
func serviceErrFromStatusCode(code int, status string, requestID, date, version string) AzureStorageServiceError {
return AzureStorageServiceError{
StatusCode: code,
Code: status,
RequestID: requestID,
Date: date,
APIVersion: version,
Message: "no response body was available for error status code",
} }
storageErr.StatusCode = statusCode
storageErr.RequestID = requestID
return storageErr, nil
} }
func (e AzureStorageServiceError) Error() string { func (e AzureStorageServiceError) Error() string {
return fmt.Sprintf("storage: service returned error: StatusCode=%d, ErrorCode=%s, ErrorMessage=%s, RequestId=%s, QueryParameterName=%s, QueryParameterValue=%s", return fmt.Sprintf("storage: service returned error: StatusCode=%d, ErrorCode=%s, ErrorMessage=%s, RequestInitiated=%s, RequestId=%s, API Version=%s, QueryParameterName=%s, QueryParameterValue=%s",
e.StatusCode, e.Code, e.Message, e.RequestID, e.QueryParameterName, e.QueryParameterValue) e.StatusCode, e.Code, e.Message, e.Date, e.RequestID, e.APIVersion, e.QueryParameterName, e.QueryParameterValue)
} }
// checkRespCode returns UnexpectedStatusError if the given response code is not // checkRespCode returns UnexpectedStatusError if the given response code is not
@ -550,3 +643,18 @@ func checkRespCode(respCode int, allowed []int) error {
} }
return UnexpectedStatusCodeError{allowed, respCode} return UnexpectedStatusCodeError{allowed, respCode}
} }
func (c Client) addMetadataToHeaders(h map[string]string, metadata map[string]string) map[string]string {
metadata = c.protectUserAgent(metadata)
for k, v := range metadata {
h[userDefinedMetadataHeaderPrefix+k] = v
}
return h
}
func getDebugHeaders(h http.Header) (requestID, date, version string) {
requestID = h.Get("x-ms-request-id")
version = h.Get("x-ms-version")
date = h.Get("Date")
return
}

File diff suppressed because it is too large Load Diff

View File

@ -2,166 +2,139 @@ package storage
import ( import (
"encoding/xml" "encoding/xml"
"errors"
"fmt" "fmt"
"io"
"net/http" "net/http"
"net/url" "net/url"
"strconv" "strconv"
"strings" "time"
) )
const ( const (
// casing is per Golang's http.Header canonicalizing the header names. // casing is per Golang's http.Header canonicalizing the header names.
approximateMessagesCountHeader = "X-Ms-Approximate-Messages-Count" approximateMessagesCountHeader = "X-Ms-Approximate-Messages-Count"
userDefinedMetadataHeaderPrefix = "X-Ms-Meta-"
) )
// QueueServiceClient contains operations for Microsoft Azure Queue Storage // QueueAccessPolicy represents each access policy in the queue ACL.
// Service. type QueueAccessPolicy struct {
type QueueServiceClient struct { ID string
client Client StartTime time.Time
ExpiryTime time.Time
CanRead bool
CanAdd bool
CanUpdate bool
CanProcess bool
} }
func pathForQueue(queue string) string { return fmt.Sprintf("/%s", queue) } // QueuePermissions represents the queue ACLs.
func pathForQueueMessages(queue string) string { return fmt.Sprintf("/%s/messages", queue) } type QueuePermissions struct {
func pathForMessage(queue, name string) string { return fmt.Sprintf("/%s/messages/%s", queue, name) } AccessPolicies []QueueAccessPolicy
type putMessageRequest struct {
XMLName xml.Name `xml:"QueueMessage"`
MessageText string `xml:"MessageText"`
} }
// PutMessageParameters is the set of options can be specified for Put Messsage // SetQueuePermissionOptions includes options for a set queue permissions operation
// operation. A zero struct does not use any preferences for the request. type SetQueuePermissionOptions struct {
type PutMessageParameters struct { Timeout uint
VisibilityTimeout int RequestID string `header:"x-ms-client-request-id"`
MessageTTL int
} }
func (p PutMessageParameters) getParameters() url.Values { // Queue represents an Azure queue.
out := url.Values{} type Queue struct {
if p.VisibilityTimeout != 0 { qsc *QueueServiceClient
out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout)) Name string
} Metadata map[string]string
if p.MessageTTL != 0 { AproxMessageCount uint64
out.Set("messagettl", strconv.Itoa(p.MessageTTL))
}
return out
} }
// GetMessagesParameters is the set of options can be specified for Get func (q *Queue) buildPath() string {
// Messsages operation. A zero struct does not use any preferences for the return fmt.Sprintf("/%s", q.Name)
// request.
type GetMessagesParameters struct {
NumOfMessages int
VisibilityTimeout int
} }
func (p GetMessagesParameters) getParameters() url.Values { func (q *Queue) buildPathMessages() string {
out := url.Values{} return fmt.Sprintf("%s/messages", q.buildPath())
if p.NumOfMessages != 0 {
out.Set("numofmessages", strconv.Itoa(p.NumOfMessages))
}
if p.VisibilityTimeout != 0 {
out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout))
}
return out
} }
// PeekMessagesParameters is the set of options can be specified for Peek // QueueServiceOptions includes options for some queue service operations
// Messsage operation. A zero struct does not use any preferences for the type QueueServiceOptions struct {
// request. Timeout uint
type PeekMessagesParameters struct { RequestID string `header:"x-ms-client-request-id"`
NumOfMessages int
} }
func (p PeekMessagesParameters) getParameters() url.Values { // Create operation creates a queue under the given account.
out := url.Values{"peekonly": {"true"}} // Required for peek operation
if p.NumOfMessages != 0 {
out.Set("numofmessages", strconv.Itoa(p.NumOfMessages))
}
return out
}
// UpdateMessageParameters is the set of options can be specified for Update Messsage
// operation. A zero struct does not use any preferences for the request.
type UpdateMessageParameters struct {
PopReceipt string
VisibilityTimeout int
}
func (p UpdateMessageParameters) getParameters() url.Values {
out := url.Values{}
if p.PopReceipt != "" {
out.Set("popreceipt", p.PopReceipt)
}
if p.VisibilityTimeout != 0 {
out.Set("visibilitytimeout", strconv.Itoa(p.VisibilityTimeout))
}
return out
}
// GetMessagesResponse represents a response returned from Get Messages
// operation.
type GetMessagesResponse struct {
XMLName xml.Name `xml:"QueueMessagesList"`
QueueMessagesList []GetMessageResponse `xml:"QueueMessage"`
}
// GetMessageResponse represents a QueueMessage object returned from Get
// Messages operation response.
type GetMessageResponse struct {
MessageID string `xml:"MessageId"`
InsertionTime string `xml:"InsertionTime"`
ExpirationTime string `xml:"ExpirationTime"`
PopReceipt string `xml:"PopReceipt"`
TimeNextVisible string `xml:"TimeNextVisible"`
DequeueCount int `xml:"DequeueCount"`
MessageText string `xml:"MessageText"`
}
// PeekMessagesResponse represents a response returned from Get Messages
// operation.
type PeekMessagesResponse struct {
XMLName xml.Name `xml:"QueueMessagesList"`
QueueMessagesList []PeekMessageResponse `xml:"QueueMessage"`
}
// PeekMessageResponse represents a QueueMessage object returned from Peek
// Messages operation response.
type PeekMessageResponse struct {
MessageID string `xml:"MessageId"`
InsertionTime string `xml:"InsertionTime"`
ExpirationTime string `xml:"ExpirationTime"`
DequeueCount int `xml:"DequeueCount"`
MessageText string `xml:"MessageText"`
}
// QueueMetadataResponse represents user defined metadata and queue
// properties on a specific queue.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179384.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Create-Queue4
type QueueMetadataResponse struct { func (q *Queue) Create(options *QueueServiceOptions) error {
ApproximateMessageCount int params := url.Values{}
UserDefinedMetadata map[string]string headers := q.qsc.client.getStandardHeaders()
headers = q.qsc.client.addMetadataToHeaders(headers, q.Metadata)
if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params)
resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, nil, q.qsc.auth)
if err != nil {
return err
}
readAndCloseBody(resp.body)
return checkRespCode(resp.statusCode, []int{http.StatusCreated})
}
// Delete operation permanently deletes the specified queue.
//
// See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Delete-Queue3
func (q *Queue) Delete(options *QueueServiceOptions) error {
params := url.Values{}
headers := q.qsc.client.getStandardHeaders()
if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params)
resp, err := q.qsc.client.exec(http.MethodDelete, uri, headers, nil, q.qsc.auth)
if err != nil {
return err
}
readAndCloseBody(resp.body)
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
}
// Exists returns true if a queue with given name exists.
func (q *Queue) Exists() (bool, error) {
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), url.Values{"comp": {"metadata"}})
resp, err := q.qsc.client.exec(http.MethodGet, uri, q.qsc.client.getStandardHeaders(), nil, q.qsc.auth)
if resp != nil {
defer readAndCloseBody(resp.body)
if resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound {
return resp.statusCode == http.StatusOK, nil
}
}
return false, err
} }
// SetMetadata operation sets user-defined metadata on the specified queue. // SetMetadata operation sets user-defined metadata on the specified queue.
// Metadata is associated with the queue as name-value pairs. // Metadata is associated with the queue as name-value pairs.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179348.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Queue-Metadata
func (c QueueServiceClient) SetMetadata(name string, metadata map[string]string) error { func (q *Queue) SetMetadata(options *QueueServiceOptions) error {
uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": []string{"metadata"}}) params := url.Values{"comp": {"metadata"}}
headers := c.client.getStandardHeaders() headers := q.qsc.client.getStandardHeaders()
for k, v := range metadata { headers = q.qsc.client.addMetadataToHeaders(headers, q.Metadata)
headers[userDefinedMetadataHeaderPrefix+k] = v
}
resp, err := c.client.exec("PUT", uri, headers, nil) if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params)
resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, nil, q.qsc.auth)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() readAndCloseBody(resp.body)
return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
} }
@ -169,176 +142,286 @@ func (c QueueServiceClient) SetMetadata(name string, metadata map[string]string)
// properties on the specified queue. Metadata is associated with // properties on the specified queue. Metadata is associated with
// the queue as name-values pairs. // the queue as name-values pairs.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179384.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Set-Queue-Metadata
// //
// Because the way Golang's http client (and http.Header in particular) // Because the way Golang's http client (and http.Header in particular)
// canonicalize header names, the returned metadata names would always // canonicalize header names, the returned metadata names would always
// be all lower case. // be all lower case.
func (c QueueServiceClient) GetMetadata(name string) (QueueMetadataResponse, error) { func (q *Queue) GetMetadata(options *QueueServiceOptions) error {
qm := QueueMetadataResponse{} params := url.Values{"comp": {"metadata"}}
qm.UserDefinedMetadata = make(map[string]string) headers := q.qsc.client.getStandardHeaders()
uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": []string{"metadata"}})
headers := c.client.getStandardHeaders()
resp, err := c.client.exec("GET", uri, headers, nil)
if err != nil {
return qm, err
}
defer resp.body.Close()
for k, v := range resp.headers { if options != nil {
if len(v) != 1 { params = addTimeout(params, options.Timeout)
return qm, fmt.Errorf("Unexpected number of values (%d) in response header '%s'", len(v), k) headers = mergeHeaders(headers, headersFromStruct(*options))
} }
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), url.Values{"comp": {"metadata"}})
value := v[0] resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth)
if k == approximateMessagesCountHeader {
qm.ApproximateMessageCount, err = strconv.Atoi(value)
if err != nil {
return qm, fmt.Errorf("Unexpected value in response header '%s': '%s' ", k, value)
}
} else if strings.HasPrefix(k, userDefinedMetadataHeaderPrefix) {
name := strings.TrimPrefix(k, userDefinedMetadataHeaderPrefix)
qm.UserDefinedMetadata[strings.ToLower(name)] = value
}
}
return qm, checkRespCode(resp.statusCode, []int{http.StatusOK})
}
// CreateQueue operation creates a queue under the given account.
//
// See https://msdn.microsoft.com/en-us/library/azure/dd179342.aspx
func (c QueueServiceClient) CreateQueue(name string) error {
uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{})
headers := c.client.getStandardHeaders()
resp, err := c.client.exec("PUT", uri, headers, nil)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() defer readAndCloseBody(resp.body)
return checkRespCode(resp.statusCode, []int{http.StatusCreated})
}
// DeleteQueue operation permanently deletes the specified queue. if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil {
// return err
// See https://msdn.microsoft.com/en-us/library/azure/dd179436.aspx }
func (c QueueServiceClient) DeleteQueue(name string) error {
uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{}) aproxMessagesStr := resp.headers.Get(http.CanonicalHeaderKey(approximateMessagesCountHeader))
resp, err := c.client.exec("DELETE", uri, c.client.getStandardHeaders(), nil) if aproxMessagesStr != "" {
aproxMessages, err := strconv.ParseUint(aproxMessagesStr, 10, 64)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() q.AproxMessageCount = aproxMessages
return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) }
q.Metadata = getMetadataFromHeaders(resp.headers)
return nil
} }
// QueueExists returns true if a queue with given name exists. // GetMessageReference returns a message object with the specified text.
func (c QueueServiceClient) QueueExists(name string) (bool, error) { func (q *Queue) GetMessageReference(text string) *Message {
uri := c.client.getEndpoint(queueServiceName, pathForQueue(name), url.Values{"comp": {"metadata"}}) return &Message{
resp, err := c.client.exec("GET", uri, c.client.getStandardHeaders(), nil) Queue: q,
if resp != nil && (resp.statusCode == http.StatusOK || resp.statusCode == http.StatusNotFound) { Text: text,
return resp.statusCode == http.StatusOK, nil
} }
return false, err
} }
// PutMessage operation adds a new message to the back of the message queue. // GetMessagesOptions is the set of options can be specified for Get
// // Messsages operation. A zero struct does not use any preferences for the
// See https://msdn.microsoft.com/en-us/library/azure/dd179346.aspx // request.
func (c QueueServiceClient) PutMessage(queue string, message string, params PutMessageParameters) error { type GetMessagesOptions struct {
uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) Timeout uint
req := putMessageRequest{MessageText: message} NumOfMessages int
body, nn, err := xmlMarshal(req) VisibilityTimeout int
if err != nil { RequestID string `header:"x-ms-client-request-id"`
return err
}
headers := c.client.getStandardHeaders()
headers["Content-Length"] = strconv.Itoa(nn)
resp, err := c.client.exec("POST", uri, headers, body)
if err != nil {
return err
}
defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusCreated})
} }
// ClearMessages operation deletes all messages from the specified queue. type messages struct {
// XMLName xml.Name `xml:"QueueMessagesList"`
// See https://msdn.microsoft.com/en-us/library/azure/dd179454.aspx Messages []Message `xml:"QueueMessage"`
func (c QueueServiceClient) ClearMessages(queue string) error {
uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), url.Values{})
resp, err := c.client.exec("DELETE", uri, c.client.getStandardHeaders(), nil)
if err != nil {
return err
}
defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
} }
// GetMessages operation retrieves one or more messages from the front of the // GetMessages operation retrieves one or more messages from the front of the
// queue. // queue.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179474.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Get-Messages
func (c QueueServiceClient) GetMessages(queue string, params GetMessagesParameters) (GetMessagesResponse, error) { func (q *Queue) GetMessages(options *GetMessagesOptions) ([]Message, error) {
var r GetMessagesResponse query := url.Values{}
uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) headers := q.qsc.client.getStandardHeaders()
resp, err := c.client.exec("GET", uri, c.client.getStandardHeaders(), nil)
if err != nil { if options != nil {
return r, err if options.NumOfMessages != 0 {
query.Set("numofmessages", strconv.Itoa(options.NumOfMessages))
} }
defer resp.body.Close() if options.VisibilityTimeout != 0 {
err = xmlUnmarshal(resp.body, &r) query.Set("visibilitytimeout", strconv.Itoa(options.VisibilityTimeout))
return r, err }
query = addTimeout(query, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), query)
resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth)
if err != nil {
return []Message{}, err
}
defer readAndCloseBody(resp.body)
var out messages
err = xmlUnmarshal(resp.body, &out)
if err != nil {
return []Message{}, err
}
for i := range out.Messages {
out.Messages[i].Queue = q
}
return out.Messages, err
}
// PeekMessagesOptions is the set of options can be specified for Peek
// Messsage operation. A zero struct does not use any preferences for the
// request.
type PeekMessagesOptions struct {
Timeout uint
NumOfMessages int
RequestID string `header:"x-ms-client-request-id"`
} }
// PeekMessages retrieves one or more messages from the front of the queue, but // PeekMessages retrieves one or more messages from the front of the queue, but
// does not alter the visibility of the message. // does not alter the visibility of the message.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179472.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Peek-Messages
func (c QueueServiceClient) PeekMessages(queue string, params PeekMessagesParameters) (PeekMessagesResponse, error) { func (q *Queue) PeekMessages(options *PeekMessagesOptions) ([]Message, error) {
var r PeekMessagesResponse query := url.Values{"peekonly": {"true"}} // Required for peek operation
uri := c.client.getEndpoint(queueServiceName, pathForQueueMessages(queue), params.getParameters()) headers := q.qsc.client.getStandardHeaders()
resp, err := c.client.exec("GET", uri, c.client.getStandardHeaders(), nil)
if err != nil { if options != nil {
return r, err if options.NumOfMessages != 0 {
query.Set("numofmessages", strconv.Itoa(options.NumOfMessages))
} }
defer resp.body.Close() query = addTimeout(query, options.Timeout)
err = xmlUnmarshal(resp.body, &r) headers = mergeHeaders(headers, headersFromStruct(*options))
return r, err }
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), query)
resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth)
if err != nil {
return []Message{}, err
}
defer readAndCloseBody(resp.body)
var out messages
err = xmlUnmarshal(resp.body, &out)
if err != nil {
return []Message{}, err
}
for i := range out.Messages {
out.Messages[i].Queue = q
}
return out.Messages, err
} }
// DeleteMessage operation deletes the specified message. // ClearMessages operation deletes all messages from the specified queue.
// //
// See https://msdn.microsoft.com/en-us/library/azure/dd179347.aspx // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/Clear-Messages
func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) error { func (q *Queue) ClearMessages(options *QueueServiceOptions) error {
uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), url.Values{ params := url.Values{}
"popreceipt": {popReceipt}}) headers := q.qsc.client.getStandardHeaders()
resp, err := c.client.exec("DELETE", uri, c.client.getStandardHeaders(), nil)
if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPathMessages(), params)
resp, err := q.qsc.client.exec(http.MethodDelete, uri, headers, nil, q.qsc.auth)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() readAndCloseBody(resp.body)
return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
} }
// UpdateMessage operation deletes the specified message. // SetPermissions sets up queue permissions
// // See https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/set-queue-acl
// See https://msdn.microsoft.com/en-us/library/azure/hh452234.aspx func (q *Queue) SetPermissions(permissions QueuePermissions, options *SetQueuePermissionOptions) error {
func (c QueueServiceClient) UpdateMessage(queue string, messageID string, message string, params UpdateMessageParameters) error { body, length, err := generateQueueACLpayload(permissions.AccessPolicies)
uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), params.getParameters())
req := putMessageRequest{MessageText: message}
body, nn, err := xmlMarshal(req)
if err != nil { if err != nil {
return err return err
} }
headers := c.client.getStandardHeaders()
headers["Content-Length"] = fmt.Sprintf("%d", nn) params := url.Values{
resp, err := c.client.exec("PUT", uri, headers, body) "comp": {"acl"},
}
headers := q.qsc.client.getStandardHeaders()
headers["Content-Length"] = strconv.Itoa(length)
if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params)
resp, err := q.qsc.client.exec(http.MethodPut, uri, headers, body, q.qsc.auth)
if err != nil { if err != nil {
return err return err
} }
defer readAndCloseBody(resp.body)
if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil {
return errors.New("Unable to set permissions")
}
return nil
}
func generateQueueACLpayload(policies []QueueAccessPolicy) (io.Reader, int, error) {
sil := SignedIdentifiers{
SignedIdentifiers: []SignedIdentifier{},
}
for _, qapd := range policies {
permission := qapd.generateQueuePermissions()
signedIdentifier := convertAccessPolicyToXMLStructs(qapd.ID, qapd.StartTime, qapd.ExpiryTime, permission)
sil.SignedIdentifiers = append(sil.SignedIdentifiers, signedIdentifier)
}
return xmlMarshal(sil)
}
func (qapd *QueueAccessPolicy) generateQueuePermissions() (permissions string) {
// generate the permissions string (raup).
// still want the end user API to have bool flags.
permissions = ""
if qapd.CanRead {
permissions += "r"
}
if qapd.CanAdd {
permissions += "a"
}
if qapd.CanUpdate {
permissions += "u"
}
if qapd.CanProcess {
permissions += "p"
}
return permissions
}
// GetQueuePermissionOptions includes options for a get queue permissions operation
type GetQueuePermissionOptions struct {
Timeout uint
RequestID string `header:"x-ms-client-request-id"`
}
// GetPermissions gets the queue permissions as per https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/get-queue-acl
// If timeout is 0 then it will not be passed to Azure
func (q *Queue) GetPermissions(options *GetQueuePermissionOptions) (*QueuePermissions, error) {
params := url.Values{
"comp": {"acl"},
}
headers := q.qsc.client.getStandardHeaders()
if options != nil {
params = addTimeout(params, options.Timeout)
headers = mergeHeaders(headers, headersFromStruct(*options))
}
uri := q.qsc.client.getEndpoint(queueServiceName, q.buildPath(), params)
resp, err := q.qsc.client.exec(http.MethodGet, uri, headers, nil, q.qsc.auth)
if err != nil {
return nil, err
}
defer resp.body.Close() defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
var ap AccessPolicy
err = xmlUnmarshal(resp.body, &ap.SignedIdentifiersList)
if err != nil {
return nil, err
}
return buildQueueAccessPolicy(ap, &resp.headers), nil
}
func buildQueueAccessPolicy(ap AccessPolicy, headers *http.Header) *QueuePermissions {
permissions := QueuePermissions{
AccessPolicies: []QueueAccessPolicy{},
}
for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers {
qapd := QueueAccessPolicy{
ID: policy.ID,
StartTime: policy.AccessPolicy.StartTime,
ExpiryTime: policy.AccessPolicy.ExpiryTime,
}
qapd.CanRead = updatePermissions(policy.AccessPolicy.Permission, "r")
qapd.CanAdd = updatePermissions(policy.AccessPolicy.Permission, "a")
qapd.CanUpdate = updatePermissions(policy.AccessPolicy.Permission, "u")
qapd.CanProcess = updatePermissions(policy.AccessPolicy.Permission, "p")
permissions.AccessPolicies = append(permissions.AccessPolicies, qapd)
}
return &permissions
} }

View File

@ -4,122 +4,175 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"io/ioutil"
"net/http" "net/http"
"net/url" "net/url"
"strconv"
"strings"
"time"
) )
// TableServiceClient contains operations for Microsoft Azure Table Storage
// Service.
type TableServiceClient struct {
client Client
}
// AzureTable is the typedef of the Azure Table name
type AzureTable string
const ( const (
tablesURIPath = "/Tables" tablesURIPath = "/Tables"
nextTableQueryParameter = "NextTableName"
headerNextPartitionKey = "x-ms-continuation-NextPartitionKey"
headerNextRowKey = "x-ms-continuation-NextRowKey"
nextPartitionKeyQueryParameter = "NextPartitionKey"
nextRowKeyQueryParameter = "NextRowKey"
) )
type createTableRequest struct { // TableAccessPolicy are used for SETTING table policies
TableName string `json:"TableName"` type TableAccessPolicy struct {
ID string
StartTime time.Time
ExpiryTime time.Time
CanRead bool
CanAppend bool
CanUpdate bool
CanDelete bool
} }
func pathForTable(table AzureTable) string { return fmt.Sprintf("%s", table) } // Table represents an Azure table.
type Table struct {
tsc *TableServiceClient
Name string `json:"TableName"`
OdataEditLink string `json:"odata.editLink"`
OdataID string `json:"odata.id"`
OdataMetadata string `json:"odata.metadata"`
OdataType string `json:"odata.type"`
}
func (c *TableServiceClient) getStandardHeaders() map[string]string { // EntityQueryResult contains the response from
return map[string]string{ // ExecuteQuery and ExecuteQueryNextResults functions.
"x-ms-version": "2015-02-21", type EntityQueryResult struct {
"x-ms-date": currentTimeRfc1123Formatted(), OdataMetadata string `json:"odata.metadata"`
"Accept": "application/json;odata=nometadata", Entities []*Entity `json:"value"`
"Accept-Charset": "UTF-8", QueryNextLink
"Content-Type": "application/json", table *Table
}
type continuationToken struct {
NextPartitionKey string
NextRowKey string
}
func (t *Table) buildPath() string {
return fmt.Sprintf("/%s", t.Name)
}
func (t *Table) buildSpecificPath() string {
return fmt.Sprintf("%s('%s')", tablesURIPath, t.Name)
}
// Get gets the referenced table.
// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/querying-tables-and-entities
func (t *Table) Get(timeout uint, ml MetadataLevel) error {
if ml == EmptyPayload {
return errEmptyPayload
} }
}
// QueryTables returns the tables created in the query := url.Values{
// *TableServiceClient storage account. "timeout": {strconv.FormatUint(uint64(timeout), 10)},
func (c *TableServiceClient) QueryTables() ([]AzureTable, error) { }
uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) headers := t.tsc.client.getStandardHeaders()
headers[headerAccept] = string(ml)
headers := c.getStandardHeaders() uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), query)
headers["Content-Length"] = "0" resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth)
resp, err := c.client.execTable("GET", uri, headers, nil)
if err != nil { if err != nil {
return nil, err return err
} }
defer resp.body.Close() defer readAndCloseBody(resp.body)
if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil { if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil {
return nil, err return err
} }
buf := new(bytes.Buffer) respBody, err := ioutil.ReadAll(resp.body)
buf.ReadFrom(resp.body) if err != nil {
return err
var respArray queryTablesResponse
if err := json.Unmarshal(buf.Bytes(), &respArray); err != nil {
return nil, err
} }
err = json.Unmarshal(respBody, t)
s := make([]AzureTable, len(respArray.TableName)) if err != nil {
for i, elem := range respArray.TableName { return err
s[i] = AzureTable(elem.TableName)
} }
return nil
return s, nil
} }
// CreateTable creates the table given the specific // Create creates the referenced table.
// name. This function fails if the name is not compliant // This function fails if the name is not compliant
// with the specification or the tables already exists. // with the specification or the tables already exists.
func (c *TableServiceClient) CreateTable(table AzureTable) error { // ml determines the level of detail of metadata in the operation response,
uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) // or no data at all.
// See https://docs.microsoft.com/rest/api/storageservices/fileservices/create-table
func (t *Table) Create(timeout uint, ml MetadataLevel, options *TableOptions) error {
uri := t.tsc.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{
"timeout": {strconv.FormatUint(uint64(timeout), 10)},
})
headers := c.getStandardHeaders() type createTableRequest struct {
TableName string `json:"TableName"`
req := createTableRequest{TableName: string(table)} }
req := createTableRequest{TableName: t.Name}
buf := new(bytes.Buffer) buf := new(bytes.Buffer)
if err := json.NewEncoder(buf).Encode(req); err != nil { if err := json.NewEncoder(buf).Encode(req); err != nil {
return err return err
} }
headers["Content-Length"] = fmt.Sprintf("%d", buf.Len()) headers := t.tsc.client.getStandardHeaders()
headers = addReturnContentHeaders(headers, ml)
resp, err := c.client.execTable("POST", uri, headers, buf) headers = addBodyRelatedHeaders(headers, buf.Len())
headers = options.addToHeaders(headers)
resp, err := t.tsc.client.exec(http.MethodPost, uri, headers, buf, t.tsc.auth)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() defer readAndCloseBody(resp.body)
if ml == EmptyPayload {
if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil {
return err
}
} else {
if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil { if err := checkRespCode(resp.statusCode, []int{http.StatusCreated}); err != nil {
return err return err
} }
}
if ml != EmptyPayload {
data, err := ioutil.ReadAll(resp.body)
if err != nil {
return err
}
err = json.Unmarshal(data, t)
if err != nil {
return err
}
}
return nil return nil
} }
// DeleteTable deletes the table given the specific // Delete deletes the referenced table.
// name. This function fails if the table is not present. // This function fails if the table is not present.
// Be advised: DeleteTable deletes all the entries // Be advised: Delete deletes all the entries that may be present.
// that may be present. // See https://docs.microsoft.com/rest/api/storageservices/fileservices/delete-table
func (c *TableServiceClient) DeleteTable(table AzureTable) error { func (t *Table) Delete(timeout uint, options *TableOptions) error {
uri := c.client.getEndpoint(tableServiceName, tablesURIPath, url.Values{}) uri := t.tsc.client.getEndpoint(tableServiceName, t.buildSpecificPath(), url.Values{
uri += fmt.Sprintf("('%s')", string(table)) "timeout": {strconv.Itoa(int(timeout))},
})
headers := c.getStandardHeaders() headers := t.tsc.client.getStandardHeaders()
headers = addReturnContentHeaders(headers, EmptyPayload)
headers["Content-Length"] = "0" headers = options.addToHeaders(headers)
resp, err := c.client.execTable("DELETE", uri, headers, nil)
resp, err := t.tsc.client.exec(http.MethodDelete, uri, headers, nil, t.tsc.auth)
if err != nil { if err != nil {
return err return err
} }
defer resp.body.Close() defer readAndCloseBody(resp.body)
if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil { if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil {
return err return err
@ -127,3 +180,233 @@ func (c *TableServiceClient) DeleteTable(table AzureTable) error {
} }
return nil return nil
} }
// QueryOptions includes options for a query entities operation.
// Top, filter and select are OData query options.
type QueryOptions struct {
Top uint
Filter string
Select []string
RequestID string
}
func (options *QueryOptions) getParameters() (url.Values, map[string]string) {
query := url.Values{}
headers := map[string]string{}
if options != nil {
if options.Top > 0 {
query.Add(OdataTop, strconv.FormatUint(uint64(options.Top), 10))
}
if options.Filter != "" {
query.Add(OdataFilter, options.Filter)
}
if len(options.Select) > 0 {
query.Add(OdataSelect, strings.Join(options.Select, ","))
}
headers = addToHeaders(headers, "x-ms-client-request-id", options.RequestID)
}
return query, headers
}
// QueryEntities returns the entities in the table.
// You can use query options defined by the OData Protocol specification.
//
// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities
func (t *Table) QueryEntities(timeout uint, ml MetadataLevel, options *QueryOptions) (*EntityQueryResult, error) {
if ml == EmptyPayload {
return nil, errEmptyPayload
}
query, headers := options.getParameters()
query = addTimeout(query, timeout)
uri := t.tsc.client.getEndpoint(tableServiceName, t.buildPath(), query)
return t.queryEntities(uri, headers, ml)
}
// NextResults returns the next page of results
// from a QueryEntities or NextResults operation.
//
// See: https://docs.microsoft.com/en-us/rest/api/storageservices/fileservices/query-entities
// See https://docs.microsoft.com/rest/api/storageservices/fileservices/query-timeout-and-pagination
func (eqr *EntityQueryResult) NextResults(options *TableOptions) (*EntityQueryResult, error) {
if eqr == nil {
return nil, errNilPreviousResult
}
if eqr.NextLink == nil {
return nil, errNilNextLink
}
headers := options.addToHeaders(map[string]string{})
return eqr.table.queryEntities(*eqr.NextLink, headers, eqr.ml)
}
// SetPermissions sets up table ACL permissions
// See https://docs.microsoft.com/rest/api/storageservices/fileservices/Set-Table-ACL
func (t *Table) SetPermissions(tap []TableAccessPolicy, timeout uint, options *TableOptions) error {
params := url.Values{"comp": {"acl"},
"timeout": {strconv.Itoa(int(timeout))},
}
uri := t.tsc.client.getEndpoint(tableServiceName, t.Name, params)
headers := t.tsc.client.getStandardHeaders()
headers = options.addToHeaders(headers)
body, length, err := generateTableACLPayload(tap)
if err != nil {
return err
}
headers["Content-Length"] = strconv.Itoa(length)
resp, err := t.tsc.client.exec(http.MethodPut, uri, headers, body, t.tsc.auth)
if err != nil {
return err
}
defer readAndCloseBody(resp.body)
if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil {
return err
}
return nil
}
func generateTableACLPayload(policies []TableAccessPolicy) (io.Reader, int, error) {
sil := SignedIdentifiers{
SignedIdentifiers: []SignedIdentifier{},
}
for _, tap := range policies {
permission := generateTablePermissions(&tap)
signedIdentifier := convertAccessPolicyToXMLStructs(tap.ID, tap.StartTime, tap.ExpiryTime, permission)
sil.SignedIdentifiers = append(sil.SignedIdentifiers, signedIdentifier)
}
return xmlMarshal(sil)
}
// GetPermissions gets the table ACL permissions
// See https://docs.microsoft.com/rest/api/storageservices/fileservices/get-table-acl
func (t *Table) GetPermissions(timeout int, options *TableOptions) ([]TableAccessPolicy, error) {
params := url.Values{"comp": {"acl"},
"timeout": {strconv.Itoa(int(timeout))},
}
uri := t.tsc.client.getEndpoint(tableServiceName, t.Name, params)
headers := t.tsc.client.getStandardHeaders()
headers = options.addToHeaders(headers)
resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth)
if err != nil {
return nil, err
}
defer resp.body.Close()
if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil {
return nil, err
}
var ap AccessPolicy
err = xmlUnmarshal(resp.body, &ap.SignedIdentifiersList)
if err != nil {
return nil, err
}
return updateTableAccessPolicy(ap), nil
}
func (t *Table) queryEntities(uri string, headers map[string]string, ml MetadataLevel) (*EntityQueryResult, error) {
headers = mergeHeaders(headers, t.tsc.client.getStandardHeaders())
if ml != EmptyPayload {
headers[headerAccept] = string(ml)
}
resp, err := t.tsc.client.exec(http.MethodGet, uri, headers, nil, t.tsc.auth)
if err != nil {
return nil, err
}
defer resp.body.Close()
if err = checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil {
return nil, err
}
data, err := ioutil.ReadAll(resp.body)
if err != nil {
return nil, err
}
var entities EntityQueryResult
err = json.Unmarshal(data, &entities)
if err != nil {
return nil, err
}
for i := range entities.Entities {
entities.Entities[i].Table = t
}
entities.table = t
contToken := extractContinuationTokenFromHeaders(resp.headers)
if contToken == nil {
entities.NextLink = nil
} else {
originalURI, err := url.Parse(uri)
if err != nil {
return nil, err
}
v := originalURI.Query()
v.Set(nextPartitionKeyQueryParameter, contToken.NextPartitionKey)
v.Set(nextRowKeyQueryParameter, contToken.NextRowKey)
newURI := t.tsc.client.getEndpoint(tableServiceName, t.buildPath(), v)
entities.NextLink = &newURI
entities.ml = ml
}
return &entities, nil
}
func extractContinuationTokenFromHeaders(h http.Header) *continuationToken {
ct := continuationToken{
NextPartitionKey: h.Get(headerNextPartitionKey),
NextRowKey: h.Get(headerNextRowKey),
}
if ct.NextPartitionKey != "" && ct.NextRowKey != "" {
return &ct
}
return nil
}
func updateTableAccessPolicy(ap AccessPolicy) []TableAccessPolicy {
taps := []TableAccessPolicy{}
for _, policy := range ap.SignedIdentifiersList.SignedIdentifiers {
tap := TableAccessPolicy{
ID: policy.ID,
StartTime: policy.AccessPolicy.StartTime,
ExpiryTime: policy.AccessPolicy.ExpiryTime,
}
tap.CanRead = updatePermissions(policy.AccessPolicy.Permission, "r")
tap.CanAppend = updatePermissions(policy.AccessPolicy.Permission, "a")
tap.CanUpdate = updatePermissions(policy.AccessPolicy.Permission, "u")
tap.CanDelete = updatePermissions(policy.AccessPolicy.Permission, "d")
taps = append(taps, tap)
}
return taps
}
func generateTablePermissions(tap *TableAccessPolicy) (permissions string) {
// generate the permissions string (raud).
// still want the end user API to have bool flags.
permissions = ""
if tap.CanRead {
permissions += "r"
}
if tap.CanAppend {
permissions += "a"
}
if tap.CanUpdate {
permissions += "u"
}
if tap.CanDelete {
permissions += "d"
}
return permissions
}

View File

@ -1,357 +0,0 @@
package storage
import (
"bytes"
"encoding/json"
"fmt"
"io"
"net/http"
"net/url"
"reflect"
)
// Annotating as secure for gas scanning
/* #nosec */
const (
partitionKeyNode = "PartitionKey"
rowKeyNode = "RowKey"
tag = "table"
tagIgnore = "-"
continuationTokenPartitionKeyHeader = "X-Ms-Continuation-Nextpartitionkey"
continuationTokenRowHeader = "X-Ms-Continuation-Nextrowkey"
maxTopParameter = 1000
)
type queryTablesResponse struct {
TableName []struct {
TableName string `json:"TableName"`
} `json:"value"`
}
const (
tableOperationTypeInsert = iota
tableOperationTypeUpdate = iota
tableOperationTypeMerge = iota
tableOperationTypeInsertOrReplace = iota
tableOperationTypeInsertOrMerge = iota
)
type tableOperation int
// TableEntity interface specifies
// the functions needed to support
// marshaling and unmarshaling into
// Azure Tables. The struct must only contain
// simple types because Azure Tables do not
// support hierarchy.
type TableEntity interface {
PartitionKey() string
RowKey() string
SetPartitionKey(string) error
SetRowKey(string) error
}
// ContinuationToken is an opaque (ie not useful to inspect)
// struct that Get... methods can return if there are more
// entries to be returned than the ones already
// returned. Just pass it to the same function to continue
// receiving the remaining entries.
type ContinuationToken struct {
NextPartitionKey string
NextRowKey string
}
type getTableEntriesResponse struct {
Elements []map[string]interface{} `json:"value"`
}
// QueryTableEntities queries the specified table and returns the unmarshaled
// entities of type retType.
// top parameter limits the returned entries up to top. Maximum top
// allowed by Azure API is 1000. In case there are more than top entries to be
// returned the function will return a non nil *ContinuationToken. You can call the
// same function again passing the received ContinuationToken as previousContToken
// parameter in order to get the following entries. The query parameter
// is the odata query. To retrieve all the entries pass the empty string.
// The function returns a pointer to a TableEntity slice, the *ContinuationToken
// if there are more entries to be returned and an error in case something went
// wrong.
//
// Example:
// entities, cToken, err = tSvc.QueryTableEntities("table", cToken, reflect.TypeOf(entity), 20, "")
func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousContToken *ContinuationToken, retType reflect.Type, top int, query string) ([]TableEntity, *ContinuationToken, error) {
if top > maxTopParameter {
return nil, nil, fmt.Errorf("top accepts at maximum %d elements. Requested %d instead", maxTopParameter, top)
}
uri := c.client.getEndpoint(tableServiceName, pathForTable(tableName), url.Values{})
uri += fmt.Sprintf("?$top=%d", top)
if query != "" {
uri += fmt.Sprintf("&$filter=%s", url.QueryEscape(query))
}
if previousContToken != nil {
uri += fmt.Sprintf("&NextPartitionKey=%s&NextRowKey=%s", previousContToken.NextPartitionKey, previousContToken.NextRowKey)
}
headers := c.getStandardHeaders()
headers["Content-Length"] = "0"
resp, err := c.client.execTable("GET", uri, headers, nil)
if err != nil {
return nil, nil, err
}
contToken := extractContinuationTokenFromHeaders(resp.headers)
if err != nil {
return nil, contToken, err
}
defer resp.body.Close()
if err := checkRespCode(resp.statusCode, []int{http.StatusOK}); err != nil {
return nil, contToken, err
}
retEntries, err := deserializeEntity(retType, resp.body)
if err != nil {
return nil, contToken, err
}
return retEntries, contToken, nil
}
// InsertEntity inserts an entity in the specified table.
// The function fails if there is an entity with the same
// PartitionKey and RowKey in the table.
func (c *TableServiceClient) InsertEntity(table AzureTable, entity TableEntity) error {
var err error
if sc, err := c.execTable(table, entity, false, "POST"); err != nil {
return checkRespCode(sc, []int{http.StatusCreated})
}
return err
}
func (c *TableServiceClient) execTable(table AzureTable, entity TableEntity, specifyKeysInURL bool, method string) (int, error) {
uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{})
if specifyKeysInURL {
uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey()))
}
headers := c.getStandardHeaders()
var buf bytes.Buffer
if err := injectPartitionAndRowKeys(entity, &buf); err != nil {
return 0, err
}
headers["Content-Length"] = fmt.Sprintf("%d", buf.Len())
var err error
var resp *odataResponse
resp, err = c.client.execTable(method, uri, headers, &buf)
if err != nil {
return 0, err
}
defer resp.body.Close()
return resp.statusCode, nil
}
// UpdateEntity updates the contents of an entity with the
// one passed as parameter. The function fails if there is no entity
// with the same PartitionKey and RowKey in the table.
func (c *TableServiceClient) UpdateEntity(table AzureTable, entity TableEntity) error {
var err error
if sc, err := c.execTable(table, entity, true, "PUT"); err != nil {
return checkRespCode(sc, []int{http.StatusNoContent})
}
return err
}
// MergeEntity merges the contents of an entity with the
// one passed as parameter.
// The function fails if there is no entity
// with the same PartitionKey and RowKey in the table.
func (c *TableServiceClient) MergeEntity(table AzureTable, entity TableEntity) error {
var err error
if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil {
return checkRespCode(sc, []int{http.StatusNoContent})
}
return err
}
// DeleteEntityWithoutCheck deletes the entity matching by
// PartitionKey and RowKey. There is no check on IfMatch
// parameter so the entity is always deleted.
// The function fails if there is no entity
// with the same PartitionKey and RowKey in the table.
func (c *TableServiceClient) DeleteEntityWithoutCheck(table AzureTable, entity TableEntity) error {
return c.DeleteEntity(table, entity, "*")
}
// DeleteEntity deletes the entity matching by
// PartitionKey, RowKey and ifMatch field.
// The function fails if there is no entity
// with the same PartitionKey and RowKey in the table or
// the ifMatch is different.
func (c *TableServiceClient) DeleteEntity(table AzureTable, entity TableEntity, ifMatch string) error {
uri := c.client.getEndpoint(tableServiceName, pathForTable(table), url.Values{})
uri += fmt.Sprintf("(PartitionKey='%s',RowKey='%s')", url.QueryEscape(entity.PartitionKey()), url.QueryEscape(entity.RowKey()))
headers := c.getStandardHeaders()
headers["Content-Length"] = "0"
headers["If-Match"] = ifMatch
resp, err := c.client.execTable("DELETE", uri, headers, nil)
if err != nil {
return err
}
defer resp.body.Close()
if err := checkRespCode(resp.statusCode, []int{http.StatusNoContent}); err != nil {
return err
}
return nil
}
// InsertOrReplaceEntity inserts an entity in the specified table
// or replaced the existing one.
func (c *TableServiceClient) InsertOrReplaceEntity(table AzureTable, entity TableEntity) error {
var err error
if sc, err := c.execTable(table, entity, true, "PUT"); err != nil {
return checkRespCode(sc, []int{http.StatusNoContent})
}
return err
}
// InsertOrMergeEntity inserts an entity in the specified table
// or merges the existing one.
func (c *TableServiceClient) InsertOrMergeEntity(table AzureTable, entity TableEntity) error {
var err error
if sc, err := c.execTable(table, entity, true, "MERGE"); err != nil {
return checkRespCode(sc, []int{http.StatusNoContent})
}
return err
}
func injectPartitionAndRowKeys(entity TableEntity, buf *bytes.Buffer) error {
if err := json.NewEncoder(buf).Encode(entity); err != nil {
return err
}
dec := make(map[string]interface{})
if err := json.NewDecoder(buf).Decode(&dec); err != nil {
return err
}
// Inject PartitionKey and RowKey
dec[partitionKeyNode] = entity.PartitionKey()
dec[rowKeyNode] = entity.RowKey()
// Remove tagged fields
// The tag is defined in the const section
// This is useful to avoid storing the PartitionKey and RowKey twice.
numFields := reflect.ValueOf(entity).Elem().NumField()
for i := 0; i < numFields; i++ {
f := reflect.ValueOf(entity).Elem().Type().Field(i)
if f.Tag.Get(tag) == tagIgnore {
// we must look for its JSON name in the dictionary
// as the user can rename it using a tag
jsonName := f.Name
if f.Tag.Get("json") != "" {
jsonName = f.Tag.Get("json")
}
delete(dec, jsonName)
}
}
buf.Reset()
if err := json.NewEncoder(buf).Encode(&dec); err != nil {
return err
}
return nil
}
func deserializeEntity(retType reflect.Type, reader io.Reader) ([]TableEntity, error) {
buf := new(bytes.Buffer)
var ret getTableEntriesResponse
if err := json.NewDecoder(reader).Decode(&ret); err != nil {
return nil, err
}
tEntries := make([]TableEntity, len(ret.Elements))
for i, entry := range ret.Elements {
buf.Reset()
if err := json.NewEncoder(buf).Encode(entry); err != nil {
return nil, err
}
dec := make(map[string]interface{})
if err := json.NewDecoder(buf).Decode(&dec); err != nil {
return nil, err
}
var pKey, rKey string
// strip pk and rk
for key, val := range dec {
switch key {
case partitionKeyNode:
pKey = val.(string)
case rowKeyNode:
rKey = val.(string)
}
}
delete(dec, partitionKeyNode)
delete(dec, rowKeyNode)
buf.Reset()
if err := json.NewEncoder(buf).Encode(dec); err != nil {
return nil, err
}
// Create a empty retType instance
tEntries[i] = reflect.New(retType.Elem()).Interface().(TableEntity)
// Popolate it with the values
if err := json.NewDecoder(buf).Decode(&tEntries[i]); err != nil {
return nil, err
}
// Reset PartitionKey and RowKey
tEntries[i].SetPartitionKey(pKey)
tEntries[i].SetRowKey(rKey)
}
return tEntries, nil
}
func extractContinuationTokenFromHeaders(h http.Header) *ContinuationToken {
ct := ContinuationToken{h.Get(continuationTokenPartitionKeyHeader), h.Get(continuationTokenRowHeader)}
if ct.NextPartitionKey != "" && ct.NextRowKey != "" {
return &ct
}
return nil
}

View File

@ -12,9 +12,15 @@ import (
"net/http" "net/http"
"net/url" "net/url"
"reflect" "reflect"
"strconv"
"strings"
"time" "time"
) )
var (
fixedTime = time.Date(2050, time.December, 20, 21, 55, 0, 0, time.FixedZone("GMT", -6))
)
func (c Client) computeHmac256(message string) string { func (c Client) computeHmac256(message string) string {
h := hmac.New(sha256.New, c.accountKey) h := hmac.New(sha256.New, c.accountKey)
h.Write([]byte(message)) h.Write([]byte(message))
@ -76,10 +82,118 @@ func headersFromStruct(v interface{}) map[string]string {
value := reflect.ValueOf(v) value := reflect.ValueOf(v)
for i := 0; i < value.NumField(); i++ { for i := 0; i < value.NumField(); i++ {
key := value.Type().Field(i).Tag.Get("header") key := value.Type().Field(i).Tag.Get("header")
val := value.Field(i).String() if key != "" {
if key != "" && val != "" { reflectedValue := reflect.Indirect(value.Field(i))
var val string
if reflectedValue.IsValid() {
switch reflectedValue.Type() {
case reflect.TypeOf(fixedTime):
val = timeRfc1123Formatted(reflectedValue.Interface().(time.Time))
case reflect.TypeOf(uint64(0)), reflect.TypeOf(uint(0)):
val = strconv.FormatUint(reflectedValue.Uint(), 10)
case reflect.TypeOf(int(0)):
val = strconv.FormatInt(reflectedValue.Int(), 10)
default:
val = reflectedValue.String()
}
}
if val != "" {
headers[key] = val headers[key] = val
} }
} }
}
return headers return headers
} }
// merges extraHeaders into headers and returns headers
func mergeHeaders(headers, extraHeaders map[string]string) map[string]string {
for k, v := range extraHeaders {
headers[k] = v
}
return headers
}
func addToHeaders(h map[string]string, key, value string) map[string]string {
if value != "" {
h[key] = value
}
return h
}
func addTimeToHeaders(h map[string]string, key string, value *time.Time) map[string]string {
if value != nil {
h = addToHeaders(h, key, timeRfc1123Formatted(*value))
}
return h
}
func addTimeout(params url.Values, timeout uint) url.Values {
if timeout > 0 {
params.Add("timeout", fmt.Sprintf("%v", timeout))
}
return params
}
func addSnapshot(params url.Values, snapshot *time.Time) url.Values {
if snapshot != nil {
params.Add("snapshot", timeRfc1123Formatted(*snapshot))
}
return params
}
func getTimeFromHeaders(h http.Header, key string) (*time.Time, error) {
var out time.Time
var err error
outStr := h.Get(key)
if outStr != "" {
out, err = time.Parse(time.RFC1123, outStr)
if err != nil {
return nil, err
}
}
return &out, nil
}
// TimeRFC1123 is an alias for time.Time needed for custom Unmarshalling
type TimeRFC1123 time.Time
// UnmarshalXML is a custom unmarshaller that overrides the default time unmarshal which uses a different time layout.
func (t *TimeRFC1123) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error {
var value string
d.DecodeElement(&value, &start)
parse, err := time.Parse(time.RFC1123, value)
if err != nil {
return err
}
*t = TimeRFC1123(parse)
return nil
}
// returns a map of custom metadata values from the specified HTTP header
func getMetadataFromHeaders(header http.Header) map[string]string {
metadata := make(map[string]string)
for k, v := range header {
// Can't trust CanonicalHeaderKey() to munge case
// reliably. "_" is allowed in identifiers:
// https://msdn.microsoft.com/en-us/library/azure/dd179414.aspx
// https://msdn.microsoft.com/library/aa664670(VS.71).aspx
// http://tools.ietf.org/html/rfc7230#section-3.2
// ...but "_" is considered invalid by
// CanonicalMIMEHeaderKey in
// https://golang.org/src/net/textproto/reader.go?s=14615:14659#L542
// so k can be "X-Ms-Meta-Lol" or "x-ms-meta-lol_rofl".
k = strings.ToLower(k)
if len(v) == 0 || !strings.HasPrefix(k, strings.ToLower(userDefinedMetadataHeaderPrefix)) {
continue
}
// metadata["lol"] = content of the last X-Ms-Meta-Lol header
k = k[len(userDefinedMetadataHeaderPrefix):]
metadata[k] = v[len(v)-1]
}
if len(metadata) == 0 {
return nil
}
return metadata
}

View File

@ -1,46 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"constants.go",
"context.go",
"csi_entry_state.go",
"csi_param_state.go",
"escape_intermediate_state.go",
"escape_state.go",
"event_handler.go",
"ground_state.go",
"osc_string_state.go",
"parser.go",
"parser_action_helpers.go",
"parser_actions.go",
"parser_test_helpers.go",
"parser_test_utilities.go",
"states.go",
"test_event_handler.go",
"utilities.go",
],
tags = ["automanaged"],
deps = ["//vendor/github.com/Sirupsen/logrus:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters
The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go). The parser (parser.go) is a partial implementation of this state machine (http://vt100.net/emu/vt500_parser.png). There are also two event handler implementations, one for tests (test_event_handler.go) to validate that the expected events are being produced and called, the other is a Windows implementation (winterm/win_event_handler.go).
See parser_test.go for examples exercising the state machine and generating appropriate function calls. See parser_test.go for examples exercising the state machine and generating appropriate function calls.
-----
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

View File

@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte {
return bytes return bytes
} }
var ToGroundBytes = getToGroundBytes() var toGroundBytes = getToGroundBytes()
var Executors = getExecuteBytes() var executors = getExecuteBytes()
// SPACE 20+A0 hex Always and everywhere a blank space // SPACE 20+A0 hex Always and everywhere a blank space
// Intermediate 20-2F hex !"#$%&'()*+,-./ // Intermediate 20-2F hex !"#$%&'()*+,-./
var Intermeds = getByteRange(0x20, 0x2F) var intermeds = getByteRange(0x20, 0x2F)
// Parameters 30-3F hex 0123456789:;<=>? // Parameters 30-3F hex 0123456789:;<=>?
// CSI Parameters 30-39, 3B hex 0123456789; // CSI Parameters 30-39, 3B hex 0123456789;
var CsiParams = getByteRange(0x30, 0x3F) var csiParams = getByteRange(0x30, 0x3F)
var CsiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...) var csiCollectables = append(getByteRange(0x30, 0x39), getByteRange(0x3B, 0x3F)...)
// Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ // Uppercase 40-5F hex @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
var UpperCase = getByteRange(0x40, 0x5F) var upperCase = getByteRange(0x40, 0x5F)
// Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~ // Lowercase 60-7E hex `abcdefghijlkmnopqrstuvwxyz{|}~
var LowerCase = getByteRange(0x60, 0x7E) var lowerCase = getByteRange(0x60, 0x7E)
// Alphabetics 40-7E hex (all of upper and lower case) // Alphabetics 40-7E hex (all of upper and lower case)
var Alphabetics = append(UpperCase, LowerCase...) var alphabetics = append(upperCase, lowerCase...)
var Printables = getByteRange(0x20, 0x7F) var printables = getByteRange(0x20, 0x7F)
var EscapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E) var escapeIntermediateToGroundBytes = getByteRange(0x30, 0x7E)
var EscapeToGroundBytes = getEscapeToGroundBytes() var escapeToGroundBytes = getEscapeToGroundBytes()
// See http://www.vt100.net/emu/vt500_parser.png for description of the complex // See http://www.vt100.net/emu/vt500_parser.png for description of the complex
// byte ranges below // byte ranges below

View File

@ -1,6 +1,6 @@
package ansiterm package ansiterm
type AnsiContext struct { type ansiContext struct {
currentChar byte currentChar byte
paramBuffer []byte paramBuffer []byte
interBuffer []byte interBuffer []byte

View File

@ -1,41 +1,41 @@
package ansiterm package ansiterm
type CsiEntryState struct { type csiEntryState struct {
BaseState baseState
} }
func (csiState CsiEntryState) Handle(b byte) (s State, e error) { func (csiState csiEntryState) Handle(b byte) (s state, e error) {
logger.Infof("CsiEntry::Handle %#x", b) logger.Infof("CsiEntry::Handle %#x", b)
nextState, err := csiState.BaseState.Handle(b) nextState, err := csiState.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case sliceContains(Alphabetics, b): case sliceContains(alphabetics, b):
return csiState.parser.Ground, nil return csiState.parser.ground, nil
case sliceContains(CsiCollectables, b): case sliceContains(csiCollectables, b):
return csiState.parser.CsiParam, nil return csiState.parser.csiParam, nil
case sliceContains(Executors, b): case sliceContains(executors, b):
return csiState, csiState.parser.execute() return csiState, csiState.parser.execute()
} }
return csiState, nil return csiState, nil
} }
func (csiState CsiEntryState) Transition(s State) error { func (csiState csiEntryState) Transition(s state) error {
logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name()) logger.Infof("CsiEntry::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s) csiState.baseState.Transition(s)
switch s { switch s {
case csiState.parser.Ground: case csiState.parser.ground:
return csiState.parser.csiDispatch() return csiState.parser.csiDispatch()
case csiState.parser.CsiParam: case csiState.parser.csiParam:
switch { switch {
case sliceContains(CsiParams, csiState.parser.context.currentChar): case sliceContains(csiParams, csiState.parser.context.currentChar):
csiState.parser.collectParam() csiState.parser.collectParam()
case sliceContains(Intermeds, csiState.parser.context.currentChar): case sliceContains(intermeds, csiState.parser.context.currentChar):
csiState.parser.collectInter() csiState.parser.collectInter()
} }
} }
@ -43,7 +43,7 @@ func (csiState CsiEntryState) Transition(s State) error {
return nil return nil
} }
func (csiState CsiEntryState) Enter() error { func (csiState csiEntryState) Enter() error {
csiState.parser.clear() csiState.parser.clear()
return nil return nil
} }

View File

@ -1,36 +1,36 @@
package ansiterm package ansiterm
type CsiParamState struct { type csiParamState struct {
BaseState baseState
} }
func (csiState CsiParamState) Handle(b byte) (s State, e error) { func (csiState csiParamState) Handle(b byte) (s state, e error) {
logger.Infof("CsiParam::Handle %#x", b) logger.Infof("CsiParam::Handle %#x", b)
nextState, err := csiState.BaseState.Handle(b) nextState, err := csiState.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case sliceContains(Alphabetics, b): case sliceContains(alphabetics, b):
return csiState.parser.Ground, nil return csiState.parser.ground, nil
case sliceContains(CsiCollectables, b): case sliceContains(csiCollectables, b):
csiState.parser.collectParam() csiState.parser.collectParam()
return csiState, nil return csiState, nil
case sliceContains(Executors, b): case sliceContains(executors, b):
return csiState, csiState.parser.execute() return csiState, csiState.parser.execute()
} }
return csiState, nil return csiState, nil
} }
func (csiState CsiParamState) Transition(s State) error { func (csiState csiParamState) Transition(s state) error {
logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name()) logger.Infof("CsiParam::Transition %s --> %s", csiState.Name(), s.Name())
csiState.BaseState.Transition(s) csiState.baseState.Transition(s)
switch s { switch s {
case csiState.parser.Ground: case csiState.parser.ground:
return csiState.parser.csiDispatch() return csiState.parser.csiDispatch()
} }

View File

@ -1,34 +1,34 @@
package ansiterm package ansiterm
type EscapeIntermediateState struct { type escapeIntermediateState struct {
BaseState baseState
} }
func (escState EscapeIntermediateState) Handle(b byte) (s State, e error) { func (escState escapeIntermediateState) Handle(b byte) (s state, e error) {
logger.Infof("EscapeIntermediateState::Handle %#x", b) logger.Infof("escapeIntermediateState::Handle %#x", b)
nextState, err := escState.BaseState.Handle(b) nextState, err := escState.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case sliceContains(Intermeds, b): case sliceContains(intermeds, b):
return escState, escState.parser.collectInter() return escState, escState.parser.collectInter()
case sliceContains(Executors, b): case sliceContains(executors, b):
return escState, escState.parser.execute() return escState, escState.parser.execute()
case sliceContains(EscapeIntermediateToGroundBytes, b): case sliceContains(escapeIntermediateToGroundBytes, b):
return escState.parser.Ground, nil return escState.parser.ground, nil
} }
return escState, nil return escState, nil
} }
func (escState EscapeIntermediateState) Transition(s State) error { func (escState escapeIntermediateState) Transition(s state) error {
logger.Infof("EscapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name()) logger.Infof("escapeIntermediateState::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s) escState.baseState.Transition(s)
switch s { switch s {
case escState.parser.Ground: case escState.parser.ground:
return escState.parser.escDispatch() return escState.parser.escDispatch()
} }

View File

@ -1,47 +1,47 @@
package ansiterm package ansiterm
type EscapeState struct { type escapeState struct {
BaseState baseState
} }
func (escState EscapeState) Handle(b byte) (s State, e error) { func (escState escapeState) Handle(b byte) (s state, e error) {
logger.Infof("EscapeState::Handle %#x", b) logger.Infof("escapeState::Handle %#x", b)
nextState, err := escState.BaseState.Handle(b) nextState, err := escState.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case b == ANSI_ESCAPE_SECONDARY: case b == ANSI_ESCAPE_SECONDARY:
return escState.parser.CsiEntry, nil return escState.parser.csiEntry, nil
case b == ANSI_OSC_STRING_ENTRY: case b == ANSI_OSC_STRING_ENTRY:
return escState.parser.OscString, nil return escState.parser.oscString, nil
case sliceContains(Executors, b): case sliceContains(executors, b):
return escState, escState.parser.execute() return escState, escState.parser.execute()
case sliceContains(EscapeToGroundBytes, b): case sliceContains(escapeToGroundBytes, b):
return escState.parser.Ground, nil return escState.parser.ground, nil
case sliceContains(Intermeds, b): case sliceContains(intermeds, b):
return escState.parser.EscapeIntermediate, nil return escState.parser.escapeIntermediate, nil
} }
return escState, nil return escState, nil
} }
func (escState EscapeState) Transition(s State) error { func (escState escapeState) Transition(s state) error {
logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name()) logger.Infof("Escape::Transition %s --> %s", escState.Name(), s.Name())
escState.BaseState.Transition(s) escState.baseState.Transition(s)
switch s { switch s {
case escState.parser.Ground: case escState.parser.ground:
return escState.parser.escDispatch() return escState.parser.escDispatch()
case escState.parser.EscapeIntermediate: case escState.parser.escapeIntermediate:
return escState.parser.collectInter() return escState.parser.collectInter()
} }
return nil return nil
} }
func (escState EscapeState) Enter() error { func (escState escapeState) Enter() error {
escState.parser.clear() escState.parser.clear()
return nil return nil
} }

View File

@ -1,22 +1,22 @@
package ansiterm package ansiterm
type GroundState struct { type groundState struct {
BaseState baseState
} }
func (gs GroundState) Handle(b byte) (s State, e error) { func (gs groundState) Handle(b byte) (s state, e error) {
gs.parser.context.currentChar = b gs.parser.context.currentChar = b
nextState, err := gs.BaseState.Handle(b) nextState, err := gs.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case sliceContains(Printables, b): case sliceContains(printables, b):
return gs, gs.parser.print() return gs, gs.parser.print()
case sliceContains(Executors, b): case sliceContains(executors, b):
return gs, gs.parser.execute() return gs, gs.parser.execute()
} }

View File

@ -1,19 +1,19 @@
package ansiterm package ansiterm
type OscStringState struct { type oscStringState struct {
BaseState baseState
} }
func (oscState OscStringState) Handle(b byte) (s State, e error) { func (oscState oscStringState) Handle(b byte) (s state, e error) {
logger.Infof("OscString::Handle %#x", b) logger.Infof("OscString::Handle %#x", b)
nextState, err := oscState.BaseState.Handle(b) nextState, err := oscState.baseState.Handle(b)
if nextState != nil || err != nil { if nextState != nil || err != nil {
return nextState, err return nextState, err
} }
switch { switch {
case isOscStringTerminator(b): case isOscStringTerminator(b):
return oscState.parser.Ground, nil return oscState.parser.ground, nil
} }
return oscState, nil return oscState, nil

View File

@ -2,7 +2,6 @@ package ansiterm
import ( import (
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -12,18 +11,18 @@ import (
var logger *logrus.Logger var logger *logrus.Logger
type AnsiParser struct { type AnsiParser struct {
currState State currState state
eventHandler AnsiEventHandler eventHandler AnsiEventHandler
context *AnsiContext context *ansiContext
CsiEntry State csiEntry state
CsiParam State csiParam state
DcsEntry State dcsEntry state
Escape State escape state
EscapeIntermediate State escapeIntermediate state
Error State error state
Ground State ground state
OscString State oscString state
stateMap []State stateMap []state
} }
func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser { func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser {
@ -41,27 +40,27 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser
parser := &AnsiParser{ parser := &AnsiParser{
eventHandler: evtHandler, eventHandler: evtHandler,
context: &AnsiContext{}, context: &ansiContext{},
} }
parser.CsiEntry = CsiEntryState{BaseState{name: "CsiEntry", parser: parser}} parser.csiEntry = csiEntryState{baseState{name: "CsiEntry", parser: parser}}
parser.CsiParam = CsiParamState{BaseState{name: "CsiParam", parser: parser}} parser.csiParam = csiParamState{baseState{name: "CsiParam", parser: parser}}
parser.DcsEntry = DcsEntryState{BaseState{name: "DcsEntry", parser: parser}} parser.dcsEntry = dcsEntryState{baseState{name: "DcsEntry", parser: parser}}
parser.Escape = EscapeState{BaseState{name: "Escape", parser: parser}} parser.escape = escapeState{baseState{name: "Escape", parser: parser}}
parser.EscapeIntermediate = EscapeIntermediateState{BaseState{name: "EscapeIntermediate", parser: parser}} parser.escapeIntermediate = escapeIntermediateState{baseState{name: "EscapeIntermediate", parser: parser}}
parser.Error = ErrorState{BaseState{name: "Error", parser: parser}} parser.error = errorState{baseState{name: "Error", parser: parser}}
parser.Ground = GroundState{BaseState{name: "Ground", parser: parser}} parser.ground = groundState{baseState{name: "Ground", parser: parser}}
parser.OscString = OscStringState{BaseState{name: "OscString", parser: parser}} parser.oscString = oscStringState{baseState{name: "OscString", parser: parser}}
parser.stateMap = []State{ parser.stateMap = []state{
parser.CsiEntry, parser.csiEntry,
parser.CsiParam, parser.csiParam,
parser.DcsEntry, parser.dcsEntry,
parser.Escape, parser.escape,
parser.EscapeIntermediate, parser.escapeIntermediate,
parser.Error, parser.error,
parser.Ground, parser.ground,
parser.OscString, parser.oscString,
} }
parser.currState = getState(initialState, parser.stateMap) parser.currState = getState(initialState, parser.stateMap)
@ -70,7 +69,7 @@ func CreateParser(initialState string, evtHandler AnsiEventHandler) *AnsiParser
return parser return parser
} }
func getState(name string, states []State) State { func getState(name string, states []state) state {
for _, el := range states { for _, el := range states {
if el.Name() == name { if el.Name() == name {
return el return el
@ -99,7 +98,7 @@ func (ap *AnsiParser) handle(b byte) error {
if newState == nil { if newState == nil {
logger.Warning("newState is nil") logger.Warning("newState is nil")
return errors.New(fmt.Sprintf("New state of 'nil' is invalid.")) return errors.New("New state of 'nil' is invalid.")
} }
if newState != ap.currState { if newState != ap.currState {
@ -111,7 +110,7 @@ func (ap *AnsiParser) handle(b byte) error {
return nil return nil
} }
func (ap *AnsiParser) changeState(newState State) error { func (ap *AnsiParser) changeState(newState state) error {
logger.Infof("ChangeState %s --> %s", ap.currState.Name(), newState.Name()) logger.Infof("ChangeState %s --> %s", ap.currState.Name(), newState.Name())
// Exit old state // Exit old state

View File

@ -31,7 +31,7 @@ func parseParams(bytes []byte) ([]string, error) {
return params, nil return params, nil
} }
func parseCmd(context AnsiContext) (string, error) { func parseCmd(context ansiContext) (string, error) {
return string(context.currentChar), nil return string(context.currentChar), nil
} }

View File

@ -113,7 +113,7 @@ func (ap *AnsiParser) print() error {
} }
func (ap *AnsiParser) clear() error { func (ap *AnsiParser) clear() error {
ap.context = &AnsiContext{} ap.context = &ansiContext{}
return nil return nil
} }

View File

@ -1,114 +0,0 @@
package ansiterm
import (
"fmt"
"testing"
)
func getStateNames() []string {
parser, _ := createTestParser("Ground")
stateNames := []string{}
for _, state := range parser.stateMap {
stateNames = append(stateNames, state.Name())
}
return stateNames
}
func stateTransitionHelper(t *testing.T, start string, end string, bytes []byte) {
for _, b := range bytes {
bytes := []byte{byte(b)}
parser, _ := createTestParser(start)
parser.Parse(bytes)
validateState(t, parser.currState, end)
}
}
func anyToXHelper(t *testing.T, bytes []byte, expectedState string) {
for _, s := range getStateNames() {
stateTransitionHelper(t, s, expectedState, bytes)
}
}
func funcCallParamHelper(t *testing.T, bytes []byte, start string, expected string, expectedCalls []string) {
parser, evtHandler := createTestParser(start)
parser.Parse(bytes)
validateState(t, parser.currState, expected)
validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls)
}
func parseParamsHelper(t *testing.T, bytes []byte, expectedParams []string) {
params, err := parseParams(bytes)
if err != nil {
t.Errorf("Parameter parse error: %v", err)
return
}
if len(params) != len(expectedParams) {
t.Errorf("Parsed parameters: %v", params)
t.Errorf("Expected parameters: %v", expectedParams)
t.Errorf("Parameter length failure: %d != %d", len(params), len(expectedParams))
return
}
for i, v := range expectedParams {
if v != params[i] {
t.Errorf("Parsed parameters: %v", params)
t.Errorf("Expected parameters: %v", expectedParams)
t.Errorf("Parameter parse failure: %s != %s at position %d", v, params[i], i)
}
}
}
func cursorSingleParamHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
}
func cursorTwoParamHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1 1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 1])", funcName)})
funcCallParamHelper(t, []byte{'2', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([23 1])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)})
funcCallParamHelper(t, []byte{'2', ';', '3', ';', '4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2 3])", funcName)})
}
func eraseHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([2])", funcName)})
funcCallParamHelper(t, []byte{'3', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([3])", funcName)})
funcCallParamHelper(t, []byte{'4', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([0])", funcName)})
funcCallParamHelper(t, []byte{'1', ';', '2', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
}
func scrollHelper(t *testing.T, command byte, funcName string) {
funcCallParamHelper(t, []byte{command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'0', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'1', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([1])", funcName)})
funcCallParamHelper(t, []byte{'5', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([5])", funcName)})
funcCallParamHelper(t, []byte{'4', ';', '6', command}, "CsiEntry", "Ground", []string{fmt.Sprintf("%s([4])", funcName)})
}
func clearOnStateChangeHelper(t *testing.T, start string, end string, bytes []byte) {
p, _ := createTestParser(start)
fillContext(p.context)
p.Parse(bytes)
validateState(t, p.currState, end)
validateEmptyContext(t, p.context)
}
func c0Helper(t *testing.T, bytes []byte, expectedState string, expectedCalls []string) {
parser, evtHandler := createTestParser("Ground")
parser.Parse(bytes)
validateState(t, parser.currState, expectedState)
validateFuncCalls(t, evtHandler.FunctionCalls, expectedCalls)
}

View File

@ -1,66 +0,0 @@
package ansiterm
import (
"testing"
)
func createTestParser(s string) (*AnsiParser, *TestAnsiEventHandler) {
evtHandler := CreateTestAnsiEventHandler()
parser := CreateParser(s, evtHandler)
return parser, evtHandler
}
func validateState(t *testing.T, actualState State, expectedStateName string) {
actualName := "Nil"
if actualState != nil {
actualName = actualState.Name()
}
if actualName != expectedStateName {
t.Errorf("Invalid State: '%s' != '%s'", actualName, expectedStateName)
}
}
func validateFuncCalls(t *testing.T, actualCalls []string, expectedCalls []string) {
actualCount := len(actualCalls)
expectedCount := len(expectedCalls)
if actualCount != expectedCount {
t.Errorf("Actual calls: %v", actualCalls)
t.Errorf("Expected calls: %v", expectedCalls)
t.Errorf("Call count error: %d != %d", actualCount, expectedCount)
return
}
for i, v := range actualCalls {
if v != expectedCalls[i] {
t.Errorf("Actual calls: %v", actualCalls)
t.Errorf("Expected calls: %v", expectedCalls)
t.Errorf("Mismatched calls: %s != %s with lengths %d and %d", v, expectedCalls[i], len(v), len(expectedCalls[i]))
}
}
}
func fillContext(context *AnsiContext) {
context.currentChar = 'A'
context.paramBuffer = []byte{'C', 'D', 'E'}
context.interBuffer = []byte{'F', 'G', 'H'}
}
func validateEmptyContext(t *testing.T, context *AnsiContext) {
var expectedCurrChar byte = 0x0
if context.currentChar != expectedCurrChar {
t.Errorf("Currentchar mismatch '%#x' != '%#x'", context.currentChar, expectedCurrChar)
}
if len(context.paramBuffer) != 0 {
t.Errorf("Non-empty parameter buffer: %v", context.paramBuffer)
}
if len(context.paramBuffer) != 0 {
t.Errorf("Non-empty intermediate buffer: %v", context.interBuffer)
}
}

View File

@ -1,52 +1,52 @@
package ansiterm package ansiterm
type StateId int type stateID int
type State interface { type state interface {
Enter() error Enter() error
Exit() error Exit() error
Handle(byte) (State, error) Handle(byte) (state, error)
Name() string Name() string
Transition(State) error Transition(state) error
} }
type BaseState struct { type baseState struct {
name string name string
parser *AnsiParser parser *AnsiParser
} }
func (base BaseState) Enter() error { func (base baseState) Enter() error {
return nil return nil
} }
func (base BaseState) Exit() error { func (base baseState) Exit() error {
return nil return nil
} }
func (base BaseState) Handle(b byte) (s State, e error) { func (base baseState) Handle(b byte) (s state, e error) {
switch { switch {
case b == CSI_ENTRY: case b == CSI_ENTRY:
return base.parser.CsiEntry, nil return base.parser.csiEntry, nil
case b == DCS_ENTRY: case b == DCS_ENTRY:
return base.parser.DcsEntry, nil return base.parser.dcsEntry, nil
case b == ANSI_ESCAPE_PRIMARY: case b == ANSI_ESCAPE_PRIMARY:
return base.parser.Escape, nil return base.parser.escape, nil
case b == OSC_STRING: case b == OSC_STRING:
return base.parser.OscString, nil return base.parser.oscString, nil
case sliceContains(ToGroundBytes, b): case sliceContains(toGroundBytes, b):
return base.parser.Ground, nil return base.parser.ground, nil
} }
return nil, nil return nil, nil
} }
func (base BaseState) Name() string { func (base baseState) Name() string {
return base.name return base.name
} }
func (base BaseState) Transition(s State) error { func (base baseState) Transition(s state) error {
if s == base.parser.Ground { if s == base.parser.ground {
execBytes := []byte{0x18} execBytes := []byte{0x18}
execBytes = append(execBytes, 0x1A) execBytes = append(execBytes, 0x1A)
execBytes = append(execBytes, getByteRange(0x80, 0x8F)...) execBytes = append(execBytes, getByteRange(0x80, 0x8F)...)
@ -62,10 +62,10 @@ func (base BaseState) Transition(s State) error {
return nil return nil
} }
type DcsEntryState struct { type dcsEntryState struct {
BaseState baseState
} }
type ErrorState struct { type errorState struct {
BaseState baseState
} }

View File

@ -1,173 +0,0 @@
package ansiterm
import (
"fmt"
"strconv"
)
type TestAnsiEventHandler struct {
FunctionCalls []string
}
func CreateTestAnsiEventHandler() *TestAnsiEventHandler {
evtHandler := TestAnsiEventHandler{}
evtHandler.FunctionCalls = make([]string, 0)
return &evtHandler
}
func (h *TestAnsiEventHandler) recordCall(call string, params []string) {
s := fmt.Sprintf("%s(%v)", call, params)
h.FunctionCalls = append(h.FunctionCalls, s)
}
func (h *TestAnsiEventHandler) Print(b byte) error {
h.recordCall("Print", []string{string(b)})
return nil
}
func (h *TestAnsiEventHandler) Execute(b byte) error {
h.recordCall("Execute", []string{string(b)})
return nil
}
func (h *TestAnsiEventHandler) CUU(param int) error {
h.recordCall("CUU", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUD(param int) error {
h.recordCall("CUD", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUF(param int) error {
h.recordCall("CUF", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUB(param int) error {
h.recordCall("CUB", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CNL(param int) error {
h.recordCall("CNL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CPL(param int) error {
h.recordCall("CPL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CHA(param int) error {
h.recordCall("CHA", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) VPA(param int) error {
h.recordCall("VPA", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) CUP(x int, y int) error {
xS, yS := strconv.Itoa(x), strconv.Itoa(y)
h.recordCall("CUP", []string{xS, yS})
return nil
}
func (h *TestAnsiEventHandler) HVP(x int, y int) error {
xS, yS := strconv.Itoa(x), strconv.Itoa(y)
h.recordCall("HVP", []string{xS, yS})
return nil
}
func (h *TestAnsiEventHandler) DECTCEM(visible bool) error {
h.recordCall("DECTCEM", []string{strconv.FormatBool(visible)})
return nil
}
func (h *TestAnsiEventHandler) DECOM(visible bool) error {
h.recordCall("DECOM", []string{strconv.FormatBool(visible)})
return nil
}
func (h *TestAnsiEventHandler) DECCOLM(use132 bool) error {
h.recordCall("DECOLM", []string{strconv.FormatBool(use132)})
return nil
}
func (h *TestAnsiEventHandler) ED(param int) error {
h.recordCall("ED", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) EL(param int) error {
h.recordCall("EL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) IL(param int) error {
h.recordCall("IL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DL(param int) error {
h.recordCall("DL", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) ICH(param int) error {
h.recordCall("ICH", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DCH(param int) error {
h.recordCall("DCH", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) SGR(params []int) error {
strings := []string{}
for _, v := range params {
strings = append(strings, strconv.Itoa(v))
}
h.recordCall("SGR", strings)
return nil
}
func (h *TestAnsiEventHandler) SU(param int) error {
h.recordCall("SU", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) SD(param int) error {
h.recordCall("SD", []string{strconv.Itoa(param)})
return nil
}
func (h *TestAnsiEventHandler) DA(params []string) error {
h.recordCall("DA", params)
return nil
}
func (h *TestAnsiEventHandler) DECSTBM(top int, bottom int) error {
topS, bottomS := strconv.Itoa(top), strconv.Itoa(bottom)
h.recordCall("DECSTBM", []string{topS, bottomS})
return nil
}
func (h *TestAnsiEventHandler) RI() error {
h.recordCall("RI", nil)
return nil
}
func (h *TestAnsiEventHandler) IND() error {
h.recordCall("IND", nil)
return nil
}
func (h *TestAnsiEventHandler) Flush() error {
return nil
}

View File

@ -9,7 +9,7 @@ import (
"strings" "strings"
"syscall" "syscall"
. "github.com/Azure/go-ansiterm" "github.com/Azure/go-ansiterm"
) )
// Windows keyboard constants // Windows keyboard constants
@ -85,17 +85,17 @@ func newAnsiCommand(command []byte) *ansiCommand {
if lastCharIndex != 0 { if lastCharIndex != 0 {
start := 1 start := 1
// skip if double char escape sequence // skip if double char escape sequence
if command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_ESCAPE_SECONDARY { if command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_ESCAPE_SECONDARY {
start++ start++
} }
// convert this to GetNextParam method // convert this to GetNextParam method
ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ANSI_PARAMETER_SEP) ac.Parameters = strings.Split(string(command[start:lastCharIndex]), ansiterm.ANSI_PARAMETER_SEP)
} }
return ac return ac
} }
func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT { func (ac *ansiCommand) paramAsSHORT(index int, defaultValue int16) int16 {
if index < 0 || index >= len(ac.Parameters) { if index < 0 || index >= len(ac.Parameters) {
return defaultValue return defaultValue
} }
@ -105,7 +105,7 @@ func (ac *ansiCommand) paramAsSHORT(index int, defaultValue SHORT) SHORT {
return defaultValue return defaultValue
} }
return SHORT(param) return int16(param)
} }
func (ac *ansiCommand) String() string { func (ac *ansiCommand) String() string {
@ -119,12 +119,12 @@ func (ac *ansiCommand) String() string {
// See http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html. // See http://manpages.ubuntu.com/manpages/intrepid/man4/console_codes.4.html.
func isAnsiCommandChar(b byte) bool { func isAnsiCommandChar(b byte) bool {
switch { switch {
case ANSI_COMMAND_FIRST <= b && b <= ANSI_COMMAND_LAST && b != ANSI_ESCAPE_SECONDARY: case ansiterm.ANSI_COMMAND_FIRST <= b && b <= ansiterm.ANSI_COMMAND_LAST && b != ansiterm.ANSI_ESCAPE_SECONDARY:
return true return true
case b == ANSI_CMD_G1 || b == ANSI_CMD_OSC || b == ANSI_CMD_DECPAM || b == ANSI_CMD_DECPNM: case b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_OSC || b == ansiterm.ANSI_CMD_DECPAM || b == ansiterm.ANSI_CMD_DECPNM:
// non-CSI escape sequence terminator // non-CSI escape sequence terminator
return true return true
case b == ANSI_CMD_STR_TERM || b == ANSI_BEL: case b == ansiterm.ANSI_CMD_STR_TERM || b == ansiterm.ANSI_BEL:
// String escape sequence terminator // String escape sequence terminator
return true return true
} }
@ -132,11 +132,11 @@ func isAnsiCommandChar(b byte) bool {
} }
func isXtermOscSequence(command []byte, current byte) bool { func isXtermOscSequence(command []byte, current byte) bool {
return (len(command) >= 2 && command[0] == ANSI_ESCAPE_PRIMARY && command[1] == ANSI_CMD_OSC && current != ANSI_BEL) return (len(command) >= 2 && command[0] == ansiterm.ANSI_ESCAPE_PRIMARY && command[1] == ansiterm.ANSI_CMD_OSC && current != ansiterm.ANSI_BEL)
} }
func isCharacterSelectionCmdChar(b byte) bool { func isCharacterSelectionCmdChar(b byte) bool {
return (b == ANSI_CMD_G0 || b == ANSI_CMD_G1 || b == ANSI_CMD_G2 || b == ANSI_CMD_G3) return (b == ansiterm.ANSI_CMD_G0 || b == ansiterm.ANSI_CMD_G1 || b == ansiterm.ANSI_CMD_G2 || b == ansiterm.ANSI_CMD_G3)
} }
// bytesToHex converts a slice of bytes to a human-readable string. // bytesToHex converts a slice of bytes to a human-readable string.
@ -150,7 +150,7 @@ func bytesToHex(b []byte) string {
// ensureInRange adjusts the passed value, if necessary, to ensure it is within // ensureInRange adjusts the passed value, if necessary, to ensure it is within
// the passed min / max range. // the passed min / max range.
func ensureInRange(n SHORT, min SHORT, max SHORT) SHORT { func ensureInRange(n int16, min int16, max int16) int16 {
if n < min { if n < min {
return min return min
} else if n > max { } else if n > max {

View File

@ -66,21 +66,21 @@ const (
// -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan). // -- The attributes are combined to produce various colors (e.g., Blue + Green will create Cyan).
// Clearing all foreground or background colors results in black; setting all creates white. // Clearing all foreground or background colors results in black; setting all creates white.
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682088(v=vs.85).aspx#_win32_character_attributes.
FOREGROUND_BLUE WORD = 0x0001 FOREGROUND_BLUE uint16 = 0x0001
FOREGROUND_GREEN WORD = 0x0002 FOREGROUND_GREEN uint16 = 0x0002
FOREGROUND_RED WORD = 0x0004 FOREGROUND_RED uint16 = 0x0004
FOREGROUND_INTENSITY WORD = 0x0008 FOREGROUND_INTENSITY uint16 = 0x0008
FOREGROUND_MASK WORD = 0x000F FOREGROUND_MASK uint16 = 0x000F
BACKGROUND_BLUE WORD = 0x0010 BACKGROUND_BLUE uint16 = 0x0010
BACKGROUND_GREEN WORD = 0x0020 BACKGROUND_GREEN uint16 = 0x0020
BACKGROUND_RED WORD = 0x0040 BACKGROUND_RED uint16 = 0x0040
BACKGROUND_INTENSITY WORD = 0x0080 BACKGROUND_INTENSITY uint16 = 0x0080
BACKGROUND_MASK WORD = 0x00F0 BACKGROUND_MASK uint16 = 0x00F0
COMMON_LVB_MASK WORD = 0xFF00 COMMON_LVB_MASK uint16 = 0xFF00
COMMON_LVB_REVERSE_VIDEO WORD = 0x4000 COMMON_LVB_REVERSE_VIDEO uint16 = 0x4000
COMMON_LVB_UNDERSCORE WORD = 0x8000 COMMON_LVB_UNDERSCORE uint16 = 0x8000
// Input event types // Input event types
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.
@ -104,60 +104,53 @@ const (
) )
// Windows API Console types // Windows API Console types
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspx for core types (e.g., SHORT)
// -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD) // -- See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682101(v=vs.85).aspx for Console specific types (e.g., COORD)
// -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment // -- See https://msdn.microsoft.com/en-us/library/aa296569(v=vs.60).aspx for comments on alignment
type ( type (
SHORT int16
BOOL int32
WORD uint16
WCHAR uint16
DWORD uint32
CHAR_INFO struct { CHAR_INFO struct {
UnicodeChar WCHAR UnicodeChar uint16
Attributes WORD Attributes uint16
} }
CONSOLE_CURSOR_INFO struct { CONSOLE_CURSOR_INFO struct {
Size DWORD Size uint32
Visible BOOL Visible int32
} }
CONSOLE_SCREEN_BUFFER_INFO struct { CONSOLE_SCREEN_BUFFER_INFO struct {
Size COORD Size COORD
CursorPosition COORD CursorPosition COORD
Attributes WORD Attributes uint16
Window SMALL_RECT Window SMALL_RECT
MaximumWindowSize COORD MaximumWindowSize COORD
} }
COORD struct { COORD struct {
X SHORT X int16
Y SHORT Y int16
} }
SMALL_RECT struct { SMALL_RECT struct {
Left SHORT Left int16
Top SHORT Top int16
Right SHORT Right int16
Bottom SHORT Bottom int16
} }
// INPUT_RECORD is a C/C++ union of which KEY_EVENT_RECORD is one case, it is also the largest // INPUT_RECORD is a C/C++ union of which KEY_EVENT_RECORD is one case, it is also the largest
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms683499(v=vs.85).aspx.
INPUT_RECORD struct { INPUT_RECORD struct {
EventType WORD EventType uint16
KeyEvent KEY_EVENT_RECORD KeyEvent KEY_EVENT_RECORD
} }
KEY_EVENT_RECORD struct { KEY_EVENT_RECORD struct {
KeyDown BOOL KeyDown int32
RepeatCount WORD RepeatCount uint16
VirtualKeyCode WORD VirtualKeyCode uint16
VirtualScanCode WORD VirtualScanCode uint16
UnicodeChar WCHAR UnicodeChar uint16
ControlKeyState DWORD ControlKeyState uint32
} }
WINDOW_BUFFER_SIZE struct { WINDOW_BUFFER_SIZE struct {
@ -165,12 +158,12 @@ type (
} }
) )
// boolToBOOL converts a Go bool into a Windows BOOL. // boolToBOOL converts a Go bool into a Windows int32.
func boolToBOOL(f bool) BOOL { func boolToBOOL(f bool) int32 {
if f { if f {
return BOOL(1) return int32(1)
} else { } else {
return BOOL(0) return int32(0)
} }
} }
@ -242,7 +235,7 @@ func SetConsoleScreenBufferSize(handle uintptr, coord COORD) error {
// SetConsoleTextAttribute sets the attributes of characters written to the // SetConsoleTextAttribute sets the attributes of characters written to the
// console screen buffer by the WriteFile or WriteConsole function. // console screen buffer by the WriteFile or WriteConsole function.
// See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx. // See http://msdn.microsoft.com/en-us/library/windows/desktop/ms686047(v=vs.85).aspx.
func SetConsoleTextAttribute(handle uintptr, attribute WORD) error { func SetConsoleTextAttribute(handle uintptr, attribute uint16) error {
r1, r2, err := setConsoleTextAttributeProc.Call(handle, uintptr(attribute), 0) r1, r2, err := setConsoleTextAttributeProc.Call(handle, uintptr(attribute), 0)
use(attribute) use(attribute)
return checkError(r1, r2, err) return checkError(r1, r2, err)
@ -280,7 +273,7 @@ func ReadConsoleInput(handle uintptr, buffer []INPUT_RECORD, count *uint32) erro
// It returns true if the handle was signaled; false otherwise. // It returns true if the handle was signaled; false otherwise.
// See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx. // See https://msdn.microsoft.com/en-us/library/windows/desktop/ms687032(v=vs.85).aspx.
func WaitForSingleObject(handle uintptr, msWait uint32) (bool, error) { func WaitForSingleObject(handle uintptr, msWait uint32) (bool, error) {
r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(DWORD(msWait))) r1, _, err := waitForSingleObjectProc.Call(handle, uintptr(uint32(msWait)))
switch r1 { switch r1 {
case WAIT_ABANDONED, WAIT_TIMEOUT: case WAIT_ABANDONED, WAIT_TIMEOUT:
return false, nil return false, nil
@ -320,8 +313,8 @@ func checkError(r1, r2 uintptr, err error) error {
// coordToPointer converts a COORD into a uintptr (by fooling the type system). // coordToPointer converts a COORD into a uintptr (by fooling the type system).
func coordToPointer(c COORD) uintptr { func coordToPointer(c COORD) uintptr {
// Note: This code assumes the two SHORTs are correctly laid out; the "cast" to DWORD is just to get a pointer to pass. // Note: This code assumes the two SHORTs are correctly laid out; the "cast" to uint32 is just to get a pointer to pass.
return uintptr(*((*DWORD)(unsafe.Pointer(&c)))) return uintptr(*((*uint32)(unsafe.Pointer(&c))))
} }
// use is a no-op, but the compiler cannot see that it is. // use is a no-op, but the compiler cannot see that it is.

View File

@ -2,9 +2,7 @@
package winterm package winterm
import ( import "github.com/Azure/go-ansiterm"
. "github.com/Azure/go-ansiterm"
)
const ( const (
FOREGROUND_COLOR_MASK = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE FOREGROUND_COLOR_MASK = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
@ -13,83 +11,83 @@ const (
// collectAnsiIntoWindowsAttributes modifies the passed Windows text mode flags to reflect the // collectAnsiIntoWindowsAttributes modifies the passed Windows text mode flags to reflect the
// request represented by the passed ANSI mode. // request represented by the passed ANSI mode.
func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode WORD, ansiMode SHORT) (WORD, bool) { func collectAnsiIntoWindowsAttributes(windowsMode uint16, inverted bool, baseMode uint16, ansiMode int16) (uint16, bool) {
switch ansiMode { switch ansiMode {
// Mode styles // Mode styles
case ANSI_SGR_BOLD: case ansiterm.ANSI_SGR_BOLD:
windowsMode = windowsMode | FOREGROUND_INTENSITY windowsMode = windowsMode | FOREGROUND_INTENSITY
case ANSI_SGR_DIM, ANSI_SGR_BOLD_DIM_OFF: case ansiterm.ANSI_SGR_DIM, ansiterm.ANSI_SGR_BOLD_DIM_OFF:
windowsMode &^= FOREGROUND_INTENSITY windowsMode &^= FOREGROUND_INTENSITY
case ANSI_SGR_UNDERLINE: case ansiterm.ANSI_SGR_UNDERLINE:
windowsMode = windowsMode | COMMON_LVB_UNDERSCORE windowsMode = windowsMode | COMMON_LVB_UNDERSCORE
case ANSI_SGR_REVERSE: case ansiterm.ANSI_SGR_REVERSE:
inverted = true inverted = true
case ANSI_SGR_REVERSE_OFF: case ansiterm.ANSI_SGR_REVERSE_OFF:
inverted = false inverted = false
case ANSI_SGR_UNDERLINE_OFF: case ansiterm.ANSI_SGR_UNDERLINE_OFF:
windowsMode &^= COMMON_LVB_UNDERSCORE windowsMode &^= COMMON_LVB_UNDERSCORE
// Foreground colors // Foreground colors
case ANSI_SGR_FOREGROUND_DEFAULT: case ansiterm.ANSI_SGR_FOREGROUND_DEFAULT:
windowsMode = (windowsMode &^ FOREGROUND_MASK) | (baseMode & FOREGROUND_MASK) windowsMode = (windowsMode &^ FOREGROUND_MASK) | (baseMode & FOREGROUND_MASK)
case ANSI_SGR_FOREGROUND_BLACK: case ansiterm.ANSI_SGR_FOREGROUND_BLACK:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK)
case ANSI_SGR_FOREGROUND_RED: case ansiterm.ANSI_SGR_FOREGROUND_RED:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED
case ANSI_SGR_FOREGROUND_GREEN: case ansiterm.ANSI_SGR_FOREGROUND_GREEN:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN
case ANSI_SGR_FOREGROUND_YELLOW: case ansiterm.ANSI_SGR_FOREGROUND_YELLOW:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN
case ANSI_SGR_FOREGROUND_BLUE: case ansiterm.ANSI_SGR_FOREGROUND_BLUE:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_BLUE windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_MAGENTA: case ansiterm.ANSI_SGR_FOREGROUND_MAGENTA:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_BLUE windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_CYAN: case ansiterm.ANSI_SGR_FOREGROUND_CYAN:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_GREEN | FOREGROUND_BLUE
case ANSI_SGR_FOREGROUND_WHITE: case ansiterm.ANSI_SGR_FOREGROUND_WHITE:
windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE windowsMode = (windowsMode &^ FOREGROUND_COLOR_MASK) | FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE
// Background colors // Background colors
case ANSI_SGR_BACKGROUND_DEFAULT: case ansiterm.ANSI_SGR_BACKGROUND_DEFAULT:
// Black with no intensity // Black with no intensity
windowsMode = (windowsMode &^ BACKGROUND_MASK) | (baseMode & BACKGROUND_MASK) windowsMode = (windowsMode &^ BACKGROUND_MASK) | (baseMode & BACKGROUND_MASK)
case ANSI_SGR_BACKGROUND_BLACK: case ansiterm.ANSI_SGR_BACKGROUND_BLACK:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK)
case ANSI_SGR_BACKGROUND_RED: case ansiterm.ANSI_SGR_BACKGROUND_RED:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED
case ANSI_SGR_BACKGROUND_GREEN: case ansiterm.ANSI_SGR_BACKGROUND_GREEN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN
case ANSI_SGR_BACKGROUND_YELLOW: case ansiterm.ANSI_SGR_BACKGROUND_YELLOW:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN
case ANSI_SGR_BACKGROUND_BLUE: case ansiterm.ANSI_SGR_BACKGROUND_BLUE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_BLUE windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_MAGENTA: case ansiterm.ANSI_SGR_BACKGROUND_MAGENTA:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_BLUE windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_CYAN: case ansiterm.ANSI_SGR_BACKGROUND_CYAN:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_GREEN | BACKGROUND_BLUE
case ANSI_SGR_BACKGROUND_WHITE: case ansiterm.ANSI_SGR_BACKGROUND_WHITE:
windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE windowsMode = (windowsMode &^ BACKGROUND_COLOR_MASK) | BACKGROUND_RED | BACKGROUND_GREEN | BACKGROUND_BLUE
} }
@ -97,6 +95,6 @@ func collectAnsiIntoWindowsAttributes(windowsMode WORD, inverted bool, baseMode
} }
// invertAttributes inverts the foreground and background colors of a Windows attributes value // invertAttributes inverts the foreground and background colors of a Windows attributes value
func invertAttributes(windowsMode WORD) WORD { func invertAttributes(windowsMode uint16) uint16 {
return (COMMON_LVB_MASK & windowsMode) | ((FOREGROUND_MASK & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4) return (COMMON_LVB_MASK & windowsMode) | ((FOREGROUND_MASK & windowsMode) << 4) | ((BACKGROUND_MASK & windowsMode) >> 4)
} }

View File

@ -3,11 +3,11 @@
package winterm package winterm
const ( const (
Horizontal = iota horizontal = iota
Vertical vertical
) )
func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT { func (h *windowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_INFO) SMALL_RECT {
if h.originMode { if h.originMode {
sr := h.effectiveSr(info.Window) sr := h.effectiveSr(info.Window)
return SMALL_RECT{ return SMALL_RECT{
@ -27,7 +27,7 @@ func (h *WindowsAnsiEventHandler) getCursorWindow(info *CONSOLE_SCREEN_BUFFER_IN
} }
// setCursorPosition sets the cursor to the specified position, bounded to the screen size // setCursorPosition sets the cursor to the specified position, bounded to the screen size
func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error { func (h *windowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL_RECT) error {
position.X = ensureInRange(position.X, window.Left, window.Right) position.X = ensureInRange(position.X, window.Left, window.Right)
position.Y = ensureInRange(position.Y, window.Top, window.Bottom) position.Y = ensureInRange(position.Y, window.Top, window.Bottom)
err := SetConsoleCursorPosition(h.fd, position) err := SetConsoleCursorPosition(h.fd, position)
@ -38,15 +38,15 @@ func (h *WindowsAnsiEventHandler) setCursorPosition(position COORD, window SMALL
return err return err
} }
func (h *WindowsAnsiEventHandler) moveCursorVertical(param int) error { func (h *windowsAnsiEventHandler) moveCursorVertical(param int) error {
return h.moveCursor(Vertical, param) return h.moveCursor(vertical, param)
} }
func (h *WindowsAnsiEventHandler) moveCursorHorizontal(param int) error { func (h *windowsAnsiEventHandler) moveCursorHorizontal(param int) error {
return h.moveCursor(Horizontal, param) return h.moveCursor(horizontal, param)
} }
func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error { func (h *windowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
@ -54,10 +54,10 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
position := info.CursorPosition position := info.CursorPosition
switch moveMode { switch moveMode {
case Horizontal: case horizontal:
position.X += SHORT(param) position.X += int16(param)
case Vertical: case vertical:
position.Y += SHORT(param) position.Y += int16(param)
} }
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
@ -67,7 +67,7 @@ func (h *WindowsAnsiEventHandler) moveCursor(moveMode int, param int) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error { func (h *windowsAnsiEventHandler) moveCursorLine(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
@ -75,7 +75,7 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error {
position := info.CursorPosition position := info.CursorPosition
position.X = 0 position.X = 0
position.Y += SHORT(param) position.Y += int16(param)
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
return err return err
@ -84,14 +84,14 @@ func (h *WindowsAnsiEventHandler) moveCursorLine(param int) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) moveCursorColumn(param int) error { func (h *windowsAnsiEventHandler) moveCursorColumn(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
} }
position := info.CursorPosition position := info.CursorPosition
position.X = SHORT(param) - 1 position.X = int16(param) - 1
if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil { if err = h.setCursorPosition(position, h.getCursorWindow(info)); err != nil {
return err return err

View File

@ -2,11 +2,9 @@
package winterm package winterm
import ( import "github.com/Azure/go-ansiterm"
. "github.com/Azure/go-ansiterm"
)
func (h *WindowsAnsiEventHandler) clearRange(attributes WORD, fromCoord COORD, toCoord COORD) error { func (h *windowsAnsiEventHandler) clearRange(attributes uint16, fromCoord COORD, toCoord COORD) error {
// Ignore an invalid (negative area) request // Ignore an invalid (negative area) request
if toCoord.Y < fromCoord.Y { if toCoord.Y < fromCoord.Y {
return nil return nil
@ -60,7 +58,7 @@ func (h *WindowsAnsiEventHandler) clearRange(attributes WORD, fromCoord COORD, t
return nil return nil
} }
func (h *WindowsAnsiEventHandler) clearRect(attributes WORD, fromCoord COORD, toCoord COORD) error { func (h *windowsAnsiEventHandler) clearRect(attributes uint16, fromCoord COORD, toCoord COORD) error {
region := SMALL_RECT{Top: fromCoord.Y, Left: fromCoord.X, Bottom: toCoord.Y, Right: toCoord.X} region := SMALL_RECT{Top: fromCoord.Y, Left: fromCoord.X, Bottom: toCoord.Y, Right: toCoord.X}
width := toCoord.X - fromCoord.X + 1 width := toCoord.X - fromCoord.X + 1
height := toCoord.Y - fromCoord.Y + 1 height := toCoord.Y - fromCoord.Y + 1
@ -72,7 +70,7 @@ func (h *WindowsAnsiEventHandler) clearRect(attributes WORD, fromCoord COORD, to
buffer := make([]CHAR_INFO, size) buffer := make([]CHAR_INFO, size)
char := CHAR_INFO{WCHAR(FILL_CHARACTER), attributes} char := CHAR_INFO{ansiterm.FILL_CHARACTER, attributes}
for i := 0; i < int(size); i++ { for i := 0; i < int(size); i++ {
buffer[i] = char buffer[i] = char
} }

View File

@ -3,9 +3,9 @@
package winterm package winterm
// effectiveSr gets the current effective scroll region in buffer coordinates // effectiveSr gets the current effective scroll region in buffer coordinates
func (h *WindowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion { func (h *windowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion {
top := AddInRange(window.Top, h.sr.top, window.Top, window.Bottom) top := addInRange(window.Top, h.sr.top, window.Top, window.Bottom)
bottom := AddInRange(window.Top, h.sr.bottom, window.Top, window.Bottom) bottom := addInRange(window.Top, h.sr.bottom, window.Top, window.Bottom)
if top >= bottom { if top >= bottom {
top = window.Top top = window.Top
bottom = window.Bottom bottom = window.Bottom
@ -13,7 +13,7 @@ func (h *WindowsAnsiEventHandler) effectiveSr(window SMALL_RECT) scrollRegion {
return scrollRegion{top: top, bottom: bottom} return scrollRegion{top: top, bottom: bottom}
} }
func (h *WindowsAnsiEventHandler) scrollUp(param int) error { func (h *windowsAnsiEventHandler) scrollUp(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
@ -23,11 +23,11 @@ func (h *WindowsAnsiEventHandler) scrollUp(param int) error {
return h.scroll(param, sr, info) return h.scroll(param, sr, info)
} }
func (h *WindowsAnsiEventHandler) scrollDown(param int) error { func (h *windowsAnsiEventHandler) scrollDown(param int) error {
return h.scrollUp(-param) return h.scrollUp(-param)
} }
func (h *WindowsAnsiEventHandler) deleteLines(param int) error { func (h *windowsAnsiEventHandler) deleteLines(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
@ -44,12 +44,12 @@ func (h *WindowsAnsiEventHandler) deleteLines(param int) error {
} }
} }
func (h *WindowsAnsiEventHandler) insertLines(param int) error { func (h *windowsAnsiEventHandler) insertLines(param int) error {
return h.deleteLines(-param) return h.deleteLines(-param)
} }
// scroll scrolls the provided scroll region by param lines. The scroll region is in buffer coordinates. // scroll scrolls the provided scroll region by param lines. The scroll region is in buffer coordinates.
func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSOLE_SCREEN_BUFFER_INFO) error { func (h *windowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSOLE_SCREEN_BUFFER_INFO) error {
logger.Infof("scroll: scrollTop: %d, scrollBottom: %d", sr.top, sr.bottom) logger.Infof("scroll: scrollTop: %d, scrollBottom: %d", sr.top, sr.bottom)
logger.Infof("scroll: windowTop: %d, windowBottom: %d", info.Window.Top, info.Window.Bottom) logger.Infof("scroll: windowTop: %d, windowBottom: %d", info.Window.Top, info.Window.Bottom)
@ -64,7 +64,7 @@ func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSO
// Origin to which area should be copied // Origin to which area should be copied
destOrigin := COORD{ destOrigin := COORD{
X: 0, X: 0,
Y: sr.top - SHORT(param), Y: sr.top - int16(param),
} }
char := CHAR_INFO{ char := CHAR_INFO{
@ -78,7 +78,7 @@ func (h *WindowsAnsiEventHandler) scroll(param int, sr scrollRegion, info *CONSO
return nil return nil
} }
func (h *WindowsAnsiEventHandler) deleteCharacters(param int) error { func (h *windowsAnsiEventHandler) deleteCharacters(param int) error {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
return err return err
@ -86,12 +86,12 @@ func (h *WindowsAnsiEventHandler) deleteCharacters(param int) error {
return h.scrollLine(param, info.CursorPosition, info) return h.scrollLine(param, info.CursorPosition, info)
} }
func (h *WindowsAnsiEventHandler) insertCharacters(param int) error { func (h *windowsAnsiEventHandler) insertCharacters(param int) error {
return h.deleteCharacters(-param) return h.deleteCharacters(-param)
} }
// scrollLine scrolls a line horizontally starting at the provided position by a number of columns. // scrollLine scrolls a line horizontally starting at the provided position by a number of columns.
func (h *WindowsAnsiEventHandler) scrollLine(columns int, position COORD, info *CONSOLE_SCREEN_BUFFER_INFO) error { func (h *windowsAnsiEventHandler) scrollLine(columns int, position COORD, info *CONSOLE_SCREEN_BUFFER_INFO) error {
// Copy from and clip to the scroll region (full buffer width) // Copy from and clip to the scroll region (full buffer width)
scrollRect := SMALL_RECT{ scrollRect := SMALL_RECT{
Top: position.Y, Top: position.Y,
@ -102,7 +102,7 @@ func (h *WindowsAnsiEventHandler) scrollLine(columns int, position COORD, info *
// Origin to which area should be copied // Origin to which area should be copied
destOrigin := COORD{ destOrigin := COORD{
X: position.X - SHORT(columns), X: position.X - int16(columns),
Y: position.Y, Y: position.Y,
} }

View File

@ -4,6 +4,6 @@ package winterm
// AddInRange increments a value by the passed quantity while ensuring the values // AddInRange increments a value by the passed quantity while ensuring the values
// always remain within the supplied min / max range. // always remain within the supplied min / max range.
func AddInRange(n SHORT, increment SHORT, min SHORT, max SHORT) SHORT { func addInRange(n int16, increment int16, min int16, max int16) int16 {
return ensureInRange(n+increment, min, max) return ensureInRange(n+increment, min, max)
} }

View File

@ -8,19 +8,19 @@ import (
"os" "os"
"strconv" "strconv"
. "github.com/Azure/go-ansiterm" "github.com/Azure/go-ansiterm"
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
) )
var logger *logrus.Logger var logger *logrus.Logger
type WindowsAnsiEventHandler struct { type windowsAnsiEventHandler struct {
fd uintptr fd uintptr
file *os.File file *os.File
infoReset *CONSOLE_SCREEN_BUFFER_INFO infoReset *CONSOLE_SCREEN_BUFFER_INFO
sr scrollRegion sr scrollRegion
buffer bytes.Buffer buffer bytes.Buffer
attributes WORD attributes uint16
inverted bool inverted bool
wrapNext bool wrapNext bool
drewMarginByte bool drewMarginByte bool
@ -30,10 +30,10 @@ type WindowsAnsiEventHandler struct {
curPos COORD curPos COORD
} }
func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler { func CreateWinEventHandler(fd uintptr, file *os.File) ansiterm.AnsiEventHandler {
logFile := ioutil.Discard logFile := ioutil.Discard
if isDebugEnv := os.Getenv(LogEnv); isDebugEnv == "1" { if isDebugEnv := os.Getenv(ansiterm.LogEnv); isDebugEnv == "1" {
logFile, _ = os.Create("winEventHandler.log") logFile, _ = os.Create("winEventHandler.log")
} }
@ -48,7 +48,7 @@ func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler {
return nil return nil
} }
return &WindowsAnsiEventHandler{ return &windowsAnsiEventHandler{
fd: fd, fd: fd,
file: file, file: file,
infoReset: infoReset, infoReset: infoReset,
@ -57,8 +57,8 @@ func CreateWinEventHandler(fd uintptr, file *os.File) AnsiEventHandler {
} }
type scrollRegion struct { type scrollRegion struct {
top SHORT top int16
bottom SHORT bottom int16
} }
// simulateLF simulates a LF or CR+LF by scrolling if necessary to handle the // simulateLF simulates a LF or CR+LF by scrolling if necessary to handle the
@ -68,7 +68,7 @@ type scrollRegion struct {
// //
// In the false case, the caller should ensure that a carriage return // In the false case, the caller should ensure that a carriage return
// and line feed are inserted or that the text is otherwise wrapped. // and line feed are inserted or that the text is otherwise wrapped.
func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) { func (h *windowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) {
if h.wrapNext { if h.wrapNext {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return false, err return false, err
@ -89,7 +89,8 @@ func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) {
h.updatePos(pos) h.updatePos(pos)
} }
return false, nil return false, nil
} else { }
// A custom scroll region is active. Scroll the window manually to simulate // A custom scroll region is active. Scroll the window manually to simulate
// the LF. // the LF.
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
@ -106,7 +107,7 @@ func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) {
} }
} }
return true, nil return true, nil
}
} else if pos.Y < info.Window.Bottom { } else if pos.Y < info.Window.Bottom {
// Let Windows handle the LF. // Let Windows handle the LF.
pos.Y++ pos.Y++
@ -133,7 +134,7 @@ func (h *WindowsAnsiEventHandler) simulateLF(includeCR bool) (bool, error) {
} }
// executeLF executes a LF without a CR. // executeLF executes a LF without a CR.
func (h *WindowsAnsiEventHandler) executeLF() error { func (h *windowsAnsiEventHandler) executeLF() error {
handled, err := h.simulateLF(false) handled, err := h.simulateLF(false)
if err != nil { if err != nil {
return err return err
@ -145,7 +146,7 @@ func (h *WindowsAnsiEventHandler) executeLF() error {
if err != nil { if err != nil {
return err return err
} }
h.buffer.WriteByte(ANSI_LINE_FEED) h.buffer.WriteByte(ansiterm.ANSI_LINE_FEED)
if pos.X != 0 { if pos.X != 0 {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
@ -159,7 +160,7 @@ func (h *WindowsAnsiEventHandler) executeLF() error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) Print(b byte) error { func (h *windowsAnsiEventHandler) Print(b byte) error {
if h.wrapNext { if h.wrapNext {
h.buffer.WriteByte(h.marginByte) h.buffer.WriteByte(h.marginByte)
h.clearWrap() h.clearWrap()
@ -182,9 +183,9 @@ func (h *WindowsAnsiEventHandler) Print(b byte) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) Execute(b byte) error { func (h *windowsAnsiEventHandler) Execute(b byte) error {
switch b { switch b {
case ANSI_TAB: case ansiterm.ANSI_TAB:
logger.Info("Execute(TAB)") logger.Info("Execute(TAB)")
// Move to the next tab stop, but preserve auto-wrap if already set. // Move to the next tab stop, but preserve auto-wrap if already set.
if !h.wrapNext { if !h.wrapNext {
@ -205,11 +206,11 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error {
} }
return nil return nil
case ANSI_BEL: case ansiterm.ANSI_BEL:
h.buffer.WriteByte(ANSI_BEL) h.buffer.WriteByte(ansiterm.ANSI_BEL)
return nil return nil
case ANSI_BACKSPACE: case ansiterm.ANSI_BACKSPACE:
if h.wrapNext { if h.wrapNext {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
@ -223,15 +224,15 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error {
if pos.X > 0 { if pos.X > 0 {
pos.X-- pos.X--
h.updatePos(pos) h.updatePos(pos)
h.buffer.WriteByte(ANSI_BACKSPACE) h.buffer.WriteByte(ansiterm.ANSI_BACKSPACE)
} }
return nil return nil
case ANSI_VERTICAL_TAB, ANSI_FORM_FEED: case ansiterm.ANSI_VERTICAL_TAB, ansiterm.ANSI_FORM_FEED:
// Treat as true LF. // Treat as true LF.
return h.executeLF() return h.executeLF()
case ANSI_LINE_FEED: case ansiterm.ANSI_LINE_FEED:
// Simulate a CR and LF for now since there is no way in go-ansiterm // Simulate a CR and LF for now since there is no way in go-ansiterm
// to tell if the LF should include CR (and more things break when it's // to tell if the LF should include CR (and more things break when it's
// missing than when it's incorrectly added). // missing than when it's incorrectly added).
@ -239,9 +240,9 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error {
if handled || err != nil { if handled || err != nil {
return err return err
} }
return h.buffer.WriteByte(ANSI_LINE_FEED) return h.buffer.WriteByte(ansiterm.ANSI_LINE_FEED)
case ANSI_CARRIAGE_RETURN: case ansiterm.ANSI_CARRIAGE_RETURN:
if h.wrapNext { if h.wrapNext {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
@ -255,7 +256,7 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error {
if pos.X != 0 { if pos.X != 0 {
pos.X = 0 pos.X = 0
h.updatePos(pos) h.updatePos(pos)
h.buffer.WriteByte(ANSI_CARRIAGE_RETURN) h.buffer.WriteByte(ansiterm.ANSI_CARRIAGE_RETURN)
} }
return nil return nil
@ -264,7 +265,7 @@ func (h *WindowsAnsiEventHandler) Execute(b byte) error {
} }
} }
func (h *WindowsAnsiEventHandler) CUU(param int) error { func (h *windowsAnsiEventHandler) CUU(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -273,7 +274,7 @@ func (h *WindowsAnsiEventHandler) CUU(param int) error {
return h.moveCursorVertical(-param) return h.moveCursorVertical(-param)
} }
func (h *WindowsAnsiEventHandler) CUD(param int) error { func (h *windowsAnsiEventHandler) CUD(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -282,7 +283,7 @@ func (h *WindowsAnsiEventHandler) CUD(param int) error {
return h.moveCursorVertical(param) return h.moveCursorVertical(param)
} }
func (h *WindowsAnsiEventHandler) CUF(param int) error { func (h *windowsAnsiEventHandler) CUF(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -291,7 +292,7 @@ func (h *WindowsAnsiEventHandler) CUF(param int) error {
return h.moveCursorHorizontal(param) return h.moveCursorHorizontal(param)
} }
func (h *WindowsAnsiEventHandler) CUB(param int) error { func (h *windowsAnsiEventHandler) CUB(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -300,7 +301,7 @@ func (h *WindowsAnsiEventHandler) CUB(param int) error {
return h.moveCursorHorizontal(-param) return h.moveCursorHorizontal(-param)
} }
func (h *WindowsAnsiEventHandler) CNL(param int) error { func (h *windowsAnsiEventHandler) CNL(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -309,7 +310,7 @@ func (h *WindowsAnsiEventHandler) CNL(param int) error {
return h.moveCursorLine(param) return h.moveCursorLine(param)
} }
func (h *WindowsAnsiEventHandler) CPL(param int) error { func (h *windowsAnsiEventHandler) CPL(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -318,7 +319,7 @@ func (h *WindowsAnsiEventHandler) CPL(param int) error {
return h.moveCursorLine(-param) return h.moveCursorLine(-param)
} }
func (h *WindowsAnsiEventHandler) CHA(param int) error { func (h *windowsAnsiEventHandler) CHA(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -327,7 +328,7 @@ func (h *WindowsAnsiEventHandler) CHA(param int) error {
return h.moveCursorColumn(param) return h.moveCursorColumn(param)
} }
func (h *WindowsAnsiEventHandler) VPA(param int) error { func (h *windowsAnsiEventHandler) VPA(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -339,11 +340,11 @@ func (h *WindowsAnsiEventHandler) VPA(param int) error {
} }
window := h.getCursorWindow(info) window := h.getCursorWindow(info)
position := info.CursorPosition position := info.CursorPosition
position.Y = window.Top + SHORT(param) - 1 position.Y = window.Top + int16(param) - 1
return h.setCursorPosition(position, window) return h.setCursorPosition(position, window)
} }
func (h *WindowsAnsiEventHandler) CUP(row int, col int) error { func (h *windowsAnsiEventHandler) CUP(row int, col int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -355,11 +356,11 @@ func (h *WindowsAnsiEventHandler) CUP(row int, col int) error {
} }
window := h.getCursorWindow(info) window := h.getCursorWindow(info)
position := COORD{window.Left + SHORT(col) - 1, window.Top + SHORT(row) - 1} position := COORD{window.Left + int16(col) - 1, window.Top + int16(row) - 1}
return h.setCursorPosition(position, window) return h.setCursorPosition(position, window)
} }
func (h *WindowsAnsiEventHandler) HVP(row int, col int) error { func (h *windowsAnsiEventHandler) HVP(row int, col int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -368,7 +369,7 @@ func (h *WindowsAnsiEventHandler) HVP(row int, col int) error {
return h.CUP(row, col) return h.CUP(row, col)
} }
func (h *WindowsAnsiEventHandler) DECTCEM(visible bool) error { func (h *windowsAnsiEventHandler) DECTCEM(visible bool) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -377,7 +378,7 @@ func (h *WindowsAnsiEventHandler) DECTCEM(visible bool) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) DECOM(enable bool) error { func (h *windowsAnsiEventHandler) DECOM(enable bool) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -387,7 +388,7 @@ func (h *WindowsAnsiEventHandler) DECOM(enable bool) error {
return h.CUP(1, 1) return h.CUP(1, 1)
} }
func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error { func (h *windowsAnsiEventHandler) DECCOLM(use132 bool) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -400,7 +401,7 @@ func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error {
if err != nil { if err != nil {
return err return err
} }
targetWidth := SHORT(80) targetWidth := int16(80)
if use132 { if use132 {
targetWidth = 132 targetWidth = 132
} }
@ -426,7 +427,7 @@ func (h *WindowsAnsiEventHandler) DECCOLM(use132 bool) error {
return SetConsoleCursorPosition(h.fd, COORD{0, 0}) return SetConsoleCursorPosition(h.fd, COORD{0, 0})
} }
func (h *WindowsAnsiEventHandler) ED(param int) error { func (h *windowsAnsiEventHandler) ED(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -485,7 +486,7 @@ func (h *WindowsAnsiEventHandler) ED(param int) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) EL(param int) error { func (h *windowsAnsiEventHandler) EL(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -526,7 +527,7 @@ func (h *WindowsAnsiEventHandler) EL(param int) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) IL(param int) error { func (h *windowsAnsiEventHandler) IL(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -535,7 +536,7 @@ func (h *WindowsAnsiEventHandler) IL(param int) error {
return h.insertLines(param) return h.insertLines(param)
} }
func (h *WindowsAnsiEventHandler) DL(param int) error { func (h *windowsAnsiEventHandler) DL(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -544,7 +545,7 @@ func (h *WindowsAnsiEventHandler) DL(param int) error {
return h.deleteLines(param) return h.deleteLines(param)
} }
func (h *WindowsAnsiEventHandler) ICH(param int) error { func (h *windowsAnsiEventHandler) ICH(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -553,7 +554,7 @@ func (h *WindowsAnsiEventHandler) ICH(param int) error {
return h.insertCharacters(param) return h.insertCharacters(param)
} }
func (h *WindowsAnsiEventHandler) DCH(param int) error { func (h *windowsAnsiEventHandler) DCH(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -562,7 +563,7 @@ func (h *WindowsAnsiEventHandler) DCH(param int) error {
return h.deleteCharacters(param) return h.deleteCharacters(param)
} }
func (h *WindowsAnsiEventHandler) SGR(params []int) error { func (h *windowsAnsiEventHandler) SGR(params []int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -579,13 +580,13 @@ func (h *WindowsAnsiEventHandler) SGR(params []int) error {
} else { } else {
for _, attr := range params { for _, attr := range params {
if attr == ANSI_SGR_RESET { if attr == ansiterm.ANSI_SGR_RESET {
h.attributes = h.infoReset.Attributes h.attributes = h.infoReset.Attributes
h.inverted = false h.inverted = false
continue continue
} }
h.attributes, h.inverted = collectAnsiIntoWindowsAttributes(h.attributes, h.inverted, h.infoReset.Attributes, SHORT(attr)) h.attributes, h.inverted = collectAnsiIntoWindowsAttributes(h.attributes, h.inverted, h.infoReset.Attributes, int16(attr))
} }
} }
@ -601,7 +602,7 @@ func (h *WindowsAnsiEventHandler) SGR(params []int) error {
return nil return nil
} }
func (h *WindowsAnsiEventHandler) SU(param int) error { func (h *windowsAnsiEventHandler) SU(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -610,7 +611,7 @@ func (h *WindowsAnsiEventHandler) SU(param int) error {
return h.scrollUp(param) return h.scrollUp(param)
} }
func (h *WindowsAnsiEventHandler) SD(param int) error { func (h *windowsAnsiEventHandler) SD(param int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -619,29 +620,29 @@ func (h *WindowsAnsiEventHandler) SD(param int) error {
return h.scrollDown(param) return h.scrollDown(param)
} }
func (h *WindowsAnsiEventHandler) DA(params []string) error { func (h *windowsAnsiEventHandler) DA(params []string) error {
logger.Infof("DA: [%v]", params) logger.Infof("DA: [%v]", params)
// DA cannot be implemented because it must send data on the VT100 input stream, // DA cannot be implemented because it must send data on the VT100 input stream,
// which is not available to go-ansiterm. // which is not available to go-ansiterm.
return nil return nil
} }
func (h *WindowsAnsiEventHandler) DECSTBM(top int, bottom int) error { func (h *windowsAnsiEventHandler) DECSTBM(top int, bottom int) error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
logger.Infof("DECSTBM: [%d, %d]", top, bottom) logger.Infof("DECSTBM: [%d, %d]", top, bottom)
// Windows is 0 indexed, Linux is 1 indexed // Windows is 0 indexed, Linux is 1 indexed
h.sr.top = SHORT(top - 1) h.sr.top = int16(top - 1)
h.sr.bottom = SHORT(bottom - 1) h.sr.bottom = int16(bottom - 1)
// This command also moves the cursor to the origin. // This command also moves the cursor to the origin.
h.clearWrap() h.clearWrap()
return h.CUP(1, 1) return h.CUP(1, 1)
} }
func (h *WindowsAnsiEventHandler) RI() error { func (h *windowsAnsiEventHandler) RI() error {
if err := h.Flush(); err != nil { if err := h.Flush(); err != nil {
return err return err
} }
@ -656,17 +657,17 @@ func (h *WindowsAnsiEventHandler) RI() error {
sr := h.effectiveSr(info.Window) sr := h.effectiveSr(info.Window)
if info.CursorPosition.Y == sr.top { if info.CursorPosition.Y == sr.top {
return h.scrollDown(1) return h.scrollDown(1)
} else {
return h.moveCursorVertical(-1)
} }
return h.moveCursorVertical(-1)
} }
func (h *WindowsAnsiEventHandler) IND() error { func (h *windowsAnsiEventHandler) IND() error {
logger.Info("IND: []") logger.Info("IND: []")
return h.executeLF() return h.executeLF()
} }
func (h *WindowsAnsiEventHandler) Flush() error { func (h *windowsAnsiEventHandler) Flush() error {
h.curInfo = nil h.curInfo = nil
if h.buffer.Len() > 0 { if h.buffer.Len() > 0 {
logger.Infof("Flush: [%s]", h.buffer.Bytes()) logger.Infof("Flush: [%s]", h.buffer.Bytes())
@ -683,7 +684,7 @@ func (h *WindowsAnsiEventHandler) Flush() error {
return err return err
} }
charInfo := []CHAR_INFO{{UnicodeChar: WCHAR(h.marginByte), Attributes: info.Attributes}} charInfo := []CHAR_INFO{{UnicodeChar: uint16(h.marginByte), Attributes: info.Attributes}}
size := COORD{1, 1} size := COORD{1, 1}
position := COORD{0, 0} position := COORD{0, 0}
region := SMALL_RECT{Left: info.CursorPosition.X, Top: info.CursorPosition.Y, Right: info.CursorPosition.X, Bottom: info.CursorPosition.Y} region := SMALL_RECT{Left: info.CursorPosition.X, Top: info.CursorPosition.Y, Right: info.CursorPosition.X, Bottom: info.CursorPosition.Y}
@ -697,7 +698,7 @@ func (h *WindowsAnsiEventHandler) Flush() error {
// cacheConsoleInfo ensures that the current console screen information has been queried // cacheConsoleInfo ensures that the current console screen information has been queried
// since the last call to Flush(). It must be called before accessing h.curInfo or h.curPos. // since the last call to Flush(). It must be called before accessing h.curInfo or h.curPos.
func (h *WindowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFER_INFO, error) { func (h *windowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFER_INFO, error) {
if h.curInfo == nil { if h.curInfo == nil {
info, err := GetConsoleScreenBufferInfo(h.fd) info, err := GetConsoleScreenBufferInfo(h.fd)
if err != nil { if err != nil {
@ -709,7 +710,7 @@ func (h *WindowsAnsiEventHandler) getCurrentInfo() (COORD, *CONSOLE_SCREEN_BUFFE
return h.curPos, h.curInfo, nil return h.curPos, h.curInfo, nil
} }
func (h *WindowsAnsiEventHandler) updatePos(pos COORD) { func (h *windowsAnsiEventHandler) updatePos(pos COORD) {
if h.curInfo == nil { if h.curInfo == nil {
panic("failed to call getCurrentInfo before calling updatePos") panic("failed to call getCurrentInfo before calling updatePos")
} }
@ -719,7 +720,7 @@ func (h *WindowsAnsiEventHandler) updatePos(pos COORD) {
// clearWrap clears the state where the cursor is in the margin // clearWrap clears the state where the cursor is in the margin
// waiting for the next character before wrapping the line. This must // waiting for the next character before wrapping the line. This must
// be done before most operations that act on the cursor. // be done before most operations that act on the cursor.
func (h *WindowsAnsiEventHandler) clearWrap() { func (h *windowsAnsiEventHandler) clearWrap() {
h.wrapNext = false h.wrapNext = false
h.drewMarginByte = false h.drewMarginByte = false
} }

View File

@ -1,42 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"autorest.go",
"client.go",
"error.go",
"preparer.go",
"responder.go",
"sender.go",
"utility.go",
"version.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//vendor/github.com/Azure/go-autorest/autorest/azure:all-srcs",
"//vendor/github.com/Azure/go-autorest/autorest/date:all-srcs",
"//vendor/github.com/Azure/go-autorest/autorest/to:all-srcs",
"//vendor/github.com/Azure/go-autorest/autorest/validation:all-srcs",
],
tags = ["automanaged"],
)

View File

@ -16,6 +16,7 @@ and Responding. A typical pattern is:
DoRetryForAttempts(5, time.Second)) DoRetryForAttempts(5, time.Second))
err = Respond(resp, err = Respond(resp,
ByDiscardingBody(),
ByClosing()) ByClosing())
Each phase relies on decorators to modify and / or manage processing. Decorators may first modify Each phase relies on decorators to modify and / or manage processing. Decorators may first modify

View File

@ -1,40 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"async.go",
"azure.go",
"config.go",
"devicetoken.go",
"environments.go",
"persist.go",
"token.go",
],
tags = ["automanaged"],
deps = [
"//vendor/github.com/Azure/go-autorest/autorest:go_default_library",
"//vendor/github.com/Azure/go-autorest/autorest/date:go_default_library",
"//vendor/github.com/dgrijalva/jwt-go:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -3,12 +3,13 @@ package azure
import ( import (
"bytes" "bytes"
"fmt" "fmt"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings" "strings"
"time" "time"
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/date"
) )
const ( const (
@ -16,12 +17,6 @@ const (
) )
const ( const (
methodDelete = "DELETE"
methodPatch = "PATCH"
methodPost = "POST"
methodPut = "PUT"
methodGet = "GET"
operationInProgress string = "InProgress" operationInProgress string = "InProgress"
operationCanceled string = "Canceled" operationCanceled string = "Canceled"
operationFailed string = "Failed" operationFailed string = "Failed"
@ -225,7 +220,7 @@ func updatePollingState(resp *http.Response, ps *pollingState) error {
// Lastly, requests against an existing resource, use the last request URI // Lastly, requests against an existing resource, use the last request URI
if ps.uri == "" { if ps.uri == "" {
m := strings.ToUpper(req.Method) m := strings.ToUpper(req.Method)
if m == methodPatch || m == methodPut || m == methodGet { if m == http.MethodPatch || m == http.MethodPut || m == http.MethodGet {
ps.uri = req.URL.String() ps.uri = req.URL.String()
} }
} }

View File

@ -1,13 +0,0 @@
package azure
import (
"net/url"
)
// OAuthConfig represents the endpoints needed
// in OAuth operations
type OAuthConfig struct {
AuthorizeEndpoint url.URL
TokenEndpoint url.URL
DeviceCodeEndpoint url.URL
}

View File

@ -1,193 +0,0 @@
package azure
/*
This file is largely based on rjw57/oauth2device's code, with the follow differences:
* scope -> resource, and only allow a single one
* receive "Message" in the DeviceCode struct and show it to users as the prompt
* azure-xplat-cli has the following behavior that this emulates:
- does not send client_secret during the token exchange
- sends resource again in the token exchange request
*/
import (
"fmt"
"net/http"
"net/url"
"time"
"github.com/Azure/go-autorest/autorest"
)
const (
logPrefix = "autorest/azure/devicetoken:"
)
var (
// ErrDeviceGeneric represents an unknown error from the token endpoint when using device flow
ErrDeviceGeneric = fmt.Errorf("%s Error while retrieving OAuth token: Unknown Error", logPrefix)
// ErrDeviceAccessDenied represents an access denied error from the token endpoint when using device flow
ErrDeviceAccessDenied = fmt.Errorf("%s Error while retrieving OAuth token: Access Denied", logPrefix)
// ErrDeviceAuthorizationPending represents the server waiting on the user to complete the device flow
ErrDeviceAuthorizationPending = fmt.Errorf("%s Error while retrieving OAuth token: Authorization Pending", logPrefix)
// ErrDeviceCodeExpired represents the server timing out and expiring the code during device flow
ErrDeviceCodeExpired = fmt.Errorf("%s Error while retrieving OAuth token: Code Expired", logPrefix)
// ErrDeviceSlowDown represents the service telling us we're polling too often during device flow
ErrDeviceSlowDown = fmt.Errorf("%s Error while retrieving OAuth token: Slow Down", logPrefix)
errCodeSendingFails = "Error occurred while sending request for Device Authorization Code"
errCodeHandlingFails = "Error occurred while handling response from the Device Endpoint"
errTokenSendingFails = "Error occurred while sending request with device code for a token"
errTokenHandlingFails = "Error occurred while handling response from the Token Endpoint (during device flow)"
)
// DeviceCode is the object returned by the device auth endpoint
// It contains information to instruct the user to complete the auth flow
type DeviceCode struct {
DeviceCode *string `json:"device_code,omitempty"`
UserCode *string `json:"user_code,omitempty"`
VerificationURL *string `json:"verification_url,omitempty"`
ExpiresIn *int64 `json:"expires_in,string,omitempty"`
Interval *int64 `json:"interval,string,omitempty"`
Message *string `json:"message"` // Azure specific
Resource string // store the following, stored when initiating, used when exchanging
OAuthConfig OAuthConfig
ClientID string
}
// TokenError is the object returned by the token exchange endpoint
// when something is amiss
type TokenError struct {
Error *string `json:"error,omitempty"`
ErrorCodes []int `json:"error_codes,omitempty"`
ErrorDescription *string `json:"error_description,omitempty"`
Timestamp *string `json:"timestamp,omitempty"`
TraceID *string `json:"trace_id,omitempty"`
}
// DeviceToken is the object return by the token exchange endpoint
// It can either look like a Token or an ErrorToken, so put both here
// and check for presence of "Error" to know if we are in error state
type deviceToken struct {
Token
TokenError
}
// InitiateDeviceAuth initiates a device auth flow. It returns a DeviceCode
// that can be used with CheckForUserCompletion or WaitForUserCompletion.
func InitiateDeviceAuth(client *autorest.Client, oauthConfig OAuthConfig, clientID, resource string) (*DeviceCode, error) {
req, _ := autorest.Prepare(
&http.Request{},
autorest.AsPost(),
autorest.AsFormURLEncoded(),
autorest.WithBaseURL(oauthConfig.DeviceCodeEndpoint.String()),
autorest.WithFormData(url.Values{
"client_id": []string{clientID},
"resource": []string{resource},
}),
)
resp, err := autorest.SendWithSender(client, req)
if err != nil {
return nil, fmt.Errorf("%s %s: %s", logPrefix, errCodeSendingFails, err)
}
var code DeviceCode
err = autorest.Respond(
resp,
autorest.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&code),
autorest.ByClosing())
if err != nil {
return nil, fmt.Errorf("%s %s: %s", logPrefix, errCodeHandlingFails, err)
}
code.ClientID = clientID
code.Resource = resource
code.OAuthConfig = oauthConfig
return &code, nil
}
// CheckForUserCompletion takes a DeviceCode and checks with the Azure AD OAuth endpoint
// to see if the device flow has: been completed, timed out, or otherwise failed
func CheckForUserCompletion(client *autorest.Client, code *DeviceCode) (*Token, error) {
req, _ := autorest.Prepare(
&http.Request{},
autorest.AsPost(),
autorest.AsFormURLEncoded(),
autorest.WithBaseURL(code.OAuthConfig.TokenEndpoint.String()),
autorest.WithFormData(url.Values{
"client_id": []string{code.ClientID},
"code": []string{*code.DeviceCode},
"grant_type": []string{OAuthGrantTypeDeviceCode},
"resource": []string{code.Resource},
}),
)
resp, err := autorest.SendWithSender(client, req)
if err != nil {
return nil, fmt.Errorf("%s %s: %s", logPrefix, errTokenSendingFails, err)
}
var token deviceToken
err = autorest.Respond(
resp,
autorest.WithErrorUnlessStatusCode(http.StatusOK, http.StatusBadRequest),
autorest.ByUnmarshallingJSON(&token),
autorest.ByClosing())
if err != nil {
return nil, fmt.Errorf("%s %s: %s", logPrefix, errTokenHandlingFails, err)
}
if token.Error == nil {
return &token.Token, nil
}
switch *token.Error {
case "authorization_pending":
return nil, ErrDeviceAuthorizationPending
case "slow_down":
return nil, ErrDeviceSlowDown
case "access_denied":
return nil, ErrDeviceAccessDenied
case "code_expired":
return nil, ErrDeviceCodeExpired
default:
return nil, ErrDeviceGeneric
}
}
// WaitForUserCompletion calls CheckForUserCompletion repeatedly until a token is granted or an error state occurs.
// This prevents the user from looping and checking against 'ErrDeviceAuthorizationPending'.
func WaitForUserCompletion(client *autorest.Client, code *DeviceCode) (*Token, error) {
intervalDuration := time.Duration(*code.Interval) * time.Second
waitDuration := intervalDuration
for {
token, err := CheckForUserCompletion(client, code)
if err == nil {
return token, nil
}
switch err {
case ErrDeviceSlowDown:
waitDuration += waitDuration
case ErrDeviceAuthorizationPending:
// noop
default: // everything else is "fatal" to us
return nil, err
}
if waitDuration > (intervalDuration * 3) {
return nil, fmt.Errorf("%s Error waiting for user to complete device flow. Server told us to slow_down too much", logPrefix)
}
time.Sleep(waitDuration)
}
}

View File

@ -2,14 +2,9 @@ package azure
import ( import (
"fmt" "fmt"
"net/url"
"strings" "strings"
) )
const (
activeDirectoryAPIVersion = "1.0"
)
var environments = map[string]Environment{ var environments = map[string]Environment{
"AZURECHINACLOUD": ChinaCloud, "AZURECHINACLOUD": ChinaCloud,
"AZUREGERMANCLOUD": GermanCloud, "AZUREGERMANCLOUD": GermanCloud,
@ -35,6 +30,7 @@ type Environment struct {
ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix"` ServiceBusEndpointSuffix string `json:"serviceBusEndpointSuffix"`
ServiceManagementVMDNSSuffix string `json:"serviceManagementVMDNSSuffix"` ServiceManagementVMDNSSuffix string `json:"serviceManagementVMDNSSuffix"`
ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix"` ResourceManagerVMDNSSuffix string `json:"resourceManagerVMDNSSuffix"`
ContainerRegistryDNSSuffix string `json:"containerRegistryDNSSuffix"`
} }
var ( var (
@ -56,6 +52,7 @@ var (
ServiceBusEndpointSuffix: "servicebus.azure.com", ServiceBusEndpointSuffix: "servicebus.azure.com",
ServiceManagementVMDNSSuffix: "cloudapp.net", ServiceManagementVMDNSSuffix: "cloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.azure.com", ResourceManagerVMDNSSuffix: "cloudapp.azure.com",
ContainerRegistryDNSSuffix: "azurecr.io",
} }
// USGovernmentCloud is the cloud environment for the US Government // USGovernmentCloud is the cloud environment for the US Government
@ -76,6 +73,7 @@ var (
ServiceBusEndpointSuffix: "servicebus.usgovcloudapi.net", ServiceBusEndpointSuffix: "servicebus.usgovcloudapi.net",
ServiceManagementVMDNSSuffix: "usgovcloudapp.net", ServiceManagementVMDNSSuffix: "usgovcloudapp.net",
ResourceManagerVMDNSSuffix: "cloudapp.windowsazure.us", ResourceManagerVMDNSSuffix: "cloudapp.windowsazure.us",
ContainerRegistryDNSSuffix: "azurecr.io",
} }
// ChinaCloud is the cloud environment operated in China // ChinaCloud is the cloud environment operated in China
@ -85,7 +83,7 @@ var (
PublishSettingsURL: "https://manage.chinacloudapi.com/publishsettings/index", PublishSettingsURL: "https://manage.chinacloudapi.com/publishsettings/index",
ServiceManagementEndpoint: "https://management.core.chinacloudapi.cn/", ServiceManagementEndpoint: "https://management.core.chinacloudapi.cn/",
ResourceManagerEndpoint: "https://management.chinacloudapi.cn/", ResourceManagerEndpoint: "https://management.chinacloudapi.cn/",
ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/?api-version=1.0", ActiveDirectoryEndpoint: "https://login.chinacloudapi.cn/",
GalleryEndpoint: "https://gallery.chinacloudapi.cn/", GalleryEndpoint: "https://gallery.chinacloudapi.cn/",
KeyVaultEndpoint: "https://vault.azure.cn/", KeyVaultEndpoint: "https://vault.azure.cn/",
GraphEndpoint: "https://graph.chinacloudapi.cn/", GraphEndpoint: "https://graph.chinacloudapi.cn/",
@ -96,6 +94,7 @@ var (
ServiceBusEndpointSuffix: "servicebus.chinacloudapi.net", ServiceBusEndpointSuffix: "servicebus.chinacloudapi.net",
ServiceManagementVMDNSSuffix: "chinacloudapp.cn", ServiceManagementVMDNSSuffix: "chinacloudapp.cn",
ResourceManagerVMDNSSuffix: "cloudapp.azure.cn", ResourceManagerVMDNSSuffix: "cloudapp.azure.cn",
ContainerRegistryDNSSuffix: "azurecr.io",
} }
// GermanCloud is the cloud environment operated in Germany // GermanCloud is the cloud environment operated in Germany
@ -116,6 +115,7 @@ var (
ServiceBusEndpointSuffix: "servicebus.cloudapi.de", ServiceBusEndpointSuffix: "servicebus.cloudapi.de",
ServiceManagementVMDNSSuffix: "azurecloudapp.de", ServiceManagementVMDNSSuffix: "azurecloudapp.de",
ResourceManagerVMDNSSuffix: "cloudapp.microsoftazure.de", ResourceManagerVMDNSSuffix: "cloudapp.microsoftazure.de",
ContainerRegistryDNSSuffix: "azurecr.io",
} }
) )
@ -128,35 +128,3 @@ func EnvironmentFromName(name string) (Environment, error) {
} }
return env, nil return env, nil
} }
// OAuthConfigForTenant returns an OAuthConfig with tenant specific urls
func (env Environment) OAuthConfigForTenant(tenantID string) (*OAuthConfig, error) {
return OAuthConfigForTenant(env.ActiveDirectoryEndpoint, tenantID)
}
// OAuthConfigForTenant returns an OAuthConfig with tenant specific urls for target cloud auth endpoint
func OAuthConfigForTenant(activeDirectoryEndpoint, tenantID string) (*OAuthConfig, error) {
template := "%s/oauth2/%s?api-version=%s"
u, err := url.Parse(activeDirectoryEndpoint)
if err != nil {
return nil, err
}
authorizeURL, err := u.Parse(fmt.Sprintf(template, tenantID, "authorize", activeDirectoryAPIVersion))
if err != nil {
return nil, err
}
tokenURL, err := u.Parse(fmt.Sprintf(template, tenantID, "token", activeDirectoryAPIVersion))
if err != nil {
return nil, err
}
deviceCodeURL, err := u.Parse(fmt.Sprintf(template, tenantID, "devicecode", activeDirectoryAPIVersion))
if err != nil {
return nil, err
}
return &OAuthConfig{
AuthorizeEndpoint: *authorizeURL,
TokenEndpoint: *tokenURL,
DeviceCodeEndpoint: *deviceCodeURL,
}, nil
}

View File

@ -1,59 +0,0 @@
package azure
import (
"encoding/json"
"fmt"
"io/ioutil"
"os"
"path/filepath"
)
// LoadToken restores a Token object from a file located at 'path'.
func LoadToken(path string) (*Token, error) {
file, err := os.Open(path)
if err != nil {
return nil, fmt.Errorf("failed to open file (%s) while loading token: %v", path, err)
}
defer file.Close()
var token Token
dec := json.NewDecoder(file)
if err = dec.Decode(&token); err != nil {
return nil, fmt.Errorf("failed to decode contents of file (%s) into Token representation: %v", path, err)
}
return &token, nil
}
// SaveToken persists an oauth token at the given location on disk.
// It moves the new file into place so it can safely be used to replace an existing file
// that maybe accessed by multiple processes.
func SaveToken(path string, mode os.FileMode, token Token) error {
dir := filepath.Dir(path)
err := os.MkdirAll(dir, os.ModePerm)
if err != nil {
return fmt.Errorf("failed to create directory (%s) to store token in: %v", dir, err)
}
newFile, err := ioutil.TempFile(dir, "token")
if err != nil {
return fmt.Errorf("failed to create the temp file to write the token: %v", err)
}
tempPath := newFile.Name()
if err := json.NewEncoder(newFile).Encode(token); err != nil {
return fmt.Errorf("failed to encode token to file (%s) while saving token: %v", tempPath, err)
}
if err := newFile.Close(); err != nil {
return fmt.Errorf("failed to close temp file %s: %v", tempPath, err)
}
// Atomic replace to avoid multi-writer file corruptions
if err := os.Rename(tempPath, path); err != nil {
return fmt.Errorf("failed to move temporary token to desired output location. src=%s dst=%s: %v", tempPath, path, err)
}
if err := os.Chmod(path, mode); err != nil {
return fmt.Errorf("failed to chmod the token file %s: %v", path, err)
}
return nil
}

View File

@ -1,363 +0,0 @@
package azure
import (
"crypto/rand"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"fmt"
"net/http"
"net/url"
"strconv"
"time"
"github.com/Azure/go-autorest/autorest"
"github.com/dgrijalva/jwt-go"
)
const (
defaultRefresh = 5 * time.Minute
tokenBaseDate = "1970-01-01T00:00:00Z"
// OAuthGrantTypeDeviceCode is the "grant_type" identifier used in device flow
OAuthGrantTypeDeviceCode = "device_code"
// OAuthGrantTypeClientCredentials is the "grant_type" identifier used in credential flows
OAuthGrantTypeClientCredentials = "client_credentials"
// OAuthGrantTypeRefreshToken is the "grant_type" identifier used in refresh token flows
OAuthGrantTypeRefreshToken = "refresh_token"
)
var expirationBase time.Time
func init() {
expirationBase, _ = time.Parse(time.RFC3339, tokenBaseDate)
}
// TokenRefreshCallback is the type representing callbacks that will be called after
// a successful token refresh
type TokenRefreshCallback func(Token) error
// Token encapsulates the access token used to authorize Azure requests.
type Token struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
ExpiresIn string `json:"expires_in"`
ExpiresOn string `json:"expires_on"`
NotBefore string `json:"not_before"`
Resource string `json:"resource"`
Type string `json:"token_type"`
}
// Expires returns the time.Time when the Token expires.
func (t Token) Expires() time.Time {
s, err := strconv.Atoi(t.ExpiresOn)
if err != nil {
s = -3600
}
return expirationBase.Add(time.Duration(s) * time.Second).UTC()
}
// IsExpired returns true if the Token is expired, false otherwise.
func (t Token) IsExpired() bool {
return t.WillExpireIn(0)
}
// WillExpireIn returns true if the Token will expire after the passed time.Duration interval
// from now, false otherwise.
func (t Token) WillExpireIn(d time.Duration) bool {
return !t.Expires().After(time.Now().Add(d))
}
// WithAuthorization returns a PrepareDecorator that adds an HTTP Authorization header whose
// value is "Bearer " followed by the AccessToken of the Token.
func (t *Token) WithAuthorization() autorest.PrepareDecorator {
return func(p autorest.Preparer) autorest.Preparer {
return autorest.PreparerFunc(func(r *http.Request) (*http.Request, error) {
return (autorest.WithBearerAuthorization(t.AccessToken)(p)).Prepare(r)
})
}
}
// ServicePrincipalNoSecret represents a secret type that contains no secret
// meaning it is not valid for fetching a fresh token. This is used by Manual
type ServicePrincipalNoSecret struct {
}
// SetAuthenticationValues is a method of the interface ServicePrincipalSecret
// It only returns an error for the ServicePrincipalNoSecret type
func (noSecret *ServicePrincipalNoSecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error {
return fmt.Errorf("Manually created ServicePrincipalToken does not contain secret material to retrieve a new access token")
}
// ServicePrincipalSecret is an interface that allows various secret mechanism to fill the form
// that is submitted when acquiring an oAuth token.
type ServicePrincipalSecret interface {
SetAuthenticationValues(spt *ServicePrincipalToken, values *url.Values) error
}
// ServicePrincipalTokenSecret implements ServicePrincipalSecret for client_secret type authorization.
type ServicePrincipalTokenSecret struct {
ClientSecret string
}
// SetAuthenticationValues is a method of the interface ServicePrincipalSecret.
// It will populate the form submitted during oAuth Token Acquisition using the client_secret.
func (tokenSecret *ServicePrincipalTokenSecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error {
v.Set("client_secret", tokenSecret.ClientSecret)
return nil
}
// ServicePrincipalCertificateSecret implements ServicePrincipalSecret for generic RSA cert auth with signed JWTs.
type ServicePrincipalCertificateSecret struct {
Certificate *x509.Certificate
PrivateKey *rsa.PrivateKey
}
// SignJwt returns the JWT signed with the certificate's private key.
func (secret *ServicePrincipalCertificateSecret) SignJwt(spt *ServicePrincipalToken) (string, error) {
hasher := sha1.New()
_, err := hasher.Write(secret.Certificate.Raw)
if err != nil {
return "", err
}
thumbprint := base64.URLEncoding.EncodeToString(hasher.Sum(nil))
// The jti (JWT ID) claim provides a unique identifier for the JWT.
jti := make([]byte, 20)
_, err = rand.Read(jti)
if err != nil {
return "", err
}
token := jwt.New(jwt.SigningMethodRS256)
token.Header["x5t"] = thumbprint
token.Claims = jwt.MapClaims{
"aud": spt.oauthConfig.TokenEndpoint.String(),
"iss": spt.clientID,
"sub": spt.clientID,
"jti": base64.URLEncoding.EncodeToString(jti),
"nbf": time.Now().Unix(),
"exp": time.Now().Add(time.Hour * 24).Unix(),
}
signedString, err := token.SignedString(secret.PrivateKey)
return signedString, err
}
// SetAuthenticationValues is a method of the interface ServicePrincipalSecret.
// It will populate the form submitted during oAuth Token Acquisition using a JWT signed with a certificate.
func (secret *ServicePrincipalCertificateSecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error {
jwt, err := secret.SignJwt(spt)
if err != nil {
return err
}
v.Set("client_assertion", jwt)
v.Set("client_assertion_type", "urn:ietf:params:oauth:client-assertion-type:jwt-bearer")
return nil
}
// ServicePrincipalToken encapsulates a Token created for a Service Principal.
type ServicePrincipalToken struct {
Token
secret ServicePrincipalSecret
oauthConfig OAuthConfig
clientID string
resource string
autoRefresh bool
refreshWithin time.Duration
sender autorest.Sender
refreshCallbacks []TokenRefreshCallback
}
// NewServicePrincipalTokenWithSecret create a ServicePrincipalToken using the supplied ServicePrincipalSecret implementation.
func NewServicePrincipalTokenWithSecret(oauthConfig OAuthConfig, id string, resource string, secret ServicePrincipalSecret, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) {
spt := &ServicePrincipalToken{
oauthConfig: oauthConfig,
secret: secret,
clientID: id,
resource: resource,
autoRefresh: true,
refreshWithin: defaultRefresh,
sender: &http.Client{},
refreshCallbacks: callbacks,
}
return spt, nil
}
// NewServicePrincipalTokenFromManualToken creates a ServicePrincipalToken using the supplied token
func NewServicePrincipalTokenFromManualToken(oauthConfig OAuthConfig, clientID string, resource string, token Token, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) {
spt, err := NewServicePrincipalTokenWithSecret(
oauthConfig,
clientID,
resource,
&ServicePrincipalNoSecret{},
callbacks...)
if err != nil {
return nil, err
}
spt.Token = token
return spt, nil
}
// NewServicePrincipalToken creates a ServicePrincipalToken from the supplied Service Principal
// credentials scoped to the named resource.
func NewServicePrincipalToken(oauthConfig OAuthConfig, clientID string, secret string, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) {
return NewServicePrincipalTokenWithSecret(
oauthConfig,
clientID,
resource,
&ServicePrincipalTokenSecret{
ClientSecret: secret,
},
callbacks...,
)
}
// NewServicePrincipalTokenFromCertificate create a ServicePrincipalToken from the supplied pkcs12 bytes.
func NewServicePrincipalTokenFromCertificate(oauthConfig OAuthConfig, clientID string, certificate *x509.Certificate, privateKey *rsa.PrivateKey, resource string, callbacks ...TokenRefreshCallback) (*ServicePrincipalToken, error) {
return NewServicePrincipalTokenWithSecret(
oauthConfig,
clientID,
resource,
&ServicePrincipalCertificateSecret{
PrivateKey: privateKey,
Certificate: certificate,
},
callbacks...,
)
}
// EnsureFresh will refresh the token if it will expire within the refresh window (as set by
// RefreshWithin).
func (spt *ServicePrincipalToken) EnsureFresh() error {
if spt.WillExpireIn(spt.refreshWithin) {
return spt.Refresh()
}
return nil
}
// InvokeRefreshCallbacks calls any TokenRefreshCallbacks that were added to the SPT during initialization
func (spt *ServicePrincipalToken) InvokeRefreshCallbacks(token Token) error {
if spt.refreshCallbacks != nil {
for _, callback := range spt.refreshCallbacks {
err := callback(spt.Token)
if err != nil {
return autorest.NewErrorWithError(err,
"azure.ServicePrincipalToken", "InvokeRefreshCallbacks", nil, "A TokenRefreshCallback handler returned an error")
}
}
}
return nil
}
// Refresh obtains a fresh token for the Service Principal.
func (spt *ServicePrincipalToken) Refresh() error {
return spt.refreshInternal(spt.resource)
}
// RefreshExchange refreshes the token, but for a different resource.
func (spt *ServicePrincipalToken) RefreshExchange(resource string) error {
return spt.refreshInternal(resource)
}
func (spt *ServicePrincipalToken) refreshInternal(resource string) error {
v := url.Values{}
v.Set("client_id", spt.clientID)
v.Set("resource", resource)
if spt.RefreshToken != "" {
v.Set("grant_type", OAuthGrantTypeRefreshToken)
v.Set("refresh_token", spt.RefreshToken)
} else {
v.Set("grant_type", OAuthGrantTypeClientCredentials)
err := spt.secret.SetAuthenticationValues(spt, &v)
if err != nil {
return err
}
}
req, _ := autorest.Prepare(&http.Request{},
autorest.AsPost(),
autorest.AsFormURLEncoded(),
autorest.WithBaseURL(spt.oauthConfig.TokenEndpoint.String()),
autorest.WithFormData(v))
resp, err := autorest.SendWithSender(spt.sender, req)
if err != nil {
return autorest.NewErrorWithError(err,
"azure.ServicePrincipalToken", "Refresh", resp, "Failure sending request for Service Principal %s",
spt.clientID)
}
var newToken Token
err = autorest.Respond(resp,
autorest.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&newToken),
autorest.ByClosing())
if err != nil {
return autorest.NewErrorWithError(err,
"azure.ServicePrincipalToken", "Refresh", resp, "Failure handling response to Service Principal %s request",
spt.clientID)
}
spt.Token = newToken
err = spt.InvokeRefreshCallbacks(newToken)
if err != nil {
// its already wrapped inside InvokeRefreshCallbacks
return err
}
return nil
}
// SetAutoRefresh enables or disables automatic refreshing of stale tokens.
func (spt *ServicePrincipalToken) SetAutoRefresh(autoRefresh bool) {
spt.autoRefresh = autoRefresh
}
// SetRefreshWithin sets the interval within which if the token will expire, EnsureFresh will
// refresh the token.
func (spt *ServicePrincipalToken) SetRefreshWithin(d time.Duration) {
spt.refreshWithin = d
return
}
// SetSender sets the autorest.Sender used when obtaining the Service Principal token. An
// undecorated http.Client is used by default.
func (spt *ServicePrincipalToken) SetSender(s autorest.Sender) {
spt.sender = s
}
// WithAuthorization returns a PrepareDecorator that adds an HTTP Authorization header whose
// value is "Bearer " followed by the AccessToken of the ServicePrincipalToken.
//
// By default, the token will automatically refresh if nearly expired (as determined by the
// RefreshWithin interval). Use the AutoRefresh method to enable or disable automatically refreshing
// tokens.
func (spt *ServicePrincipalToken) WithAuthorization() autorest.PrepareDecorator {
return func(p autorest.Preparer) autorest.Preparer {
return autorest.PreparerFunc(func(r *http.Request) (*http.Request, error) {
if spt.autoRefresh {
err := spt.EnsureFresh()
if err != nil {
return r, autorest.NewErrorWithError(err,
"azure.ServicePrincipalToken", "WithAuthorization", nil, "Failed to refresh Service Principal Token for request to %s",
r.URL)
}
}
return (autorest.WithBearerAuthorization(spt.AccessToken)(p)).Prepare(r)
})
}
}

View File

@ -8,6 +8,7 @@ import (
"log" "log"
"net/http" "net/http"
"net/http/cookiejar" "net/http/cookiejar"
"runtime"
"time" "time"
) )
@ -22,13 +23,24 @@ const (
DefaultRetryAttempts = 3 DefaultRetryAttempts = 3
) )
var statusCodesForRetry = []int{ var (
// defaultUserAgent builds a string containing the Go version, system archityecture and OS,
// and the go-autorest version.
defaultUserAgent = fmt.Sprintf("Go/%s (%s-%s) go-autorest/%s",
runtime.Version(),
runtime.GOARCH,
runtime.GOOS,
Version(),
)
statusCodesForRetry = []int{
http.StatusRequestTimeout, // 408 http.StatusRequestTimeout, // 408
http.StatusInternalServerError, // 500 http.StatusInternalServerError, // 500
http.StatusBadGateway, // 502 http.StatusBadGateway, // 502
http.StatusServiceUnavailable, // 503 http.StatusServiceUnavailable, // 503
http.StatusGatewayTimeout, // 504 http.StatusGatewayTimeout, // 504
} }
)
const ( const (
requestFormat = `HTTP Request Begin =================================================== requestFormat = `HTTP Request Begin ===================================================
@ -140,13 +152,24 @@ type Client struct {
// NewClientWithUserAgent returns an instance of a Client with the UserAgent set to the passed // NewClientWithUserAgent returns an instance of a Client with the UserAgent set to the passed
// string. // string.
func NewClientWithUserAgent(ua string) Client { func NewClientWithUserAgent(ua string) Client {
return Client{ c := Client{
PollingDelay: DefaultPollingDelay, PollingDelay: DefaultPollingDelay,
PollingDuration: DefaultPollingDuration, PollingDuration: DefaultPollingDuration,
RetryAttempts: DefaultRetryAttempts, RetryAttempts: DefaultRetryAttempts,
RetryDuration: 30 * time.Second, RetryDuration: 30 * time.Second,
UserAgent: ua, UserAgent: defaultUserAgent,
} }
c.AddToUserAgent(ua)
return c
}
// AddToUserAgent adds an extension to the current user agent
func (c *Client) AddToUserAgent(extension string) error {
if extension != "" {
c.UserAgent = fmt.Sprintf("%s %s", c.UserAgent, extension)
return nil
}
return fmt.Errorf("Extension was empty, User Agent stayed as %s", c.UserAgent)
} }
// Do implements the Sender interface by invoking the active Sender after applying authorization. // Do implements the Sender interface by invoking the active Sender after applying authorization.

View File

@ -1,32 +0,0 @@
package(default_visibility = ["//visibility:public"])
licenses(["notice"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"date.go",
"time.go",
"timerfc1123.go",
"utility.go",
],
tags = ["automanaged"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
)

View File

@ -183,6 +183,16 @@ func WithBaseURL(baseURL string) PrepareDecorator {
} }
} }
// WithCustomBaseURL returns a PrepareDecorator that replaces brace-enclosed keys within the
// request base URL (i.e., http.Request.URL) with the corresponding values from the passed map.
func WithCustomBaseURL(baseURL string, urlParameters map[string]interface{}) PrepareDecorator {
parameters := ensureValueStrings(urlParameters)
for key, value := range parameters {
baseURL = strings.Replace(baseURL, "{"+key+"}", value, -1)
}
return WithBaseURL(baseURL)
}
// WithFormData returns a PrepareDecoratore that "URL encodes" (e.g., bar=baz&foo=quux) into the // WithFormData returns a PrepareDecoratore that "URL encodes" (e.g., bar=baz&foo=quux) into the
// http.Request body. // http.Request body.
func WithFormData(v url.Values) PrepareDecorator { func WithFormData(v url.Values) PrepareDecorator {
@ -416,18 +426,3 @@ func WithQueryParameters(queryParameters map[string]interface{}) PrepareDecorato
}) })
} }
} }
// Authorizer is the interface that provides a PrepareDecorator used to supply request
// authorization. Most often, the Authorizer decorator runs last so it has access to the full
// state of the formed HTTP request.
type Authorizer interface {
WithAuthorization() PrepareDecorator
}
// NullAuthorizer implements a default, "do nothing" Authorizer.
type NullAuthorizer struct{}
// WithAuthorization returns a PrepareDecorator that does nothing.
func (na NullAuthorizer) WithAuthorization() PrepareDecorator {
return WithNothing()
}

View File

@ -5,6 +5,7 @@ import (
"encoding/json" "encoding/json"
"encoding/xml" "encoding/xml"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings" "strings"
@ -87,6 +88,24 @@ func ByCopying(b *bytes.Buffer) RespondDecorator {
} }
} }
// ByDiscardingBody returns a RespondDecorator that first invokes the passed Responder after which
// it copies the remaining bytes (if any) in the response body to ioutil.Discard. Since the passed
// Responder is invoked prior to discarding the response body, the decorator may occur anywhere
// within the set.
func ByDiscardingBody() RespondDecorator {
return func(r Responder) Responder {
return ResponderFunc(func(resp *http.Response) error {
err := r.Respond(resp)
if err == nil && resp != nil && resp.Body != nil {
if _, err := io.Copy(ioutil.Discard, resp.Body); err != nil {
return fmt.Errorf("Error discarding the response body: %v", err)
}
}
return err
})
}
}
// ByClosing returns a RespondDecorator that first invokes the passed Responder after which it // ByClosing returns a RespondDecorator that first invokes the passed Responder after which it
// closes the response body. Since the passed Responder is invoked prior to closing the response // closes the response body. Since the passed Responder is invoked prior to closing the response
// body, the decorator may occur anywhere within the set. // body, the decorator may occur anywhere within the set.
@ -128,6 +147,8 @@ func ByUnmarshallingJSON(v interface{}) RespondDecorator {
err := r.Respond(resp) err := r.Respond(resp)
if err == nil { if err == nil {
b, errInner := ioutil.ReadAll(resp.Body) b, errInner := ioutil.ReadAll(resp.Body)
// Some responses might include a BOM, remove for successful unmarshalling
b = bytes.TrimPrefix(b, []byte("\xef\xbb\xbf"))
if errInner != nil { if errInner != nil {
err = fmt.Errorf("Error occurred reading http.Response#Body - Error = '%v'", errInner) err = fmt.Errorf("Error occurred reading http.Response#Body - Error = '%v'", errInner)
} else if len(strings.Trim(string(b), " ")) > 0 { } else if len(strings.Trim(string(b), " ")) > 0 {

View File

@ -97,7 +97,7 @@ func DoCloseIfError() SendDecorator {
return SenderFunc(func(r *http.Request) (*http.Response, error) { return SenderFunc(func(r *http.Request) (*http.Response, error) {
resp, err := s.Do(r) resp, err := s.Do(r)
if err != nil { if err != nil {
Respond(resp, ByClosing()) Respond(resp, ByDiscardingBody(), ByClosing())
} }
return resp, err return resp, err
}) })
@ -156,6 +156,7 @@ func DoPollForStatusCodes(duration time.Duration, delay time.Duration, codes ...
for err == nil && ResponseHasStatusCode(resp, codes...) { for err == nil && ResponseHasStatusCode(resp, codes...) {
Respond(resp, Respond(resp,
ByDiscardingBody(),
ByClosing()) ByClosing())
resp, err = SendWithSender(s, r, resp, err = SendWithSender(s, r,
AfterDelay(GetRetryAfter(resp, delay))) AfterDelay(GetRetryAfter(resp, delay)))

Some files were not shown because too many files have changed in this diff Show More