Commit 8d90cadc authored by Brendan Burns's avatar Brendan Burns

Update azure dependency. Add contianer registry.

parent bb792b17
...@@ -30,51 +30,61 @@ ...@@ -30,51 +30,61 @@
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/compute",
"Comment": "v3.1.0-beta-24-g8316b90", "Comment": "v7.0.1-beta",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2" "Rev": "0984e0641ae43b89283223034574d6465be93bf4"
},
{
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/containerregistry",
"Comment": "v7.0.1-beta",
"Rev": "0984e0641ae43b89283223034574d6465be93bf4"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/network",
"Comment": "v3.1.0-beta-24-g8316b90", "Comment": "v7.0.1-beta",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2" "Rev": "0984e0641ae43b89283223034574d6465be93bf4"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/arm/storage",
"Comment": "v3.1.0-beta-24-g8316b90", "Comment": "v7.0.1-beta",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2" "Rev": "0984e0641ae43b89283223034574d6465be93bf4"
}, },
{ {
"ImportPath": "github.com/Azure/azure-sdk-for-go/storage", "ImportPath": "github.com/Azure/azure-sdk-for-go/storage",
"Comment": "v3.1.0-beta-24-g8316b90", "Comment": "v7.0.1-beta",
"Rev": "8316b9060f9c2443ba0864663245695d570a7fa2" "Rev": "0984e0641ae43b89283223034574d6465be93bf4"
}, },
{ {
"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.0.6-4-g2492d97", "Comment": "v7.2.2-8-ge0c77ec",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a" "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/azure", "ImportPath": "github.com/Azure/go-autorest/autorest/azure",
"Comment": "v7.0.6-4-g2492d97", "Comment": "v7.2.2-8-ge0c77ec",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a" "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/date", "ImportPath": "github.com/Azure/go-autorest/autorest/date",
"Comment": "v7.0.6-4-g2492d97", "Comment": "v7.2.2-8-ge0c77ec",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a" "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
}, },
{ {
"ImportPath": "github.com/Azure/go-autorest/autorest/to", "ImportPath": "github.com/Azure/go-autorest/autorest/to",
"Comment": "v7.0.6-4-g2492d97", "Comment": "v7.2.2-8-ge0c77ec",
"Rev": "2492d97b402e00797833c03ac5fa1c572c7bb29a" "Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
},
{
"ImportPath": "github.com/Azure/go-autorest/autorest/validation",
"Comment": "v7.2.2-8-ge0c77ec",
"Rev": "e0c77ecbe74311e03f2a629834d2110f031f1453"
}, },
{ {
"ImportPath": "github.com/MakeNowJust/heredoc", "ImportPath": "github.com/MakeNowJust/heredoc",
...@@ -2304,12 +2314,12 @@ ...@@ -2304,12 +2314,12 @@
}, },
{ {
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon", "ImportPath": "github.com/vmware/photon-controller-go-sdk/photon",
"Comment": "PROMOTED-336", "Comment": "PROMOTED-339",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832" "Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
}, },
{ {
"ImportPath": "github.com/vmware/photon-controller-go-sdk/photon/lightwave", "ImportPath": "github.com/vmware/photon-controller-go-sdk/photon/lightwave",
"Comment": "PROMOTED-336", "Comment": "PROMOTED-339",
"Rev": "dd6be2029ef341cae37b2557ddd302f68176f832" "Rev": "dd6be2029ef341cae37b2557ddd302f68176f832"
}, },
{ {
......
...@@ -21,6 +21,7 @@ package compute ...@@ -21,6 +21,7 @@ package compute
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"
) )
...@@ -41,12 +42,19 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string) ...@@ -41,12 +42,19 @@ func NewAvailabilitySetsClientWithBaseURI(baseURI string, subscriptionID string)
return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)} return AvailabilitySetsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the operation to create or update the availability set. // CreateOrUpdate create or update an availability set.
// //
// resourceGroupName is the name of the resource group. name is parameters // resourceGroupName is the name of the resource group. name is the name of
// supplied to the Create Availability Set operation. parameters is // the availability set. parameters is parameters supplied to the Create
// 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") return result, autorest.NewErrorWithError(err, "compute.AvailabilitySetsClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -107,7 +115,7 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response ...@@ -107,7 +115,7 @@ func (client AvailabilitySetsClient) CreateOrUpdateResponder(resp *http.Response
return return
} }
// Delete the operation to delete the availability set. // Delete delete an availability set.
// //
// 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.
...@@ -169,7 +177,7 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul ...@@ -169,7 +177,7 @@ func (client AvailabilitySetsClient) DeleteResponder(resp *http.Response) (resul
return return
} }
// Get the operation to get the availability set. // Get retrieves information about an availability set.
// //
// 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.
...@@ -232,7 +240,7 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A ...@@ -232,7 +240,7 @@ func (client AvailabilitySetsClient) GetResponder(resp *http.Response) (result A
return return
} }
// List the operation to list the availability sets. // List lists all availability sets in a resource group.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) { func (client AvailabilitySetsClient) List(resourceGroupName string) (result AvailabilitySetListResult, err error) {
......
...@@ -21,6 +21,7 @@ package compute ...@@ -21,6 +21,7 @@ package compute
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"
) )
...@@ -41,10 +42,18 @@ func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string) ...@@ -41,10 +42,18 @@ func NewUsageOperationsClientWithBaseURI(baseURI string, subscriptionID string)
return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)} return UsageOperationsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// List lists compute usages for a subscription. // 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 upon which resource usage is queried. // location is the location for which resource usage is queried.
func (client UsageOperationsClient) List(location string) (result ListUsagesResult, err error) { 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) req, err := client.ListPreparer(location)
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing request") return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing request")
...@@ -106,7 +115,7 @@ func (client UsageOperationsClient) ListResponder(resp *http.Response) (result L ...@@ -106,7 +115,7 @@ func (client UsageOperationsClient) ListResponder(resp *http.Response) (result L
func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult) (result ListUsagesResult, err error) { func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult) (result ListUsagesResult, err error) {
req, err := lastResults.ListUsagesResultPreparer() req, err := lastResults.ListUsagesResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -115,12 +124,12 @@ func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult ...@@ -115,12 +124,12 @@ func (client UsageOperationsClient) ListNextResults(lastResults ListUsagesResult
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.UsageOperationsClient", "List", resp, "Failure sending next results request request") return result, autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "compute.UsageOperationsClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -23,9 +23,9 @@ import ( ...@@ -23,9 +23,9 @@ import (
) )
const ( const (
major = "3" major = "7"
minor = "2" minor = "0"
patch = "0" patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org) // Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta" tag = "-beta"
semVerFormat = "%s.%s.%s%s" semVerFormat = "%s.%s.%s%s"
......
...@@ -21,6 +21,7 @@ package compute ...@@ -21,6 +21,7 @@ package compute
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"
) )
...@@ -52,6 +53,13 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID ...@@ -52,6 +53,13 @@ func NewVirtualMachineExtensionsClientWithBaseURI(baseURI string, subscriptionID
// 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{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: extensionParameters,
Constraints: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "extensionParameters.VirtualMachineExtensionProperties.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, vmName, vmExtensionName, extensionParameters, cancel) 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") return result, autorest.NewErrorWithError(err, "compute.VirtualMachineExtensionsClient", "CreateOrUpdate", nil, "Failure preparing request")
......
...@@ -43,6 +43,9 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str ...@@ -43,6 +43,9 @@ func NewVirtualMachineImagesClientWithBaseURI(baseURI string, subscriptionID str
// Get gets a virtual machine image. // Get gets a virtual machine image.
// //
// location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer. skus is a valid
// image SKU. version is a valid image SKU version.
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 {
...@@ -105,9 +108,12 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu ...@@ -105,9 +108,12 @@ func (client VirtualMachineImagesClient) GetResponder(resp *http.Response) (resu
return return
} }
// List gets a list of virtual machine images. // List gets a list of all virtual machine image versions for the specified
// location, publisher, offer, and SKU.
// //
// filter is the filter to apply on the operation. // location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer. skus is a valid
// image SKU. filter is the filter to apply on the operation.
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 {
...@@ -178,8 +184,11 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res ...@@ -178,8 +184,11 @@ func (client VirtualMachineImagesClient) ListResponder(resp *http.Response) (res
return return
} }
// ListOffers gets a list of virtual machine image offers. // ListOffers gets a list of virtual machine image offers for the specified
// location and publisher.
// //
// location is the name of a supported Azure region. publisherName is a valid
// image publisher.
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 {
...@@ -239,8 +248,10 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response ...@@ -239,8 +248,10 @@ func (client VirtualMachineImagesClient) ListOffersResponder(resp *http.Response
return return
} }
// ListPublishers gets a list of virtual machine image publishers. // ListPublishers gets a list of virtual machine image publishers for the
// specified Azure location.
// //
// location is the name of a supported Azure region.
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 {
...@@ -299,8 +310,11 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp ...@@ -299,8 +310,11 @@ func (client VirtualMachineImagesClient) ListPublishersResponder(resp *http.Resp
return return
} }
// ListSkus gets a list of virtual machine image skus. // ListSkus gets a list of virtual machine image SKUs for the specified
// location, publisher, and offer.
// //
// location is the name of a supported Azure region. publisherName is a valid
// image publisher. offer is a valid image publisher offer.
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 {
......
...@@ -21,6 +21,7 @@ package compute ...@@ -21,6 +21,7 @@ package compute
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"
) )
...@@ -46,6 +47,12 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri ...@@ -46,6 +47,12 @@ func NewVirtualMachineSizesClientWithBaseURI(baseURI string, subscriptionID stri
// //
// location is the location upon which virtual-machine-sizes is queried. // location is the location upon which virtual-machine-sizes is queried.
func (client VirtualMachineSizesClient) List(location string) (result VirtualMachineSizeListResult, err error) { func (client VirtualMachineSizesClient) List(location string) (result VirtualMachineSizeListResult, 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.VirtualMachineSizesClient", "List")
}
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") return result, autorest.NewErrorWithError(err, "compute.VirtualMachineSizesClient", "List", nil, "Failure preparing request")
......
// Package containerregistry implements the Azure ARM Containerregistry
// service API version 2016-06-27-preview.
//
package containerregistry
// 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"
)
const (
// APIVersion is the version of the Containerregistry
APIVersion = "2016-06-27-preview"
// DefaultBaseURI is the default URI used for the service Containerregistry
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Containerregistry.
type ManagementClient struct {
autorest.Client
BaseURI string
APIVersion string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID,
}
}
package containerregistry
// 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/date"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// Registry is an object that represents a container registry.
type Registry 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"`
*RegistryProperties `json:"properties,omitempty"`
}
// RegistryCredentials is the result of a request to get the administrator
// login credentials for a container registry.
type RegistryCredentials struct {
autorest.Response `json:"-"`
Username *string `json:"username,omitempty"`
Password *string `json:"password,omitempty"`
}
// RegistryListResult is the result of a request to list container registries.
type RegistryListResult struct {
autorest.Response `json:"-"`
Value *[]Registry `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// RegistryListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client RegistryListResult) RegistryListResultPreparer() (*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)))
}
// RegistryNameCheckRequest is a request to check whether the container
// registry name is available.
type RegistryNameCheckRequest struct {
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
}
// RegistryNameStatus is the result of a request to check the availability of
// a container registry name.
type RegistryNameStatus struct {
autorest.Response `json:"-"`
NameAvailable *bool `json:"nameAvailable,omitempty"`
Reason *string `json:"reason,omitempty"`
Message *string `json:"message,omitempty"`
}
// RegistryProperties is the properties of a container registry.
type RegistryProperties struct {
LoginServer *string `json:"loginServer,omitempty"`
CreationDate *date.Time `json:"creationDate,omitempty"`
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
}
// RegistryPropertiesUpdateParameters is the parameters for updating the
// properties of a container registry.
type RegistryPropertiesUpdateParameters struct {
AdminUserEnabled *bool `json:"adminUserEnabled,omitempty"`
StorageAccount *StorageAccountProperties `json:"storageAccount,omitempty"`
}
// RegistryUpdateParameters is the parameters for updating a container
// registry.
type RegistryUpdateParameters struct {
Tags *map[string]*string `json:"tags,omitempty"`
*RegistryPropertiesUpdateParameters `json:"properties,omitempty"`
}
// Resource is an Azure resource.
type Resource struct {
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"`
}
// StorageAccountProperties is the properties of a storage account for a
// container registry.
type StorageAccountProperties struct {
Name *string `json:"name,omitempty"`
AccessKey *string `json:"accessKey,omitempty"`
}
package containerregistry
// 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 (
"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.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "containerregistry", "2016-06-27-preview")
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
}
// Package network implements the Azure ARM Network service API version // Package network implements the Azure ARM Network service API version
// 2016-06-01. // 2016-09-01.
// //
// The Microsoft Azure Network management API provides a RESTful set of web // The Microsoft Azure Network management API provides a RESTful set of web
// services that interact with Microsoft Azure Networks service to manage // services that interact with Microsoft Azure Networks service to manage
// your network resrources. The API has entities that capture the // your network resources. The API has entities that capture the relationship
// relationship between an end user and the Microsoft Azure Networks service. // 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.
...@@ -33,7 +33,7 @@ import ( ...@@ -33,7 +33,7 @@ import (
const ( const (
// APIVersion is the version of the Network // APIVersion is the version of the Network
APIVersion = "2016-06-01" 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"
...@@ -65,7 +65,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient { ...@@ -65,7 +65,7 @@ func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
// CheckDNSNameAvailability checks whether a domain name in the cloudapp.net // CheckDNSNameAvailability checks whether a domain name in the cloudapp.net
// zone is available for use. // zone is available for use.
// //
// location is the location of the domain name domainNameLabel is the domain // location is the location of the domain name. domainNameLabel is the domain
// name to be verified. It must conform to the following regular expression: // name to be verified. It must conform to the following regular expression:
// ^[a-z][a-z0-9-]{1,61}[a-z0-9]$. // ^[a-z][a-z0-9-]{1,61}[a-z0-9]$.
func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) { func (client ManagementClient) CheckDNSNameAvailability(location string, domainNameLabel string) (result DNSNameAvailabilityResult, err error) {
......
...@@ -26,8 +26,8 @@ import ( ...@@ -26,8 +26,8 @@ import (
// ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network // ExpressRouteCircuitAuthorizationsClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with // management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The // Microsoft Azure Networks service to manage your network resources. The API
// API has entities that capture the relationship between an end user and the // has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service. // Microsoft Azure Networks service.
type ExpressRouteCircuitAuthorizationsClient struct { type ExpressRouteCircuitAuthorizationsClient struct {
ManagementClient ManagementClient
...@@ -45,16 +45,15 @@ func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subsc ...@@ -45,16 +45,15 @@ func NewExpressRouteCircuitAuthorizationsClientWithBaseURI(baseURI string, subsc
return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)} return ExpressRouteCircuitAuthorizationsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put Authorization operation creates/updates an // CreateOrUpdate creates or updates an authorization in the specified express
// authorization in thespecified ExpressRouteCircuits This method may poll // route circuit. This method may poll for completion. Polling can be
// for completion. Polling can be canceled by passing the cancel channel // canceled by passing the cancel channel argument. The channel will be used
// argument. The channel will be used to cancel polling and any outstanding // 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 of the express route circuit. authorizationName is the name of the // name 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/update ExpressRouteCircuitAuthorization operation // create 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{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, authorizationName, authorizationParameters, cancel)
if err != nil { if err != nil {
...@@ -118,11 +117,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(re ...@@ -118,11 +117,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) CreateOrUpdateResponder(re
return return
} }
// Delete the delete authorization operation deletes the specified // Delete deletes the specified authorization from the specified express route
// authorization from the specified ExpressRouteCircuit. This method may poll // circuit. This method may poll for completion. Polling can be canceled by
// for completion. Polling can be canceled by passing the cancel channel // passing the cancel channel argument. The channel will be used to cancel
// argument. The channel will be used to cancel polling and any outstanding // 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 of the express route circuit. authorizationName is the name of the // name of the express route circuit. authorizationName is the name of the
...@@ -188,8 +186,8 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeleteResponder(resp *http ...@@ -188,8 +186,8 @@ func (client ExpressRouteCircuitAuthorizationsClient) DeleteResponder(resp *http
return return
} }
// Get the GET authorization operation retrieves the specified authorization // Get gets the specified authorization from the specified express route
// from the specified ExpressRouteCircuit. // circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. authorizationName is the name of the // name of the express route circuit. authorizationName is the name of the
...@@ -254,11 +252,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetResponder(resp *http.Re ...@@ -254,11 +252,10 @@ func (client ExpressRouteCircuitAuthorizationsClient) GetResponder(resp *http.Re
return return
} }
// List the List authorization operation retrieves all the authorizations in // List gets all authorizations in an express route circuit.
// an ExpressRouteCircuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the
// name of the curcuit. // name 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 {
...@@ -322,7 +319,7 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListResponder(resp *http.R ...@@ -322,7 +319,7 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListResponder(resp *http.R
func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResults AuthorizationListResult) (result AuthorizationListResult, err error) { func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResults AuthorizationListResult) (result AuthorizationListResult, err error) {
req, err := lastResults.AuthorizationListResultPreparer() req, err := lastResults.AuthorizationListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -331,12 +328,12 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResult ...@@ -331,12 +328,12 @@ func (client ExpressRouteCircuitAuthorizationsClient) ListNextResults(lastResult
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 next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitAuthorizationsClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -26,8 +26,8 @@ import ( ...@@ -26,8 +26,8 @@ import (
// ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network // ExpressRouteCircuitPeeringsClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with // management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The // Microsoft Azure Networks service to manage your network resources. The API
// API has entities that capture the relationship between an end user and the // has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service. // Microsoft Azure Networks service.
type ExpressRouteCircuitPeeringsClient struct { type ExpressRouteCircuitPeeringsClient struct {
ManagementClient ManagementClient
...@@ -45,15 +45,15 @@ func NewExpressRouteCircuitPeeringsClientWithBaseURI(baseURI string, subscriptio ...@@ -45,15 +45,15 @@ func NewExpressRouteCircuitPeeringsClientWithBaseURI(baseURI string, subscriptio
return ExpressRouteCircuitPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)} return ExpressRouteCircuitPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put Pering operation creates/updates an peering in the // CreateOrUpdate creates or updates a peering in the specified express route
// specified ExpressRouteCircuits This method may poll for completion. // circuits. This method may poll for completion. Polling can be canceled by
// Polling can be canceled by passing the cancel channel argument. The // passing the cancel channel argument. The channel will be used to cancel
// 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 of the express route circuit. peeringName is the name of the peering. // name of the express route circuit. peeringName is the name of the peering.
// peeringParameters is parameters supplied to the create/update // peeringParameters is parameters supplied to the create or update express
// ExpressRouteCircuit 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{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, circuitName, peeringName, peeringParameters, cancel)
if err != nil { if err != nil {
...@@ -117,10 +117,10 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *ht ...@@ -117,10 +117,10 @@ func (client ExpressRouteCircuitPeeringsClient) CreateOrUpdateResponder(resp *ht
return return
} }
// Delete the delete peering operation deletes the specified peering from the // Delete deletes the specified peering from the specified express route
// ExpressRouteCircuit. This method may poll for completion. Polling can be // circuit. 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. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. peeringName is the name of the peering. // name of the express route circuit. peeringName is the name of the peering.
...@@ -185,8 +185,8 @@ func (client ExpressRouteCircuitPeeringsClient) DeleteResponder(resp *http.Respo ...@@ -185,8 +185,8 @@ func (client ExpressRouteCircuitPeeringsClient) DeleteResponder(resp *http.Respo
return return
} }
// Get the GET peering operation retrieves the specified authorization from // Get gets the specified authorization from the specified express route
// the ExpressRouteCircuit. // circuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the
// name of the express route circuit. peeringName is the name of the peering. // name of the express route circuit. peeringName is the name of the peering.
...@@ -250,11 +250,10 @@ func (client ExpressRouteCircuitPeeringsClient) GetResponder(resp *http.Response ...@@ -250,11 +250,10 @@ func (client ExpressRouteCircuitPeeringsClient) GetResponder(resp *http.Response
return return
} }
// List the List peering operation retrieves all the peerings in an // List gets all peerings in a specified express route circuit.
// ExpressRouteCircuit.
// //
// resourceGroupName is the name of the resource group. circuitName is the // resourceGroupName is the name of the resource group. circuitName is the
// name of the curcuit. // name 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 {
...@@ -318,7 +317,7 @@ func (client ExpressRouteCircuitPeeringsClient) ListResponder(resp *http.Respons ...@@ -318,7 +317,7 @@ func (client ExpressRouteCircuitPeeringsClient) ListResponder(resp *http.Respons
func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults ExpressRouteCircuitPeeringListResult) (result ExpressRouteCircuitPeeringListResult, err error) { func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults ExpressRouteCircuitPeeringListResult) (result ExpressRouteCircuitPeeringListResult, err error) {
req, err := lastResults.ExpressRouteCircuitPeeringListResultPreparer() req, err := lastResults.ExpressRouteCircuitPeeringListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -327,12 +326,12 @@ func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults Expr ...@@ -327,12 +326,12 @@ func (client ExpressRouteCircuitPeeringsClient) ListNextResults(lastResults Expr
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 next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.ExpressRouteCircuitPeeringsClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -26,8 +26,8 @@ import ( ...@@ -26,8 +26,8 @@ import (
// ExpressRouteServiceProvidersClient is the the Microsoft Azure Network // ExpressRouteServiceProvidersClient is the the Microsoft Azure Network
// management API provides a RESTful set of web services that interact with // management API provides a RESTful set of web services that interact with
// Microsoft Azure Networks service to manage your network resrources. The // Microsoft Azure Networks service to manage your network resources. The API
// API has entities that capture the relationship between an end user and the // has entities that capture the relationship between an end user and the
// Microsoft Azure Networks service. // Microsoft Azure Networks service.
type ExpressRouteServiceProvidersClient struct { type ExpressRouteServiceProvidersClient struct {
ManagementClient ManagementClient
...@@ -45,8 +45,7 @@ func NewExpressRouteServiceProvidersClientWithBaseURI(baseURI string, subscripti ...@@ -45,8 +45,7 @@ func NewExpressRouteServiceProvidersClientWithBaseURI(baseURI string, subscripti
return ExpressRouteServiceProvidersClient{NewWithBaseURI(baseURI, subscriptionID)} return ExpressRouteServiceProvidersClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// List the List ExpressRouteServiceProvider operation retrieves all the // List gets all the available express route service providers.
// available ExpressRouteServiceProviders.
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 {
...@@ -108,7 +107,7 @@ func (client ExpressRouteServiceProvidersClient) ListResponder(resp *http.Respon ...@@ -108,7 +107,7 @@ func (client ExpressRouteServiceProvidersClient) ListResponder(resp *http.Respon
func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults ExpressRouteServiceProviderListResult) (result ExpressRouteServiceProviderListResult, err error) { func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults ExpressRouteServiceProviderListResult) (result ExpressRouteServiceProviderListResult, err error) {
req, err := lastResults.ExpressRouteServiceProviderListResultPreparer() req, err := lastResults.ExpressRouteServiceProviderListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -117,12 +116,12 @@ func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults Exp ...@@ -117,12 +116,12 @@ func (client ExpressRouteServiceProvidersClient) ListNextResults(lastResults Exp
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 next results request request") return result, autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.ExpressRouteServiceProvidersClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
// LoadBalancersClient is the the Microsoft Azure Network management API // LoadBalancersClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure // provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities // Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure // that capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type LoadBalancersClient struct { type LoadBalancersClient struct {
...@@ -45,14 +45,14 @@ func NewLoadBalancersClientWithBaseURI(baseURI string, subscriptionID string) Lo ...@@ -45,14 +45,14 @@ func NewLoadBalancersClientWithBaseURI(baseURI string, subscriptionID string) Lo
return LoadBalancersClient{NewWithBaseURI(baseURI, subscriptionID)} return LoadBalancersClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put LoadBalancer operation creates/updates a // CreateOrUpdate creates or updates a load balancer. This method may poll for
// LoadBalancer This method may poll for completion. Polling can be canceled // completion. Polling can be canceled by passing the cancel channel
// by passing the cancel channel argument. The channel will be used to cancel // argument. The channel will be used to cancel polling and any outstanding
// polling and any outstanding HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer. parameters is parameters supplied to the // the name of the load balancer. parameters is parameters supplied to the
// create/delete LoadBalancer operation // create 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{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, loadBalancerName, parameters, cancel)
if err != nil { if err != nil {
...@@ -115,13 +115,13 @@ func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) ( ...@@ -115,13 +115,13 @@ func (client LoadBalancersClient) CreateOrUpdateResponder(resp *http.Response) (
return return
} }
// Delete the delete loadbalancer operation deletes the specified // Delete deletes the specified load balancer. This method may poll for
// loadbalancer. This method may poll for completion. Polling can be canceled // completion. Polling can be canceled by passing the cancel channel
// by passing the cancel channel argument. The channel will be used to cancel // argument. The channel will be used to cancel polling and any outstanding
// polling and any outstanding HTTP requests. // HTTP requests.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer. // the 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{}) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel) req, err := client.DeletePreparer(resourceGroupName, loadBalancerName, cancel)
if err != nil { if err != nil {
...@@ -182,11 +182,10 @@ func (client LoadBalancersClient) DeleteResponder(resp *http.Response) (result a ...@@ -182,11 +182,10 @@ func (client LoadBalancersClient) DeleteResponder(resp *http.Response) (result a
return return
} }
// Get the Get ntework interface operation retreives information about the // Get gets the specified load balancer.
// specified network interface.
// //
// resourceGroupName is the name of the resource group. loadBalancerName is // resourceGroupName is the name of the resource group. loadBalancerName is
// the name of the loadBalancer. expand is expand references resources. // the 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 {
...@@ -249,8 +248,7 @@ func (client LoadBalancersClient) GetResponder(resp *http.Response) (result Load ...@@ -249,8 +248,7 @@ func (client LoadBalancersClient) GetResponder(resp *http.Response) (result Load
return return
} }
// List the List loadBalancer operation retrieves all the loadbalancers in a // List gets all the load balancers in a resource group.
// resource group.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) { func (client LoadBalancersClient) List(resourceGroupName string) (result LoadBalancerListResult, err error) {
...@@ -315,7 +313,7 @@ func (client LoadBalancersClient) ListResponder(resp *http.Response) (result Loa ...@@ -315,7 +313,7 @@ func (client LoadBalancersClient) ListResponder(resp *http.Response) (result Loa
func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) { func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) {
req, err := lastResults.LoadBalancerListResultPreparer() req, err := lastResults.LoadBalancerListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -324,19 +322,18 @@ func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListRe ...@@ -324,19 +322,18 @@ func (client LoadBalancersClient) ListNextResults(lastResults LoadBalancerListRe
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 next results request request") return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "List", resp, "Failure responding to next results request")
} }
return return
} }
// ListAll the List loadBalancer operation retrieves all the loadbalancers in // ListAll gets all the load balancers in a subscription.
// a subscription.
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 {
...@@ -398,7 +395,7 @@ func (client LoadBalancersClient) ListAllResponder(resp *http.Response) (result ...@@ -398,7 +395,7 @@ func (client LoadBalancersClient) ListAllResponder(resp *http.Response) (result
func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) { func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerListResult) (result LoadBalancerListResult, err error) {
req, err := lastResults.LoadBalancerListResultPreparer() req, err := lastResults.LoadBalancerListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -407,12 +404,12 @@ func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerLis ...@@ -407,12 +404,12 @@ func (client LoadBalancersClient) ListAllNextResults(lastResults LoadBalancerLis
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 next results request request") return result, autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure sending next results request")
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.LoadBalancersClient", "ListAll", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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"
) )
// LocalNetworkGatewaysClient is the the Microsoft Azure Network management // LocalNetworkGatewaysClient is the the Microsoft Azure Network management
// API provides a RESTful set of web services that interact with Microsoft // API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resrources. The API has // Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the // entities that capture the relationship between an end user and the
// Microsoft Azure Networks service. // Microsoft Azure Networks service.
type LocalNetworkGatewaysClient struct { type LocalNetworkGatewaysClient struct {
...@@ -45,17 +46,25 @@ func NewLocalNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID str ...@@ -45,17 +46,25 @@ func NewLocalNetworkGatewaysClientWithBaseURI(baseURI string, subscriptionID str
return LocalNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)} return LocalNetworkGatewaysClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put LocalNetworkGateway operation creates/updates a // CreateOrUpdate creates or updates a local network gateway in the specified
// local network gateway in the specified resource group through Network // resource group. This method may poll for completion. Polling can be
// resource provider. 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 cancel polling and any outstanding HTTP requests. // to cancel polling and any outstanding HTTP requests.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// localNetworkGatewayName is the name of the local network gateway. // localNetworkGatewayName is the name of the local network gateway.
// parameters is parameters supplied to the Begin Create or update Local // parameters is parameters supplied to the create or update local network
// Network Gateway operation through Network resource provider. // gateway operation.
func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) { func (client LocalNetworkGatewaysClient) CreateOrUpdate(resourceGroupName string, localNetworkGatewayName string, parameters LocalNetworkGateway, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.LocalNetworkGatewayPropertiesFormat.LocalNetworkAddressSpace", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.LocalNetworkGatewayPropertiesFormat.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate")
}
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") return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -117,8 +126,7 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Resp ...@@ -117,8 +126,7 @@ func (client LocalNetworkGatewaysClient) CreateOrUpdateResponder(resp *http.Resp
return return
} }
// Delete the Delete LocalNetworkGateway operation deletes the specifed local // Delete deletes the specified local network gateway. This method may poll
// network Gateway through Network resource provider. This method may poll
// for completion. Polling can be canceled by passing the cancel channel // for completion. Polling can be canceled by passing the cancel channel
// 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.
...@@ -185,8 +193,7 @@ func (client LocalNetworkGatewaysClient) DeleteResponder(resp *http.Response) (r ...@@ -185,8 +193,7 @@ func (client LocalNetworkGatewaysClient) DeleteResponder(resp *http.Response) (r
return return
} }
// Get the Get LocalNetworkGateway operation retrieves information about the // Get gets the specified local network gateway in a resource group.
// specified local network gateway through Network resource provider.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
// localNetworkGatewayName is the name of the local network gateway. // localNetworkGatewayName is the name of the local network gateway.
...@@ -249,8 +256,7 @@ func (client LocalNetworkGatewaysClient) GetResponder(resp *http.Response) (resu ...@@ -249,8 +256,7 @@ func (client LocalNetworkGatewaysClient) GetResponder(resp *http.Response) (resu
return return
} }
// List the List LocalNetworkGateways operation retrieves all the local // List gets all the local network gateways in a resource group.
// network gateways stored.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) { func (client LocalNetworkGatewaysClient) List(resourceGroupName string) (result LocalNetworkGatewayListResult, err error) {
...@@ -315,7 +321,7 @@ func (client LocalNetworkGatewaysClient) ListResponder(resp *http.Response) (res ...@@ -315,7 +321,7 @@ func (client LocalNetworkGatewaysClient) ListResponder(resp *http.Response) (res
func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetworkGatewayListResult) (result LocalNetworkGatewayListResult, err error) { func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetworkGatewayListResult) (result LocalNetworkGatewayListResult, err error) {
req, err := lastResults.LocalNetworkGatewayListResultPreparer() req, err := lastResults.LocalNetworkGatewayListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -324,12 +330,12 @@ func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetwor ...@@ -324,12 +330,12 @@ func (client LocalNetworkGatewaysClient) ListNextResults(lastResults LocalNetwor
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 next results request request") return result, autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.LocalNetworkGatewaysClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
// RoutesClient is the the Microsoft Azure Network management API provides a // RoutesClient is the the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks // RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that // service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure // capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type RoutesClient struct { type RoutesClient struct {
...@@ -43,14 +43,15 @@ func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesCli ...@@ -43,14 +43,15 @@ func NewRoutesClientWithBaseURI(baseURI string, subscriptionID string) RoutesCli
return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)} return RoutesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put route operation creates/updates a route in the // CreateOrUpdate creates or updates a route in the specified route table.
// specified route table This method may poll for completion. Polling can be // This method may poll for completion. Polling can be canceled by passing
// canceled by passing the cancel channel argument. The channel will be used // the cancel channel argument. The channel will be used to cancel polling
// to cancel polling and any outstanding HTTP requests. // 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. routeName is the name of the route. // name of the route table. routeName is the name of the route.
// routeParameters is parameters supplied to the create/update routeoperation // routeParameters is parameters supplied to the create or update route
// operation.
func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (result autorest.Response, err error) { func (client RoutesClient) CreateOrUpdate(resourceGroupName string, routeTableName string, routeName string, routeParameters Route, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, routeTableName, routeName, routeParameters, cancel)
if err != nil { if err != nil {
...@@ -114,10 +115,10 @@ func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result ...@@ -114,10 +115,10 @@ func (client RoutesClient) CreateOrUpdateResponder(resp *http.Response) (result
return return
} }
// Delete the delete route operation deletes the specified route from a route // Delete deletes the specified route from a route table. This method may poll
// table. This method may poll for completion. Polling can be canceled by // for completion. Polling can be canceled by passing the cancel channel
// passing the cancel channel argument. The channel will be used to cancel // argument. The channel will be used to cancel polling and any outstanding
// polling and any outstanding HTTP requests. // 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.
...@@ -182,8 +183,7 @@ func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest ...@@ -182,8 +183,7 @@ func (client RoutesClient) DeleteResponder(resp *http.Response) (result autorest
return return
} }
// Get the Get route operation retreives information about the specified route // Get gets the specified route from a route table.
// from the route table.
// //
// 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.
...@@ -247,8 +247,7 @@ func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err ...@@ -247,8 +247,7 @@ func (client RoutesClient) GetResponder(resp *http.Response) (result Route, err
return return
} }
// List the List network security rule operation retrieves all the routes in a // List gets all routes in a route table.
// route table.
// //
// 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.
...@@ -315,7 +314,7 @@ func (client RoutesClient) ListResponder(resp *http.Response) (result RouteListR ...@@ -315,7 +314,7 @@ func (client RoutesClient) ListResponder(resp *http.Response) (result RouteListR
func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result RouteListResult, err error) { func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result RouteListResult, err error) {
req, err := lastResults.RouteListResultPreparer() req, err := lastResults.RouteListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -324,12 +323,12 @@ func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result ...@@ -324,12 +323,12 @@ func (client RoutesClient) ListNextResults(lastResults RouteListResult) (result
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 next results request request") return result, autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.RoutesClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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 the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure // provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities // Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure // that capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type RouteTablesClient struct { type RouteTablesClient struct {
...@@ -44,15 +45,22 @@ func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) Rout ...@@ -44,15 +45,22 @@ func NewRouteTablesClientWithBaseURI(baseURI string, subscriptionID string) Rout
return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)} return RouteTablesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put RouteTable operation creates/updates a route tablein // CreateOrUpdate create or updates a route table in a specified resource
// the specified resource group. This method may poll for completion. Polling // group. This method may poll for completion. Polling can be canceled by
// can be canceled by passing the cancel channel argument. The channel will // passing the cancel channel argument. The channel will be used to cancel
// be used to cancel 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 // name of the route table. parameters is parameters supplied to the create
// create/update Route Table operation // or 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{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.RouteTablePropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil}}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.RouteTablesClient", "CreateOrUpdate")
}
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") return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -114,10 +122,10 @@ func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (re ...@@ -114,10 +122,10 @@ func (client RouteTablesClient) CreateOrUpdateResponder(resp *http.Response) (re
return return
} }
// Delete the Delete RouteTable operation deletes the specifed Route Table // Delete deletes the specified route table. This method may poll for
// This method may poll for completion. Polling can be canceled by passing // completion. Polling can be canceled by passing the cancel channel
// the cancel channel argument. The channel will be used to cancel polling // argument. The channel will be used to cancel polling and any outstanding
// and any outstanding HTTP requests. // 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. // name of the route table.
...@@ -181,11 +189,10 @@ func (client RouteTablesClient) DeleteResponder(resp *http.Response) (result aut ...@@ -181,11 +189,10 @@ func (client RouteTablesClient) DeleteResponder(resp *http.Response) (result aut
return return
} }
// Get the Get RouteTables operation retrieves information about the specified // Get gets the specified route table.
// route table.
// //
// 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. expand is expand references resources. // name of the route table. expand is expands referenced resources.
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 {
...@@ -248,7 +255,7 @@ func (client RouteTablesClient) GetResponder(resp *http.Response) (result RouteT ...@@ -248,7 +255,7 @@ func (client RouteTablesClient) GetResponder(resp *http.Response) (result RouteT
return return
} }
// List the list RouteTables returns all route tables in a resource group // List gets all route tables in a resource group.
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) { func (client RouteTablesClient) List(resourceGroupName string) (result RouteTableListResult, err error) {
...@@ -313,7 +320,7 @@ func (client RouteTablesClient) ListResponder(resp *http.Response) (result Route ...@@ -313,7 +320,7 @@ func (client RouteTablesClient) ListResponder(resp *http.Response) (result Route
func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) { func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) {
req, err := lastResults.RouteTableListResultPreparer() req, err := lastResults.RouteTableListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -322,18 +329,18 @@ func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult ...@@ -322,18 +329,18 @@ func (client RouteTablesClient) ListNextResults(lastResults RouteTableListResult
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 next results request request") return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "List", resp, "Failure responding to next results request")
} }
return return
} }
// ListAll the list RouteTables returns all route tables in a subscription // ListAll gets all route tables in a subscription.
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 {
...@@ -395,7 +402,7 @@ func (client RouteTablesClient) ListAllResponder(resp *http.Response) (result Ro ...@@ -395,7 +402,7 @@ func (client RouteTablesClient) ListAllResponder(resp *http.Response) (result Ro
func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) { func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListResult) (result RouteTableListResult, err error) {
req, err := lastResults.RouteTableListResultPreparer() req, err := lastResults.RouteTableListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -404,12 +411,12 @@ func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListRes ...@@ -404,12 +411,12 @@ func (client RouteTablesClient) ListAllNextResults(lastResults RouteTableListRes
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 next results request request") return result, autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure sending next results request")
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.RouteTablesClient", "ListAll", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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 the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure // provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities // Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure // that capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type SecurityGroupsClient struct { type SecurityGroupsClient struct {
...@@ -45,17 +46,25 @@ func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) S ...@@ -45,17 +46,25 @@ func NewSecurityGroupsClientWithBaseURI(baseURI string, subscriptionID string) S
return SecurityGroupsClient{NewWithBaseURI(baseURI, subscriptionID)} return SecurityGroupsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put NetworkSecurityGroup operation creates/updates a // CreateOrUpdate creates or updates a network security group in the specified
// network security groupin the specified resource group. This method may // resource group. This method may poll for completion. Polling can be
// poll for completion. Polling can be canceled by passing the cancel channel // canceled by passing the cancel channel argument. The channel will be used
// argument. The channel will be used to cancel polling and any outstanding // to cancel polling and any outstanding HTTP requests.
// 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/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{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "parameters.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SecurityGroupsClient", "CreateOrUpdate")
}
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") return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -117,10 +126,10 @@ func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response) ...@@ -117,10 +126,10 @@ func (client SecurityGroupsClient) CreateOrUpdateResponder(resp *http.Response)
return return
} }
// Delete the Delete NetworkSecurityGroup operation deletes the specifed // Delete deletes the specified network security group. This method may poll
// network security group This method may poll for completion. Polling can be // for completion. Polling can be canceled by passing the cancel channel
// canceled by passing the cancel channel argument. The channel will be used // argument. The channel will be used to cancel polling and any outstanding
// to cancel polling and any outstanding HTTP requests. // 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.
...@@ -184,12 +193,11 @@ func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result ...@@ -184,12 +193,11 @@ func (client SecurityGroupsClient) DeleteResponder(resp *http.Response) (result
return return
} }
// Get the Get NetworkSecurityGroups operation retrieves information about the // Get gets the specified network security group.
// specified network security group.
// //
// 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. expand // networkSecurityGroupName is the name of the network security group. expand
// is expand references resources. // is expands referenced resources.
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 {
...@@ -252,8 +260,7 @@ func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result Sec ...@@ -252,8 +260,7 @@ func (client SecurityGroupsClient) GetResponder(resp *http.Response) (result Sec
return return
} }
// List the list NetworkSecurityGroups returns all network security groups in // List gets all network security groups in a resource group.
// a resource group
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) { func (client SecurityGroupsClient) List(resourceGroupName string) (result SecurityGroupListResult, err error) {
...@@ -318,7 +325,7 @@ func (client SecurityGroupsClient) ListResponder(resp *http.Response) (result Se ...@@ -318,7 +325,7 @@ func (client SecurityGroupsClient) ListResponder(resp *http.Response) (result Se
func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) { func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
req, err := lastResults.SecurityGroupListResultPreparer() req, err := lastResults.SecurityGroupListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -327,19 +334,18 @@ func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupList ...@@ -327,19 +334,18 @@ func (client SecurityGroupsClient) ListNextResults(lastResults SecurityGroupList
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 next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "List", resp, "Failure responding to next results request")
} }
return return
} }
// ListAll the list NetworkSecurityGroups returns all network security groups // ListAll gets all network security groups in a subscription.
// in a subscription
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 {
...@@ -401,7 +407,7 @@ func (client SecurityGroupsClient) ListAllResponder(resp *http.Response) (result ...@@ -401,7 +407,7 @@ func (client SecurityGroupsClient) ListAllResponder(resp *http.Response) (result
func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) { func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupListResult) (result SecurityGroupListResult, err error) {
req, err := lastResults.SecurityGroupListResultPreparer() req, err := lastResults.SecurityGroupListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -410,12 +416,12 @@ func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupL ...@@ -410,12 +416,12 @@ func (client SecurityGroupsClient) ListAllNextResults(lastResults SecurityGroupL
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 next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure sending next results request")
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.SecurityGroupsClient", "ListAll", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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"
) )
// SecurityRulesClient is the the Microsoft Azure Network management API // SecurityRulesClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure // provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities // Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure // that capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type SecurityRulesClient struct { type SecurityRulesClient struct {
...@@ -45,18 +46,26 @@ func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) Se ...@@ -45,18 +46,26 @@ func NewSecurityRulesClientWithBaseURI(baseURI string, subscriptionID string) Se
return SecurityRulesClient{NewWithBaseURI(baseURI, subscriptionID)} return SecurityRulesClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put network security rule operation creates/updates a // CreateOrUpdate creates or updates a security rule in the specified network
// security rule in the specified network security group This method may poll // security group. This method may poll for completion. Polling can be
// for completion. Polling can be canceled by passing the cancel channel // canceled by passing the cancel channel argument. The channel will be used
// argument. The channel will be used to cancel polling and any outstanding // to cancel polling and any outstanding HTTP requests.
// 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 parameters supplied to the create/update network security rule // is 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{}) (result autorest.Response, err error) { func (client SecurityRulesClient) CreateOrUpdate(resourceGroupName string, networkSecurityGroupName string, securityRuleName string, securityRuleParameters SecurityRule, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: securityRuleParameters,
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},
{Target: "securityRuleParameters.SecurityRulePropertiesFormat.DestinationAddressPrefix", Name: validation.Null, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "network.SecurityRulesClient", "CreateOrUpdate")
}
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") return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -119,10 +128,10 @@ func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) ( ...@@ -119,10 +128,10 @@ func (client SecurityRulesClient) CreateOrUpdateResponder(resp *http.Response) (
return return
} }
// Delete the delete network security rule operation deletes the specified // Delete deletes the specified network security rule. This method may poll
// network security rule. This method may poll for completion. Polling can be // for completion. Polling can be canceled by passing the cancel channel
// canceled by passing the cancel channel argument. The channel will be used // argument. The channel will be used to cancel polling and any outstanding
// to cancel polling and any outstanding HTTP requests. // 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.
...@@ -188,8 +197,7 @@ func (client SecurityRulesClient) DeleteResponder(resp *http.Response) (result a ...@@ -188,8 +197,7 @@ func (client SecurityRulesClient) DeleteResponder(resp *http.Response) (result a
return return
} }
// Get the Get NetworkSecurityRule operation retreives information about the // Get get the specified network security rule.
// specified network security rule.
// //
// 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.
...@@ -254,8 +262,7 @@ func (client SecurityRulesClient) GetResponder(resp *http.Response) (result Secu ...@@ -254,8 +262,7 @@ func (client SecurityRulesClient) GetResponder(resp *http.Response) (result Secu
return return
} }
// List the List network security rule operation retrieves all the security // List gets all security rules in a network security group.
// rules in a network security group.
// //
// 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.
...@@ -322,7 +329,7 @@ func (client SecurityRulesClient) ListResponder(resp *http.Response) (result Sec ...@@ -322,7 +329,7 @@ func (client SecurityRulesClient) ListResponder(resp *http.Response) (result Sec
func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListResult) (result SecurityRuleListResult, err error) { func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListResult) (result SecurityRuleListResult, err error) {
req, err := lastResults.SecurityRuleListResultPreparer() req, err := lastResults.SecurityRuleListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -331,12 +338,12 @@ func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListRe ...@@ -331,12 +338,12 @@ func (client SecurityRulesClient) ListNextResults(lastResults SecurityRuleListRe
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 next results request request") return result, autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.SecurityRulesClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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 the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks // RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that // service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure // capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type SubnetsClient struct { type SubnetsClient struct {
...@@ -43,16 +44,34 @@ func NewSubnetsClientWithBaseURI(baseURI string, subscriptionID string) SubnetsC ...@@ -43,16 +44,34 @@ func NewSubnetsClientWithBaseURI(baseURI string, subscriptionID string) SubnetsC
return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)} return SubnetsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put Subnet operation creates/updates a subnet in // CreateOrUpdate creates or updates a subnet in the specified virtual
// thespecified virtual network This method may poll for completion. Polling // network. This method may poll for completion. Polling can be canceled by
// can be canceled by passing the cancel channel argument. The channel will // passing the cancel channel argument. The channel will be used to cancel
// be used 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. 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/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{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: subnetParameters,
Constraints: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.NetworkInterfaces", Name: validation.ReadOnly, Rule: true, Chain: nil},
{Target: "subnetParameters.SubnetPropertiesFormat.NetworkSecurityGroup.SecurityGroupPropertiesFormat.Subnets", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "subnetParameters.SubnetPropertiesFormat.RouteTable", Name: validation.Null, Rule: false,
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") return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "CreateOrUpdate", nil, "Failure preparing request")
...@@ -115,10 +134,9 @@ func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result ...@@ -115,10 +134,9 @@ func (client SubnetsClient) CreateOrUpdateResponder(resp *http.Response) (result
return return
} }
// Delete the delete subnet operation deletes the specified subnet. This // Delete deletes the specified subnet. This method may poll for completion.
// method may poll for completion. Polling can be canceled by passing the // Polling can be canceled by passing the cancel channel argument. The
// cancel channel argument. The channel will be used to cancel polling and // channel will be used to cancel polling and any outstanding HTTP requests.
// 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.
...@@ -183,12 +201,11 @@ func (client SubnetsClient) DeleteResponder(resp *http.Response) (result autores ...@@ -183,12 +201,11 @@ func (client SubnetsClient) DeleteResponder(resp *http.Response) (result autores
return return
} }
// Get the Get subnet operation retreives information about the specified // Get gets the specified subnet by virtual network and resource group.
// subnet.
// //
// 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.
// expand is expand references resources. // expand is expands referenced resources.
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 {
...@@ -252,8 +269,7 @@ func (client SubnetsClient) GetResponder(resp *http.Response) (result Subnet, er ...@@ -252,8 +269,7 @@ func (client SubnetsClient) GetResponder(resp *http.Response) (result Subnet, er
return return
} }
// List the List subnets operation retrieves all the subnets in a virtual // List gets all subnets in a virtual network.
// network.
// //
// 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.
...@@ -320,7 +336,7 @@ func (client SubnetsClient) ListResponder(resp *http.Response) (result SubnetLis ...@@ -320,7 +336,7 @@ func (client SubnetsClient) ListResponder(resp *http.Response) (result SubnetLis
func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (result SubnetListResult, err error) { func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (result SubnetListResult, err error) {
req, err := lastResults.SubnetListResultPreparer() req, err := lastResults.SubnetListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -329,12 +345,12 @@ func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (resul ...@@ -329,12 +345,12 @@ func (client SubnetsClient) ListNextResults(lastResults SubnetListResult) (resul
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 next results request request") return result, autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.SubnetsClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -21,12 +21,13 @@ package network ...@@ -21,12 +21,13 @@ package network
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"
) )
// UsagesClient is the the Microsoft Azure Network management API provides a // UsagesClient is the the Microsoft Azure Network management API provides a
// RESTful set of web services that interact with Microsoft Azure Networks // RESTful set of web services that interact with Microsoft Azure Networks
// service to manage your network resrources. The API has entities that // service to manage your network resources. The API has entities that
// capture the relationship between an end user and the Microsoft Azure // capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type UsagesClient struct { type UsagesClient struct {
...@@ -45,8 +46,14 @@ func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesCli ...@@ -45,8 +46,14 @@ func NewUsagesClientWithBaseURI(baseURI string, subscriptionID string) UsagesCli
// List lists compute usages for a subscription. // List lists compute usages for a subscription.
// //
// location is the location upon which resource usage is queried. // location is the location where resource usage is queried.
func (client UsagesClient) List(location string) (result UsagesListResult, err error) { func (client UsagesClient) List(location string) (result UsagesListResult, 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, "network.UsagesClient", "List")
}
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") return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing request")
...@@ -108,7 +115,7 @@ func (client UsagesClient) ListResponder(resp *http.Response) (result UsagesList ...@@ -108,7 +115,7 @@ func (client UsagesClient) ListResponder(resp *http.Response) (result UsagesList
func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result UsagesListResult, err error) { func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result UsagesListResult, err error) {
req, err := lastResults.UsagesListResultPreparer() req, err := lastResults.UsagesListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -117,12 +124,12 @@ func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result ...@@ -117,12 +124,12 @@ func (client UsagesClient) ListNextResults(lastResults UsagesListResult) (result
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 next results request request") return result, autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.UsagesClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -23,9 +23,9 @@ import ( ...@@ -23,9 +23,9 @@ import (
) )
const ( const (
major = "3" major = "7"
minor = "2" minor = "0"
patch = "0" patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org) // Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta" tag = "-beta"
semVerFormat = "%s.%s.%s%s" semVerFormat = "%s.%s.%s%s"
...@@ -34,7 +34,7 @@ const ( ...@@ -34,7 +34,7 @@ const (
// 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-06-01") return fmt.Sprintf(userAgentFormat, Version(), "network", "2016-09-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.
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
// VirtualNetworkPeeringsClient is the the Microsoft Azure Network management // VirtualNetworkPeeringsClient is the the Microsoft Azure Network management
// API provides a RESTful set of web services that interact with Microsoft // API provides a RESTful set of web services that interact with Microsoft
// Azure Networks service to manage your network resrources. The API has // Azure Networks service to manage your network resources. The API has
// entities that capture the relationship between an end user and the // entities that capture the relationship between an end user and the
// Microsoft Azure Networks service. // Microsoft Azure Networks service.
type VirtualNetworkPeeringsClient struct { type VirtualNetworkPeeringsClient struct {
...@@ -45,16 +45,15 @@ func NewVirtualNetworkPeeringsClientWithBaseURI(baseURI string, subscriptionID s ...@@ -45,16 +45,15 @@ func NewVirtualNetworkPeeringsClientWithBaseURI(baseURI string, subscriptionID s
return VirtualNetworkPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)} return VirtualNetworkPeeringsClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CreateOrUpdate the Put virtual network peering operation creates/updates a // CreateOrUpdate creates or updates a peering in the specified virtual
// peering in the specified virtual network This method may poll for // network. This method may poll for completion. Polling can be canceled by
// completion. Polling can be canceled by passing the cancel channel // passing the cancel channel argument. The channel will be used to cancel
// argument. The channel will be used to cancel polling and any outstanding // polling and any outstanding HTTP requests.
// 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. 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/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{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, virtualNetworkPeeringName, virtualNetworkPeeringParameters, cancel)
if err != nil { if err != nil {
...@@ -118,10 +117,10 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Re ...@@ -118,10 +117,10 @@ func (client VirtualNetworkPeeringsClient) CreateOrUpdateResponder(resp *http.Re
return return
} }
// Delete the delete virtual network peering operation deletes the specified // Delete deletes the specified virtual network peering. This method may poll
// peering. This method may poll for completion. Polling can be canceled by // for completion. Polling can be canceled by passing the cancel channel
// passing the cancel channel argument. The channel will be used to cancel // argument. The channel will be used to cancel polling and any outstanding
// polling and any outstanding HTTP requests. // 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. virtualNetworkPeeringName is the name of // the name of the virtual network. virtualNetworkPeeringName is the name of
...@@ -187,8 +186,7 @@ func (client VirtualNetworkPeeringsClient) DeleteResponder(resp *http.Response) ...@@ -187,8 +186,7 @@ func (client VirtualNetworkPeeringsClient) DeleteResponder(resp *http.Response)
return return
} }
// Get the Get virtual network peering operation retreives information about // Get gets the specified virtual network peering.
// the specified virtual network peering.
// //
// 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
...@@ -253,8 +251,7 @@ func (client VirtualNetworkPeeringsClient) GetResponder(resp *http.Response) (re ...@@ -253,8 +251,7 @@ func (client VirtualNetworkPeeringsClient) GetResponder(resp *http.Response) (re
return return
} }
// List the List virtual network peerings operation retrieves all the peerings // List gets all virtual network peerings in a virtual network.
// in a virtual network.
// //
// 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.
...@@ -321,7 +318,7 @@ func (client VirtualNetworkPeeringsClient) ListResponder(resp *http.Response) (r ...@@ -321,7 +318,7 @@ func (client VirtualNetworkPeeringsClient) ListResponder(resp *http.Response) (r
func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNetworkPeeringListResult) (result VirtualNetworkPeeringListResult, err error) { func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNetworkPeeringListResult) (result VirtualNetworkPeeringListResult, err error) {
req, err := lastResults.VirtualNetworkPeeringListResultPreparer() req, err := lastResults.VirtualNetworkPeeringListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -330,12 +327,12 @@ func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNe ...@@ -330,12 +327,12 @@ func (client VirtualNetworkPeeringsClient) ListNextResults(lastResults VirtualNe
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 next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.VirtualNetworkPeeringsClient", "List", resp, "Failure responding to next results request")
} }
return return
......
...@@ -26,7 +26,7 @@ import ( ...@@ -26,7 +26,7 @@ import (
// VirtualNetworksClient is the the Microsoft Azure Network management API // VirtualNetworksClient is the the Microsoft Azure Network management API
// provides a RESTful set of web services that interact with Microsoft Azure // provides a RESTful set of web services that interact with Microsoft Azure
// Networks service to manage your network resrources. The API has entities // Networks service to manage your network resources. The API has entities
// that capture the relationship between an end user and the Microsoft Azure // that capture the relationship between an end user and the Microsoft Azure
// Networks service. // Networks service.
type VirtualNetworksClient struct { type VirtualNetworksClient struct {
...@@ -45,7 +45,7 @@ func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string) ...@@ -45,7 +45,7 @@ func NewVirtualNetworksClientWithBaseURI(baseURI string, subscriptionID string)
return VirtualNetworksClient{NewWithBaseURI(baseURI, subscriptionID)} return VirtualNetworksClient{NewWithBaseURI(baseURI, subscriptionID)}
} }
// CheckIPAddressAvailability checks whether a private Ip address is available // CheckIPAddressAvailability checks whether a private IP address is available
// for use. // for use.
// //
// resourceGroupName is the name of the resource group. virtualNetworkName is // resourceGroupName is the name of the resource group. virtualNetworkName is
...@@ -113,15 +113,14 @@ func (client VirtualNetworksClient) CheckIPAddressAvailabilityResponder(resp *ht ...@@ -113,15 +113,14 @@ func (client VirtualNetworksClient) CheckIPAddressAvailabilityResponder(resp *ht
return return
} }
// CreateOrUpdate the Put VirtualNetwork operation creates/updates a virtual // CreateOrUpdate creates or updates a virtual network in the specified
// network in the specified resource group. This method may poll for // resource group. This method may poll for completion. Polling can be
// completion. Polling can be canceled by passing the cancel channel // canceled by passing the cancel channel argument. The channel will be used
// argument. The channel will be used to cancel polling and any outstanding // to cancel polling and any outstanding HTTP requests.
// 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/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{}) (result autorest.Response, err error) {
req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel) req, err := client.CreateOrUpdatePreparer(resourceGroupName, virtualNetworkName, parameters, cancel)
if err != nil { if err != nil {
...@@ -184,10 +183,10 @@ func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response) ...@@ -184,10 +183,10 @@ func (client VirtualNetworksClient) CreateOrUpdateResponder(resp *http.Response)
return return
} }
// Delete the Delete VirtualNetwork operation deletes the specifed virtual // Delete deletes the specified virtual network. This method may poll for
// network This method may poll for completion. Polling can be canceled by // completion. Polling can be canceled by passing the cancel channel
// passing the cancel channel argument. The channel will be used to cancel // argument. The channel will be used to cancel polling and any outstanding
// polling and any outstanding HTTP requests. // 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. // the name of the virtual network.
...@@ -251,11 +250,10 @@ func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result ...@@ -251,11 +250,10 @@ func (client VirtualNetworksClient) DeleteResponder(resp *http.Response) (result
return return
} }
// Get the Get VirtualNetwork operation retrieves information about the // Get gets the specified virtual network by resource group.
// specified virtual network.
// //
// 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. expand is expand references resources. // the name of the virtual network. expand is expands referenced resources.
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 {
...@@ -318,8 +316,7 @@ func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result Vi ...@@ -318,8 +316,7 @@ func (client VirtualNetworksClient) GetResponder(resp *http.Response) (result Vi
return return
} }
// List the list VirtualNetwork returns all Virtual Networks in a resource // List gets all virtual networks in a resource group.
// group
// //
// resourceGroupName is the name of the resource group. // resourceGroupName is the name of the resource group.
func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) { func (client VirtualNetworksClient) List(resourceGroupName string) (result VirtualNetworkListResult, err error) {
...@@ -384,7 +381,7 @@ func (client VirtualNetworksClient) ListResponder(resp *http.Response) (result V ...@@ -384,7 +381,7 @@ func (client VirtualNetworksClient) ListResponder(resp *http.Response) (result V
func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) { func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) {
req, err := lastResults.VirtualNetworkListResultPreparer() req, err := lastResults.VirtualNetworkListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -393,19 +390,18 @@ func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkLi ...@@ -393,19 +390,18 @@ func (client VirtualNetworksClient) ListNextResults(lastResults VirtualNetworkLi
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 next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure sending next results request")
} }
result, err = client.ListResponder(resp) result, err = client.ListResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "List", resp, "Failure responding to next results request")
} }
return return
} }
// ListAll the list VirtualNetwork returns all Virtual Networks in a // ListAll gets all virtual networks in a subscription.
// subscription
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 {
...@@ -467,7 +463,7 @@ func (client VirtualNetworksClient) ListAllResponder(resp *http.Response) (resul ...@@ -467,7 +463,7 @@ func (client VirtualNetworksClient) ListAllResponder(resp *http.Response) (resul
func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) { func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetworkListResult) (result VirtualNetworkListResult, err error) {
req, err := lastResults.VirtualNetworkListResultPreparer() req, err := lastResults.VirtualNetworkListResultPreparer()
if err != nil { if err != nil {
return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", nil, "Failure preparing next results request")
} }
if req == nil { if req == nil {
return return
...@@ -476,12 +472,12 @@ func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetwor ...@@ -476,12 +472,12 @@ func (client VirtualNetworksClient) ListAllNextResults(lastResults VirtualNetwor
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 next results request request") return result, autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure sending next results request")
} }
result, err = client.ListAllResponder(resp) result, err = client.ListAllResponder(resp)
if err != nil { if err != nil {
err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure responding to next results request request") err = autorest.NewErrorWithError(err, "network.VirtualNetworksClient", "ListAll", resp, "Failure responding to next results request")
} }
return return
......
...@@ -131,15 +131,15 @@ const ( ...@@ -131,15 +131,15 @@ const (
// Account is the storage account. // Account is the storage account.
type Account struct { type Account struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
ID *string `json:"id,omitempty"` ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"` Name *string `json:"name,omitempty"`
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"` Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"` Kind Kind `json:"kind,omitempty"`
Properties *AccountProperties `json:"properties,omitempty"` *AccountProperties `json:"properties,omitempty"`
} }
// AccountCheckNameAvailabilityParameters is // AccountCheckNameAvailabilityParameters is
...@@ -148,13 +148,14 @@ type AccountCheckNameAvailabilityParameters struct { ...@@ -148,13 +148,14 @@ type AccountCheckNameAvailabilityParameters struct {
Type *string `json:"type,omitempty"` Type *string `json:"type,omitempty"`
} }
// AccountCreateParameters is the parameters to provide for the account. // AccountCreateParameters is the parameters used when creating a storage
// account.
type AccountCreateParameters struct { type AccountCreateParameters struct {
Sku *Sku `json:"sku,omitempty"` Sku *Sku `json:"sku,omitempty"`
Kind Kind `json:"kind,omitempty"` Kind Kind `json:"kind,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"`
Properties *AccountPropertiesCreateParameters `json:"properties,omitempty"` *AccountPropertiesCreateParameters `json:"properties,omitempty"`
} }
// AccountKey is an access key for the storage account. // AccountKey is an access key for the storage account.
...@@ -164,13 +165,13 @@ type AccountKey struct { ...@@ -164,13 +165,13 @@ type AccountKey struct {
Permissions KeyPermission `json:"permissions,omitempty"` Permissions KeyPermission `json:"permissions,omitempty"`
} }
// AccountListKeysResult is the ListKeys operation response. // AccountListKeysResult is the response from the ListKeys operation.
type AccountListKeysResult struct { type AccountListKeysResult struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
Keys *[]AccountKey `json:"keys,omitempty"` Keys *[]AccountKey `json:"keys,omitempty"`
} }
// AccountListResult is the list storage accounts operation response. // AccountListResult is the response from the List Storage Accounts operation.
type AccountListResult struct { type AccountListResult struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
Value *[]Account `json:"value,omitempty"` Value *[]Account `json:"value,omitempty"`
...@@ -211,11 +212,12 @@ type AccountRegenerateKeyParameters struct { ...@@ -211,11 +212,12 @@ type AccountRegenerateKeyParameters struct {
KeyName *string `json:"keyName,omitempty"` KeyName *string `json:"keyName,omitempty"`
} }
// AccountUpdateParameters is the parameters to provide for the account. // 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"`
Properties *AccountPropertiesUpdateParameters `json:"properties,omitempty"` *AccountPropertiesUpdateParameters `json:"properties,omitempty"`
} }
// CheckNameAvailabilityResult is the CheckNameAvailability operation response. // CheckNameAvailabilityResult is the CheckNameAvailability operation response.
...@@ -233,25 +235,26 @@ type CustomDomain struct { ...@@ -233,25 +235,26 @@ type CustomDomain struct {
UseSubDomain *bool `json:"useSubDomain,omitempty"` UseSubDomain *bool `json:"useSubDomain,omitempty"`
} }
// Encryption is the encryption settings on the account. // Encryption is the encryption settings on the storage account.
type Encryption struct { type Encryption struct {
Services *EncryptionServices `json:"services,omitempty"` Services *EncryptionServices `json:"services,omitempty"`
KeySource *string `json:"keySource,omitempty"` KeySource *string `json:"keySource,omitempty"`
} }
// EncryptionService is an encrypted service. // EncryptionService is a service that allows server-side encryption to be
// used.
type EncryptionService struct { type EncryptionService struct {
Enabled *bool `json:"enabled,omitempty"` Enabled *bool `json:"enabled,omitempty"`
LastEnabledTime *date.Time `json:"lastEnabledTime,omitempty"` LastEnabledTime *date.Time `json:"lastEnabledTime,omitempty"`
} }
// EncryptionServices is the encrypted services. // 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"`
} }
// 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, queue or table object. // blob, 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"`
...@@ -282,13 +285,14 @@ type Usage struct { ...@@ -282,13 +285,14 @@ type Usage struct {
Name *UsageName `json:"name,omitempty"` Name *UsageName `json:"name,omitempty"`
} }
// UsageListResult is the List Usages operation response. // UsageListResult is the response from the List Usages operation.
type UsageListResult struct { type UsageListResult struct {
autorest.Response `json:"-"` autorest.Response `json:"-"`
Value *[]Usage `json:"value,omitempty"` Value *[]Usage `json:"value,omitempty"`
} }
// UsageName is the Usage Names. // UsageName is the usage names that can be used; currently limited to
// StorageAccount.
type UsageName struct { type UsageName struct {
Value *string `json:"value,omitempty"` Value *string `json:"value,omitempty"`
LocalizedValue *string `json:"localizedValue,omitempty"` LocalizedValue *string `json:"localizedValue,omitempty"`
......
...@@ -23,9 +23,9 @@ import ( ...@@ -23,9 +23,9 @@ import (
) )
const ( const (
major = "3" major = "7"
minor = "2" minor = "0"
patch = "0" patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org) // Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta" tag = "-beta"
semVerFormat = "%s.%s.%s%s" semVerFormat = "%s.%s.%s%s"
......
# 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/)
\ No newline at end of file
...@@ -128,6 +128,7 @@ func NewBasicClient(accountName, accountKey string) (Client, error) { ...@@ -128,6 +128,7 @@ 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)
} }
//NewEmulatorClient contructs a Client intended to only work with Azure //NewEmulatorClient contructs a Client intended to only work with Azure
...@@ -305,7 +306,7 @@ func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) { ...@@ -305,7 +306,7 @@ func (c Client) buildCanonicalizedResourceTable(uri string) (string, error) {
cr := "/" + c.getCanonicalizedAccountName() cr := "/" + c.getCanonicalizedAccountName()
if len(u.Path) > 0 { if len(u.Path) > 0 {
cr += u.Path cr += u.EscapedPath()
} }
return cr, nil return cr, nil
......
...@@ -82,6 +82,24 @@ func (p PeekMessagesParameters) getParameters() url.Values { ...@@ -82,6 +82,24 @@ func (p PeekMessagesParameters) getParameters() url.Values {
return out 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 // GetMessagesResponse represents a response returned from Get Messages
// operation. // operation.
type GetMessagesResponse struct { type GetMessagesResponse struct {
...@@ -304,3 +322,23 @@ func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) e ...@@ -304,3 +322,23 @@ func (c QueueServiceClient) DeleteMessage(queue, messageID, popReceipt string) e
defer resp.body.Close() defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent}) return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
} }
// UpdateMessage operation deletes the specified message.
//
// See https://msdn.microsoft.com/en-us/library/azure/hh452234.aspx
func (c QueueServiceClient) UpdateMessage(queue string, messageID string, message string, params UpdateMessageParameters) error {
uri := c.client.getEndpoint(queueServiceName, pathForMessage(queue, messageID), params.getParameters())
req := putMessageRequest{MessageText: message}
body, nn, err := xmlMarshal(req)
if err != nil {
return err
}
headers := c.client.getStandardHeaders()
headers["Content-Length"] = fmt.Sprintf("%d", nn)
resp, err := c.client.exec("PUT", uri, headers, body)
if err != nil {
return err
}
defer resp.body.Close()
return checkRespCode(resp.statusCode, []int{http.StatusNoContent})
}
...@@ -10,6 +10,8 @@ import ( ...@@ -10,6 +10,8 @@ import (
"reflect" "reflect"
) )
// Annotating as secure for gas scanning
/* #nosec */
const ( const (
partitionKeyNode = "PartitionKey" partitionKeyNode = "PartitionKey"
rowKeyNode = "RowKey" rowKeyNode = "RowKey"
...@@ -98,6 +100,10 @@ func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousCo ...@@ -98,6 +100,10 @@ func (c *TableServiceClient) QueryTableEntities(tableName AzureTable, previousCo
resp, err := c.client.execTable("GET", uri, headers, nil) resp, err := c.client.execTable("GET", uri, headers, nil)
if err != nil {
return nil, nil, err
}
contToken := extractContinuationTokenFromHeaders(resp.headers) contToken := extractContinuationTokenFromHeaders(resp.headers)
if err != nil { if err != nil {
......
...@@ -77,7 +77,7 @@ func headersFromStruct(v interface{}) map[string]string { ...@@ -77,7 +77,7 @@ func headersFromStruct(v interface{}) map[string]string {
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() val := value.Field(i).String()
if val != "" { if key != "" && val != "" {
headers[key] = val headers[key] = val
} }
} }
......
...@@ -7,3 +7,6 @@ For example the parser might receive "ESC, [, A" as a stream of three characters ...@@ -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.
...@@ -124,32 +124,32 @@ func getByteRange(start byte, end byte) []byte { ...@@ -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
......
package ansiterm package ansiterm
type AnsiContext struct { type ansiContext struct {
currentChar byte currentChar byte
paramBuffer []byte paramBuffer []byte
interBuffer []byte interBuffer []byte
......
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 { ...@@ -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
} }
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()
} }
......
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()
} }
......
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
} }
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()
} }
......
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
......
...@@ -2,7 +2,6 @@ package ansiterm ...@@ -2,7 +2,6 @@ package ansiterm
import ( import (
"errors" "errors"
"fmt"
"io/ioutil" "io/ioutil"
"os" "os"
...@@ -12,18 +11,18 @@ import ( ...@@ -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 ...@@ -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 ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -31,7 +31,7 @@ func parseParams(bytes []byte) ([]string, error) { ...@@ -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
} }
......
...@@ -113,7 +113,7 @@ func (ap *AnsiParser) print() error { ...@@ -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
} }
......
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)
}
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)
}
}
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 { ...@@ -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
} }
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
}
...@@ -9,7 +9,7 @@ import ( ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 {
......
...@@ -66,21 +66,21 @@ const ( ...@@ -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 ( ...@@ -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 ( ...@@ -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 { ...@@ -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 ...@@ -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 { ...@@ -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.
......
...@@ -2,9 +2,7 @@ ...@@ -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 ( ...@@ -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 ...@@ -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)
} }
...@@ -3,11 +3,11 @@ ...@@ -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 ...@@ -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 ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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
......
...@@ -2,11 +2,9 @@ ...@@ -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 ...@@ -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 ...@@ -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
} }
......
...@@ -3,9 +3,9 @@ ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 ...@@ -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 ...@@ -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 { ...@@ -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 * ...@@ -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,
} }
......
...@@ -4,6 +4,6 @@ package winterm ...@@ -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)
} }
...@@ -91,7 +91,7 @@ type ServicePrincipalNoSecret struct { ...@@ -91,7 +91,7 @@ type ServicePrincipalNoSecret struct {
// SetAuthenticationValues is a method of the interface ServicePrincipalSecret // SetAuthenticationValues is a method of the interface ServicePrincipalSecret
// It only returns an error for the ServicePrincipalNoSecret type // It only returns an error for the ServicePrincipalNoSecret type
func (noSecret *ServicePrincipalNoSecret) SetAuthenticationValues(spt *ServicePrincipalToken, v *url.Values) error { 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.") 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 // ServicePrincipalSecret is an interface that allows various secret mechanism to fill the form
...@@ -138,7 +138,7 @@ func (secret *ServicePrincipalCertificateSecret) SignJwt(spt *ServicePrincipalTo ...@@ -138,7 +138,7 @@ func (secret *ServicePrincipalCertificateSecret) SignJwt(spt *ServicePrincipalTo
token := jwt.New(jwt.SigningMethodRS256) token := jwt.New(jwt.SigningMethodRS256)
token.Header["x5t"] = thumbprint token.Header["x5t"] = thumbprint
token.Claims = jwt.MapClaims{ token.Claims = jwt.MapClaims{
"aud": spt.oauthConfig.TokenEndpoint, "aud": spt.oauthConfig.TokenEndpoint.String(),
"iss": spt.clientID, "iss": spt.clientID,
"sub": spt.clientID, "sub": spt.clientID,
"jti": base64.URLEncoding.EncodeToString(jti), "jti": base64.URLEncoding.EncodeToString(jti),
......
...@@ -20,9 +20,6 @@ const ( ...@@ -20,9 +20,6 @@ const (
// DefaultRetryAttempts is number of attempts for retry status codes (5xx). // DefaultRetryAttempts is number of attempts for retry status codes (5xx).
DefaultRetryAttempts = 3 DefaultRetryAttempts = 3
// DefaultRetryDuration is a resonable delay for retry.
defaultRetryInterval = 30 * time.Second
) )
var statusCodesForRetry = []int{ var statusCodesForRetry = []int{
...@@ -130,6 +127,9 @@ type Client struct { ...@@ -130,6 +127,9 @@ type Client struct {
// RetryAttempts sets the default number of retry attempts for client. // RetryAttempts sets the default number of retry attempts for client.
RetryAttempts int RetryAttempts int
// RetryDuration sets the delay duration for retries.
RetryDuration time.Duration
// UserAgent, if not empty, will be set as the HTTP User-Agent header on all requests sent // UserAgent, if not empty, will be set as the HTTP User-Agent header on all requests sent
// through the Do method. // through the Do method.
UserAgent string UserAgent string
...@@ -144,6 +144,7 @@ func NewClientWithUserAgent(ua string) Client { ...@@ -144,6 +144,7 @@ func NewClientWithUserAgent(ua string) Client {
PollingDelay: DefaultPollingDelay, PollingDelay: DefaultPollingDelay,
PollingDuration: DefaultPollingDuration, PollingDuration: DefaultPollingDuration,
RetryAttempts: DefaultRetryAttempts, RetryAttempts: DefaultRetryAttempts,
RetryDuration: 30 * time.Second,
UserAgent: ua, UserAgent: ua,
} }
} }
...@@ -163,7 +164,7 @@ func (c Client) Do(r *http.Request) (*http.Response, error) { ...@@ -163,7 +164,7 @@ func (c Client) Do(r *http.Request) (*http.Response, error) {
return nil, NewErrorWithError(err, "autorest/Client", "Do", nil, "Preparing request failed") return nil, NewErrorWithError(err, "autorest/Client", "Do", nil, "Preparing request failed")
} }
resp, err := SendWithSender(c.sender(), r, resp, err := SendWithSender(c.sender(), r,
DoRetryForStatusCodes(c.RetryAttempts, defaultRetryInterval, statusCodesForRetry...)) DoRetryForStatusCodes(c.RetryAttempts, c.RetryDuration, statusCodesForRetry...))
Respond(resp, Respond(resp,
c.ByInspecting()) c.ByInspecting())
return resp, err return resp, err
......
package date package date
import ( import (
"regexp"
"time" "time"
) )
// Azure reports time in UTC but it doesn't include the 'Z' time zone suffix in some cases.
const ( const (
rfc3339JSON = `"` + time.RFC3339Nano + `"` azureUtcFormatJSON = `"2006-01-02T15:04:05.999999999"`
rfc3339 = time.RFC3339Nano azureUtcFormat = "2006-01-02T15:04:05.999999999"
rfc3339JSON = `"` + time.RFC3339Nano + `"`
rfc3339 = time.RFC3339Nano
tzOffsetRegex = `(Z|z|\+|-)(\d+:\d+)*"*$`
) )
// Time defines a type similar to time.Time but assumes a layout of RFC3339 date-time (i.e., // Time defines a type similar to time.Time but assumes a layout of RFC3339 date-time (i.e.,
...@@ -36,7 +41,14 @@ func (t Time) MarshalJSON() (json []byte, err error) { ...@@ -36,7 +41,14 @@ func (t Time) MarshalJSON() (json []byte, err error) {
// UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC3339 date-time // UnmarshalJSON reconstitutes the Time from a JSON string conforming to RFC3339 date-time
// (i.e., 2006-01-02T15:04:05Z). // (i.e., 2006-01-02T15:04:05Z).
func (t *Time) UnmarshalJSON(data []byte) (err error) { func (t *Time) UnmarshalJSON(data []byte) (err error) {
t.Time, err = ParseTime(rfc3339JSON, string(data)) timeFormat := azureUtcFormatJSON
match, err := regexp.Match(tzOffsetRegex, data)
if err != nil {
return err
} else if match {
timeFormat = rfc3339JSON
}
t.Time, err = ParseTime(timeFormat, string(data))
return err return err
} }
...@@ -49,7 +61,14 @@ func (t Time) MarshalText() (text []byte, err error) { ...@@ -49,7 +61,14 @@ func (t Time) MarshalText() (text []byte, err error) {
// UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC3339 date-time // UnmarshalText reconstitutes a Time saved as a byte array conforming to RFC3339 date-time
// (i.e., 2006-01-02T15:04:05Z). // (i.e., 2006-01-02T15:04:05Z).
func (t *Time) UnmarshalText(data []byte) (err error) { func (t *Time) UnmarshalText(data []byte) (err error) {
t.Time, err = ParseTime(rfc3339, string(data)) timeFormat := azureUtcFormat
match, err := regexp.Match(tzOffsetRegex, data)
if err != nil {
return err
} else if match {
timeFormat = rfc3339
}
t.Time, err = ParseTime(timeFormat, string(data))
return err return err
} }
......
...@@ -4,7 +4,9 @@ import ( ...@@ -4,7 +4,9 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io"
"io/ioutil" "io/ioutil"
"mime/multipart"
"net/http" "net/http"
"net/url" "net/url"
"strings" "strings"
...@@ -197,6 +199,64 @@ func WithFormData(v url.Values) PrepareDecorator { ...@@ -197,6 +199,64 @@ func WithFormData(v url.Values) PrepareDecorator {
} }
} }
// WithMultiPartFormData returns a PrepareDecoratore that "URL encodes" (e.g., bar=baz&foo=quux) form parameters
// into the http.Request body.
func WithMultiPartFormData(formDataParameters map[string]interface{}) PrepareDecorator {
return func(p Preparer) Preparer {
return PreparerFunc(func(r *http.Request) (*http.Request, error) {
r, err := p.Prepare(r)
if err == nil {
var body bytes.Buffer
writer := multipart.NewWriter(&body)
for key, value := range formDataParameters {
if rc, ok := value.(io.ReadCloser); ok {
var fd io.Writer
if fd, err = writer.CreateFormFile(key, key); err != nil {
return r, err
}
if _, err = io.Copy(fd, rc); err != nil {
return r, err
}
} else {
if err = writer.WriteField(key, ensureValueString(value)); err != nil {
return r, err
}
}
}
if err = writer.Close(); err != nil {
return r, err
}
if r.Header == nil {
r.Header = make(http.Header)
}
r.Header.Set(http.CanonicalHeaderKey(headerContentType), writer.FormDataContentType())
r.Body = ioutil.NopCloser(bytes.NewReader(body.Bytes()))
r.ContentLength = int64(body.Len())
return r, err
}
return r, err
})
}
}
// WithFile returns a PrepareDecorator that sends file in request body.
func WithFile(f io.ReadCloser) PrepareDecorator {
return func(p Preparer) Preparer {
return PreparerFunc(func(r *http.Request) (*http.Request, error) {
r, err := p.Prepare(r)
if err == nil {
b, err := ioutil.ReadAll(f)
if err != nil {
return r, err
}
r.Body = ioutil.NopCloser(bytes.NewReader(b))
r.ContentLength = int64(len(b))
}
return r, err
})
}
}
// WithBool returns a PrepareDecorator that encodes the passed bool into the body of the request // WithBool returns a PrepareDecorator that encodes the passed bool into the body of the request
// and sets the Content-Length header. // and sets the Content-Length header.
func WithBool(v bool) PrepareDecorator { func WithBool(v bool) PrepareDecorator {
......
...@@ -7,6 +7,7 @@ import ( ...@@ -7,6 +7,7 @@ import (
"fmt" "fmt"
"io" "io"
"net/url" "net/url"
"reflect"
"sort" "sort"
"strings" "strings"
) )
...@@ -106,6 +107,22 @@ func ensureValueString(value interface{}) string { ...@@ -106,6 +107,22 @@ func ensureValueString(value interface{}) string {
} }
} }
// MapToValues method converts map[string]interface{} to url.Values.
func MapToValues(m map[string]interface{}) url.Values {
v := url.Values{}
for key, value := range m {
x := reflect.ValueOf(value)
if x.Kind() == reflect.Array || x.Kind() == reflect.Slice {
for i := 0; i < x.Len(); i++ {
v.Add(key, ensureValueString(x.Index(i)))
}
} else {
v.Add(key, ensureValueString(value))
}
}
return v
}
// String method converts interface v to string. If interface is a list, it // String method converts interface v to string. If interface is a list, it
// joins list elements using separator. // joins list elements using separator.
func String(v interface{}, sep ...string) string { func String(v interface{}, sep ...string) string {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment