From 7a03f40ee7c5a7028677d67fccdbced275ceb267 Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 2 Feb 2021 14:29:27 -0600 Subject: [PATCH 01/15] Upgrade signalr package to use 2020-05-01 --- .../services/signalr/client/client.go | 2 +- .../signalr/signalr_service_resource.go | 2 +- .../mgmt/2018-10-01/signalr/CHANGELOG.md | 5 - .../mgmt/2020-05-01/signalr/CHANGELOG.md | 9 + .../signalr/client.go | 2 +- .../signalr/enums.go | 70 ++- .../signalr/models.go | 554 +++++++++++++++--- .../signalr/operations.go | 2 +- .../signalr/privateendpointconnections.go | 287 +++++++++ .../signalr/privatelinkresources.go | 162 +++++ .../signalr/signalr.go | 40 +- .../signalr/usages.go | 2 +- .../signalr/version.go | 2 +- vendor/modules.txt | 2 +- 14 files changed, 1042 insertions(+), 99 deletions(-) delete mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/CHANGELOG.md create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/client.go (98%) rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/enums.go (56%) rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/models.go (65%) rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/operations.go (99%) create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go create mode 100644 vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/signalr.go (97%) rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/usages.go (99%) rename vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/{2018-10-01 => 2020-05-01}/signalr/version.go (94%) diff --git a/azurerm/internal/services/signalr/client/client.go b/azurerm/internal/services/signalr/client/client.go index 9f9aa2479c56..33748e7e3315 100644 --- a/azurerm/internal/services/signalr/client/client.go +++ b/azurerm/internal/services/signalr/client/client.go @@ -1,7 +1,7 @@ package client import ( - "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr" + "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/common" ) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index 02865d7211d7..bd9bfd8a59b9 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -5,7 +5,7 @@ import ( "log" "time" - "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr" + "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr" "github.com/hashicorp/go-azure-helpers/response" "github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/helper/validation" diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/CHANGELOG.md deleted file mode 100644 index 77a0c543711b..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/CHANGELOG.md +++ /dev/null @@ -1,5 +0,0 @@ -Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82//specification/signalr/resource-manager/readme.md tag: `package-2018-10-01` - -Code generator @microsoft.azure/autorest.go@2.1.171 - - diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md new file mode 100644 index 000000000000..2df7a3c94f21 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md @@ -0,0 +1,9 @@ +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82//specification/signalr/resource-manager/readme.md tag: `package-2018-10-01` + +Code generator @microsoft.azure/autorest.go@2.1.171 + + +- Function `NewPrivateLinkResourceListPage` parameter(s) have been changed from `(func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error))` to `(PrivateLinkResourceList, func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error))` +- Function `NewOperationListPage` parameter(s) have been changed from `(func(context.Context, OperationList) (OperationList, error))` to `(OperationList, func(context.Context, OperationList) (OperationList, error))` +- Function `NewUsageListPage` parameter(s) have been changed from `(func(context.Context, UsageList) (UsageList, error))` to `(UsageList, func(context.Context, UsageList) (UsageList, error))` +- Function `NewResourceListPage` parameter(s) have been changed from `(func(context.Context, ResourceList) (ResourceList, error))` to `(ResourceList, func(context.Context, ResourceList) (ResourceList, error))` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/client.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/client.go index 636149b898a0..7d615b08f13c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/client.go @@ -1,4 +1,4 @@ -// Package signalr implements the Azure ARM Signalr service API version 2018-10-01. +// Package signalr implements the Azure ARM Signalr service API version 2020-05-01. // // REST API for Azure SignalR Service package signalr diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/enums.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/enums.go similarity index 56% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/enums.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/enums.go index 773a92aaf1bf..241d6ab1b914 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/enums.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/enums.go @@ -17,19 +17,36 @@ package signalr // Code generated by Microsoft (R) AutoRest Code Generator. // Changes may cause incorrect behavior and will be lost if the code is regenerated. +// ACLAction enumerates the values for acl action. +type ACLAction string + +const ( + // Allow ... + Allow ACLAction = "Allow" + // Deny ... + Deny ACLAction = "Deny" +) + +// PossibleACLActionValues returns an array of possible values for the ACLAction const type. +func PossibleACLActionValues() []ACLAction { + return []ACLAction{Allow, Deny} +} + // FeatureFlags enumerates the values for feature flags. type FeatureFlags string const ( // EnableConnectivityLogs ... EnableConnectivityLogs FeatureFlags = "EnableConnectivityLogs" + // EnableMessagingLogs ... + EnableMessagingLogs FeatureFlags = "EnableMessagingLogs" // ServiceMode ... ServiceMode FeatureFlags = "ServiceMode" ) // PossibleFeatureFlagsValues returns an array of possible values for the FeatureFlags const type. func PossibleFeatureFlagsValues() []FeatureFlags { - return []FeatureFlags{EnableConnectivityLogs, ServiceMode} + return []FeatureFlags{EnableConnectivityLogs, EnableMessagingLogs, ServiceMode} } // KeyType enumerates the values for key type. @@ -47,6 +64,25 @@ func PossibleKeyTypeValues() []KeyType { return []KeyType{Primary, Secondary} } +// PrivateLinkServiceConnectionStatus enumerates the values for private link service connection status. +type PrivateLinkServiceConnectionStatus string + +const ( + // Approved ... + Approved PrivateLinkServiceConnectionStatus = "Approved" + // Disconnected ... + Disconnected PrivateLinkServiceConnectionStatus = "Disconnected" + // Pending ... + Pending PrivateLinkServiceConnectionStatus = "Pending" + // Rejected ... + Rejected PrivateLinkServiceConnectionStatus = "Rejected" +) + +// PossiblePrivateLinkServiceConnectionStatusValues returns an array of possible values for the PrivateLinkServiceConnectionStatus const type. +func PossiblePrivateLinkServiceConnectionStatusValues() []PrivateLinkServiceConnectionStatus { + return []PrivateLinkServiceConnectionStatus{Approved, Disconnected, Pending, Rejected} +} + // ProvisioningState enumerates the values for provisioning state. type ProvisioningState string @@ -76,6 +112,38 @@ func PossibleProvisioningStateValues() []ProvisioningState { return []ProvisioningState{Canceled, Creating, Deleting, Failed, Moving, Running, Succeeded, Unknown, Updating} } +// RequestType enumerates the values for request type. +type RequestType string + +const ( + // ClientConnection ... + ClientConnection RequestType = "ClientConnection" + // RESTAPI ... + RESTAPI RequestType = "RESTAPI" + // ServerConnection ... + ServerConnection RequestType = "ServerConnection" +) + +// PossibleRequestTypeValues returns an array of possible values for the RequestType const type. +func PossibleRequestTypeValues() []RequestType { + return []RequestType{ClientConnection, RESTAPI, ServerConnection} +} + +// ServiceKind enumerates the values for service kind. +type ServiceKind string + +const ( + // RawWebSockets ... + RawWebSockets ServiceKind = "RawWebSockets" + // SignalR ... + SignalR ServiceKind = "SignalR" +) + +// PossibleServiceKindValues returns an array of possible values for the ServiceKind const type. +func PossibleServiceKindValues() []ServiceKind { + return []ServiceKind{RawWebSockets, SignalR} +} + // SkuTier enumerates the values for sku tier. type SkuTier string diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go similarity index 65% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go index c60deefd045f..4dc5172cca43 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go @@ -28,7 +28,7 @@ import ( ) // The package's fully qualified name. -const fqdn = "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr" +const fqdn = "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr" // CorsSettings cross-Origin Resource Sharing (CORS) settings. type CorsSettings struct { @@ -59,39 +59,10 @@ type CreateOrUpdateProperties struct { Features *[]Feature `json:"features,omitempty"` // Cors - Cross-Origin Resource Sharing (CORS) settings. Cors *CorsSettings `json:"cors,omitempty"` -} - -// CreateParameters parameters for SignalR service create/update operation. -// -// Keep the same schema as AzSignalR.Models.SignalRResource -type CreateParameters struct { - // Location - Azure GEO region: e.g. West US | East US | North Central US | South Central US | West Europe | North Europe | East Asia | Southeast Asia | etc. - // The geo region of a resource never changes after it is created. - Location *string `json:"location,omitempty"` - // Tags - A list of key value pairs that describe the resource. - Tags map[string]*string `json:"tags"` - // Sku - The billing information of the resource.(e.g. basic vs. standard) - Sku *ResourceSku `json:"sku,omitempty"` - // Properties - Settings used to provision or configure the resource - Properties *CreateOrUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for CreateParameters. -func (cp CreateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if cp.Location != nil { - objectMap["location"] = cp.Location - } - if cp.Tags != nil { - objectMap["tags"] = cp.Tags - } - if cp.Sku != nil { - objectMap["sku"] = cp.Sku - } - if cp.Properties != nil { - objectMap["properties"] = cp.Properties - } - return json.Marshal(objectMap) + // Upstream - Upstream settings when the Azure SignalR is in server-less mode. + Upstream *ServerlessUpstreamSettings `json:"upstream,omitempty"` + // NetworkACLs - Network ACLs + NetworkACLs *NetworkACLs `json:"networkACLs,omitempty"` } // DeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. @@ -137,7 +108,7 @@ type ErrorResponseBody struct { type Feature struct { // Flag - FeatureFlags is the supported features of Azure SignalR service. // - ServiceMode: Flag for backend server for SignalR service. Values allowed: "Default": have your own backend server; "Serverless": your application doesn't have a backend server; "Classic": for backward compatibility. Support both Default and Serverless mode but not recommended; "PredefinedOnly": for future use. - // - EnableConnectivityLogs: "true"/"false", to enable/disable the connectivity log category respectively. Possible values include: 'ServiceMode', 'EnableConnectivityLogs' + // - EnableConnectivityLogs: "true"/"false", to enable/disable the connectivity log category respectively. Possible values include: 'ServiceMode', 'EnableConnectivityLogs', 'EnableMessagingLogs' Flag FeatureFlags `json:"flag,omitempty"` // Value - Value of the feature flag. See Azure SignalR service document https://docs.microsoft.com/azure/azure-signalr/ for allowed values. Value *string `json:"value,omitempty"` @@ -223,10 +194,30 @@ type NameAvailabilityParameters struct { Name *string `json:"name,omitempty"` } +// NetworkACL network ACL +type NetworkACL struct { + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// NetworkACLs network ACLs for SignalR +type NetworkACLs struct { + // DefaultAction - Default action when no other rule matches. Possible values include: 'Allow', 'Deny' + DefaultAction ACLAction `json:"defaultAction,omitempty"` + // PublicNetwork - ACL for requests from public network + PublicNetwork *NetworkACL `json:"publicNetwork,omitempty"` + // PrivateEndpoints - ACLs for requests from private endpoints + PrivateEndpoints *[]PrivateEndpointACL `json:"privateEndpoints,omitempty"` +} + // Operation REST API operation supported by SignalR resource provider. type Operation struct { // Name - Name of the operation with format: {provider}/{resource}/{operation} Name *string `json:"name,omitempty"` + // IsDataAction - If the operation is a data action. (for data plane rbac) + IsDataAction *bool `json:"isDataAction,omitempty"` // Display - The object that describes the operation. Display *OperationDisplay `json:"display,omitempty"` // Origin - Optional. The intended executor of the operation; governs the display of the operation in the RBAC UX and the audit logs UX. @@ -413,6 +404,393 @@ type OperationProperties struct { ServiceSpecification *ServiceSpecification `json:"serviceSpecification,omitempty"` } +// PrivateEndpoint private endpoint +type PrivateEndpoint struct { + // ID - Full qualified Id of the private endpoint + ID *string `json:"id,omitempty"` +} + +// PrivateEndpointACL ACL for a private endpoint +type PrivateEndpointACL struct { + // Name - Name of the private endpoint connection + Name *string `json:"name,omitempty"` + // Allow - Allowed request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Allow *[]RequestType `json:"allow,omitempty"` + // Deny - Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. + Deny *[]RequestType `json:"deny,omitempty"` +} + +// PrivateEndpointConnection a private endpoint connection to SignalR resource +type PrivateEndpointConnection struct { + autorest.Response `json:"-"` + // PrivateEndpointConnectionProperties - Properties of the private endpoint connection + *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnection. +func (pec PrivateEndpointConnection) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pec.PrivateEndpointConnectionProperties != nil { + objectMap["properties"] = pec.PrivateEndpointConnectionProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateEndpointConnection struct. +func (pec *PrivateEndpointConnection) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateEndpointConnectionProperties PrivateEndpointConnectionProperties + err = json.Unmarshal(*v, &privateEndpointConnectionProperties) + if err != nil { + return err + } + pec.PrivateEndpointConnectionProperties = &privateEndpointConnectionProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + pec.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + pec.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + pec.Type = &typeVar + } + } + } + + return nil +} + +// PrivateEndpointConnectionProperties private endpoint connection properties +type PrivateEndpointConnectionProperties struct { + // ProvisioningState - READ-ONLY; Provisioning state of the private endpoint connection. Possible values include: 'Unknown', 'Succeeded', 'Failed', 'Canceled', 'Running', 'Creating', 'Updating', 'Deleting', 'Moving' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // PrivateEndpoint - Private endpoint associated with the private endpoint connection + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + // PrivateLinkServiceConnectionState - Connection state + PrivateLinkServiceConnectionState *PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateEndpointConnectionProperties. +func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if pecp.PrivateEndpoint != nil { + objectMap["privateEndpoint"] = pecp.PrivateEndpoint + } + if pecp.PrivateLinkServiceConnectionState != nil { + objectMap["privateLinkServiceConnectionState"] = pecp.PrivateLinkServiceConnectionState + } + return json.Marshal(objectMap) +} + +// PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type PrivateEndpointConnectionsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *PrivateEndpointConnectionsDeleteFuture) Result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("signalr.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// PrivateLinkResource private link resource +type PrivateLinkResource struct { + // PrivateLinkResourceProperties - Properties of a private link resource + *PrivateLinkResourceProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for PrivateLinkResource. +func (plr PrivateLinkResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if plr.PrivateLinkResourceProperties != nil { + objectMap["properties"] = plr.PrivateLinkResourceProperties + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for PrivateLinkResource struct. +func (plr *PrivateLinkResource) UnmarshalJSON(body []byte) error { + var m map[string]*json.RawMessage + err := json.Unmarshal(body, &m) + if err != nil { + return err + } + for k, v := range m { + switch k { + case "properties": + if v != nil { + var privateLinkResourceProperties PrivateLinkResourceProperties + err = json.Unmarshal(*v, &privateLinkResourceProperties) + if err != nil { + return err + } + plr.PrivateLinkResourceProperties = &privateLinkResourceProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + plr.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + plr.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + plr.Type = &typeVar + } + } + } + + return nil +} + +// PrivateLinkResourceList contains a list of AzSignalR.Models.Response.PrivateLink.PrivateLinkResource and +// a possible link to query more results +type PrivateLinkResourceList struct { + autorest.Response `json:"-"` + // Value - List of PrivateLinkResource + Value *[]PrivateLinkResource `json:"value,omitempty"` + // NextLink - The URL the client should use to fetch the next page (per server side paging). + // It's null for now, added for future use. + NextLink *string `json:"nextLink,omitempty"` +} + +// PrivateLinkResourceListIterator provides access to a complete listing of PrivateLinkResource values. +type PrivateLinkResourceListIterator struct { + i int + page PrivateLinkResourceListPage +} + +// NextWithContext advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +func (iter *PrivateLinkResourceListIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListIterator.NextWithContext") + defer func() { + sc := -1 + if iter.Response().Response.Response != nil { + sc = iter.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + iter.i++ + if iter.i < len(iter.page.Values()) { + return nil + } + err = iter.page.NextWithContext(ctx) + if err != nil { + iter.i-- + return err + } + iter.i = 0 + return nil +} + +// Next advances to the next value. If there was an error making +// the request the iterator does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (iter *PrivateLinkResourceListIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter PrivateLinkResourceListIterator) NotDone() bool { + return iter.page.NotDone() && iter.i < len(iter.page.Values()) +} + +// Response returns the raw server response from the last page request. +func (iter PrivateLinkResourceListIterator) Response() PrivateLinkResourceList { + return iter.page.Response() +} + +// Value returns the current value or a zero-initialized value if the +// iterator has advanced beyond the end of the collection. +func (iter PrivateLinkResourceListIterator) Value() PrivateLinkResource { + if !iter.page.NotDone() { + return PrivateLinkResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the PrivateLinkResourceListIterator type. +func NewPrivateLinkResourceListIterator(page PrivateLinkResourceListPage) PrivateLinkResourceListIterator { + return PrivateLinkResourceListIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (plrl PrivateLinkResourceList) IsEmpty() bool { + return plrl.Value == nil || len(*plrl.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (plrl PrivateLinkResourceList) hasNextLink() bool { + return plrl.NextLink != nil && len(*plrl.NextLink) != 0 +} + +// privateLinkResourceListPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (plrl PrivateLinkResourceList) privateLinkResourceListPreparer(ctx context.Context) (*http.Request, error) { + if !plrl.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(plrl.NextLink))) +} + +// PrivateLinkResourceListPage contains a page of PrivateLinkResource values. +type PrivateLinkResourceListPage struct { + fn func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error) + plrl PrivateLinkResourceList +} + +// NextWithContext advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +func (page *PrivateLinkResourceListPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourceListPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + for { + next, err := page.fn(ctx, page.plrl) + if err != nil { + return err + } + page.plrl = next + if !next.hasNextLink() || !next.IsEmpty() { + break + } + } + return nil +} + +// Next advances to the next page of values. If there was an error making +// the request the page does not advance and the error is returned. +// Deprecated: Use NextWithContext() instead. +func (page *PrivateLinkResourceListPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page PrivateLinkResourceListPage) NotDone() bool { + return !page.plrl.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page PrivateLinkResourceListPage) Response() PrivateLinkResourceList { + return page.plrl +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page PrivateLinkResourceListPage) Values() []PrivateLinkResource { + if page.plrl.IsEmpty() { + return nil + } + return *page.plrl.Value +} + +// Creates a new instance of the PrivateLinkResourceListPage type. +func NewPrivateLinkResourceListPage(cur PrivateLinkResourceList, getNextPage func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error)) PrivateLinkResourceListPage { + return PrivateLinkResourceListPage{ + fn: getNextPage, + plrl: cur, + } +} + +// PrivateLinkResourceProperties private link resource properties +type PrivateLinkResourceProperties struct { + // GroupID - Group Id of the private link resource + GroupID *string `json:"groupId,omitempty"` + // RequiredMembers - Required members of the private link resource + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + // RequiredZoneNames - Required private DNS zone names + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} + +// PrivateLinkServiceConnectionState connection state of the private endpoint connection +type PrivateLinkServiceConnectionState struct { + // Status - Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. Possible values include: 'Pending', 'Approved', 'Rejected', 'Disconnected' + Status PrivateLinkServiceConnectionStatus `json:"status,omitempty"` + // Description - The reason for approval/rejection of the connection. + Description *string `json:"description,omitempty"` + // ActionsRequired - A message indicating if changes on the service provider require any updates on the consumer. + ActionsRequired *string `json:"actionsRequired,omitempty"` +} + // Properties a class that describes the properties of the SignalR service that should contain more // read-only properties than AzSignalR.Models.SignalRCreateOrUpdateProperties type Properties struct { @@ -426,8 +804,10 @@ type Properties struct { PublicPort *int32 `json:"publicPort,omitempty"` // ServerPort - READ-ONLY; The publicly accessible port of the SignalR service which is designed for customer server side usage. ServerPort *int32 `json:"serverPort,omitempty"` - // Version - Version of the SignalR resource. Probably you need the same or higher version of client SDKs. + // Version - READ-ONLY; Version of the SignalR resource. Probably you need the same or higher version of client SDKs. Version *string `json:"version,omitempty"` + // PrivateEndpointConnections - READ-ONLY; Private endpoint connections to the SignalR resource. + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` // HostNamePrefix - Prefix for the hostName of the SignalR service. Retained for future use. // The hostname will be of format: <hostNamePrefix>.service.signalr.net. HostNamePrefix *string `json:"hostNamePrefix,omitempty"` @@ -440,14 +820,15 @@ type Properties struct { Features *[]Feature `json:"features,omitempty"` // Cors - Cross-Origin Resource Sharing (CORS) settings. Cors *CorsSettings `json:"cors,omitempty"` + // Upstream - Upstream settings when the Azure SignalR is in server-less mode. + Upstream *ServerlessUpstreamSettings `json:"upstream,omitempty"` + // NetworkACLs - Network ACLs + NetworkACLs *NetworkACLs `json:"networkACLs,omitempty"` } // MarshalJSON is the custom marshaler for Properties. func (p Properties) MarshalJSON() ([]byte, error) { objectMap := make(map[string]interface{}) - if p.Version != nil { - objectMap["version"] = p.Version - } if p.HostNamePrefix != nil { objectMap["hostNamePrefix"] = p.HostNamePrefix } @@ -457,9 +838,26 @@ func (p Properties) MarshalJSON() ([]byte, error) { if p.Cors != nil { objectMap["cors"] = p.Cors } + if p.Upstream != nil { + objectMap["upstream"] = p.Upstream + } + if p.NetworkACLs != nil { + objectMap["networkACLs"] = p.NetworkACLs + } return json.Marshal(objectMap) } +// ProxyResource the resource model definition for a ARM proxy resource. It will have everything other than +// required location and tags +type ProxyResource struct { + // ID - READ-ONLY; Fully qualified resource Id for the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; The name of the resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" + Type *string `json:"type,omitempty"` +} + // RegenerateKeyFuture an abstraction for monitoring and retrieving the results of a long-running // operation. type RegenerateKeyFuture struct { @@ -481,7 +879,7 @@ type Resource struct { ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR" + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" Type *string `json:"type,omitempty"` } @@ -670,10 +1068,12 @@ type ResourceSku struct { // ResourceType a class represent a SignalR service resource. type ResourceType struct { autorest.Response `json:"-"` - // Sku - SKU of the service. + // Sku - The billing information of the resource.(e.g. Free, Standard) Sku *ResourceSku `json:"sku,omitempty"` - // Properties - The properties of the service. + // Properties - Settings used to provision or configure the resource *Properties `json:"properties,omitempty"` + // Kind - The kind of the service - e.g. "SignalR", or "RawWebSockets" for "Microsoft.SignalRService/SignalR". Possible values include: 'SignalR', 'RawWebSockets' + Kind ServiceKind `json:"kind,omitempty"` // Location - The GEO location of the SignalR service. e.g. West US | East US | North Central US | South Central US. Location *string `json:"location,omitempty"` // Tags - Tags of the service which is a list of key value pairs that describe the resource. @@ -682,7 +1082,7 @@ type ResourceType struct { ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR" + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" Type *string `json:"type,omitempty"` } @@ -695,6 +1095,9 @@ func (rt ResourceType) MarshalJSON() ([]byte, error) { if rt.Properties != nil { objectMap["properties"] = rt.Properties } + if rt.Kind != "" { + objectMap["kind"] = rt.Kind + } if rt.Location != nil { objectMap["location"] = rt.Location } @@ -731,6 +1134,15 @@ func (rt *ResourceType) UnmarshalJSON(body []byte) error { } rt.Properties = &properties } + case "kind": + if v != nil { + var kind ServiceKind + err = json.Unmarshal(*v, &kind) + if err != nil { + return err + } + rt.Kind = kind + } case "location": if v != nil { var location string @@ -790,6 +1202,12 @@ type RestartFuture struct { Result func(Client) (autorest.Response, error) } +// ServerlessUpstreamSettings the settings for the Upstream when the Azure SignalR is in server-less mode. +type ServerlessUpstreamSettings struct { + // Templates - Gets or sets the list of Upstream URL templates. Order matters, and the first matching template takes effects. + Templates *[]UpstreamTemplate `json:"templates,omitempty"` +} + // ServiceSpecification an object that describes a specification. type ServiceSpecification struct { // MetricSpecifications - Specifications of the Metrics for Azure Monitoring. @@ -808,7 +1226,7 @@ type TrackedResource struct { ID *string `json:"id,omitempty"` // Name - READ-ONLY; The name of the resource. Name *string `json:"name,omitempty"` - // Type - READ-ONLY; The type of the service - e.g. "Microsoft.SignalRService/SignalR" + // Type - READ-ONLY; The type of the resource - e.g. "Microsoft.SignalRService/SignalR" Type *string `json:"type,omitempty"` } @@ -832,29 +1250,31 @@ type UpdateFuture struct { Result func(Client) (ResourceType, error) } -// UpdateParameters parameters for SignalR service update operation -type UpdateParameters struct { - // Tags - A list of key value pairs that describe the resource. - Tags map[string]*string `json:"tags"` - // Sku - The billing information of the resource.(e.g. basic vs. standard) - Sku *ResourceSku `json:"sku,omitempty"` - // Properties - Settings used to provision or configure the resource - Properties *CreateOrUpdateProperties `json:"properties,omitempty"` -} - -// MarshalJSON is the custom marshaler for UpdateParameters. -func (up UpdateParameters) MarshalJSON() ([]byte, error) { - objectMap := make(map[string]interface{}) - if up.Tags != nil { - objectMap["tags"] = up.Tags - } - if up.Sku != nil { - objectMap["sku"] = up.Sku - } - if up.Properties != nil { - objectMap["properties"] = up.Properties - } - return json.Marshal(objectMap) +// UpstreamTemplate upstream template item settings. It defines the Upstream URL of the incoming requests. +// The template defines the pattern of the event, the hub or the category of the incoming request that +// matches current URL template. +type UpstreamTemplate struct { + // HubPattern - Gets or sets the matching pattern for hub names. If not set, it matches any hub. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any hub name + // 2. Combine multiple hubs with ",", for example "hub1,hub2", it matches "hub1" and "hub2" + // 3. The single hub name, for example, "hub1", it matches "hub1" + HubPattern *string `json:"hubPattern,omitempty"` + // EventPattern - Gets or sets the matching pattern for event names. If not set, it matches any event. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any event name + // 2. Combine multiple events with ",", for example "connect,disconnect", it matches event "connect" and "disconnect" + // 3. The single event name, for example, "connect", it matches "connect" + EventPattern *string `json:"eventPattern,omitempty"` + // CategoryPattern - Gets or sets the matching pattern for category names. If not set, it matches any category. + // There are 3 kind of patterns supported: + // 1. "*", it to matches any category name + // 2. Combine multiple categories with ",", for example "connections,messages", it matches category "connections" and "messages" + // 3. The single category name, for example, "connections", it matches the category "connections" + CategoryPattern *string `json:"categoryPattern,omitempty"` + // URLTemplate - Gets or sets the Upstream URL template. You can use 3 predefined parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is dynamically calculated when the client request comes in. + // For example, if the urlTemplate is `http://example.com/{hub}/api/{event}`, with a client request from hub `chat` connects, it will first POST to this URL: `http://example.com/chat/api/connect`. + URLTemplate *string `json:"urlTemplate,omitempty"` } // Usage object that describes a specific usage of SignalR resources. diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/operations.go index 5507877a067a..e448682e6522 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/operations.go @@ -82,7 +82,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListPa // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go new file mode 100644 index 000000000000..faab2191c75e --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go @@ -0,0 +1,287 @@ +package signalr + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateEndpointConnectionsClient is the REST API for Azure SignalR Service +type PrivateEndpointConnectionsClient struct { + BaseClient +} + +// NewPrivateEndpointConnectionsClient creates an instance of the PrivateEndpointConnectionsClient client. +func NewPrivateEndpointConnectionsClient(subscriptionID string) PrivateEndpointConnectionsClient { + return NewPrivateEndpointConnectionsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateEndpointConnectionsClientWithBaseURI creates an instance of the PrivateEndpointConnectionsClient client +// using a custom endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign +// clouds, Azure stack). +func NewPrivateEndpointConnectionsClientWithBaseURI(baseURI string, subscriptionID string) PrivateEndpointConnectionsClient { + return PrivateEndpointConnectionsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Delete delete the specified private endpoint connection associated with a SignalR resource. +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection associated with the SignalR +// resource. +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the SignalR resource. +func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnectionsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client PrivateEndpointConnectionsClient) DeletePreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// DeleteSender sends the Delete request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) (future PrivateEndpointConnectionsDeleteFuture, err error) { + var resp *http.Response + resp, err = client.Send(req, azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// DeleteResponder handles the response to the Delete request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Get get the specified private endpoint connection associated with a SignalR resource. +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection associated with the SignalR +// resource. +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the SignalR resource. +func (client PrivateEndpointConnectionsClient) Get(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Get") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetPreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Get", resp, "Failure responding to request") + return + } + + return +} + +// GetPreparer prepares the Get request. +func (client PrivateEndpointConnectionsClient) GetPreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetSender sends the Get request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) GetSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) GetResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Update update the state of specified private endpoint connection associated with a SignalR resource. +// Parameters: +// privateEndpointConnectionName - the name of the private endpoint connection associated with the SignalR +// resource. +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the SignalR resource. +// parameters - the resource of private endpoint and its properties. +func (client PrivateEndpointConnectionsClient) Update(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string, parameters *PrivateEndpointConnection) (result PrivateEndpointConnection, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateEndpointConnectionsClient.Update") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.UpdatePreparer(ctx, privateEndpointConnectionName, resourceGroupName, resourceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Update", resp, "Failure responding to request") + return + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client PrivateEndpointConnectionsClient) UpdatePreparer(ctx context.Context, privateEndpointConnectionName string, resourceGroupName string, resourceName string, parameters *PrivateEndpointConnection) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "privateEndpointConnectionName": autorest.Encode("path", privateEndpointConnectionName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if parameters != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(parameters)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// UpdateSender sends the Update request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateEndpointConnectionsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client PrivateEndpointConnectionsClient) UpdateResponder(resp *http.Response) (result PrivateEndpointConnection, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go new file mode 100644 index 000000000000..f44ac63394b2 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go @@ -0,0 +1,162 @@ +package signalr + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// PrivateLinkResourcesClient is the REST API for Azure SignalR Service +type PrivateLinkResourcesClient struct { + BaseClient +} + +// NewPrivateLinkResourcesClient creates an instance of the PrivateLinkResourcesClient client. +func NewPrivateLinkResourcesClient(subscriptionID string) PrivateLinkResourcesClient { + return NewPrivateLinkResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewPrivateLinkResourcesClientWithBaseURI creates an instance of the PrivateLinkResourcesClient client using a custom +// endpoint. Use this when interacting with an Azure cloud that uses a non-standard base URI (sovereign clouds, Azure +// stack). +func NewPrivateLinkResourcesClientWithBaseURI(baseURI string, subscriptionID string) PrivateLinkResourcesClient { + return PrivateLinkResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List get the private link resources that need to be created for a SignalR resource. +// Parameters: +// resourceGroupName - the name of the resource group that contains the resource. You can obtain this value +// from the Azure Resource Manager API or the portal. +// resourceName - the name of the SignalR resource. +func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.plrl.Response.Response != nil { + sc = result.plrl.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, resourceName) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.plrl.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", resp, "Failure sending request") + return + } + + result.plrl, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "List", resp, "Failure responding to request") + return + } + if result.plrl.hasNextLink() && result.plrl.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client PrivateLinkResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, resourceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "resourceName": autorest.Encode("path", resourceName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-05-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListSender sends the List request. The method will close the +// http.Response Body if it receives an error. +func (client PrivateLinkResourcesClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client PrivateLinkResourcesClient) ListResponder(resp *http.Response) (result PrivateLinkResourceList, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client PrivateLinkResourcesClient) listNextResults(ctx context.Context, lastResults PrivateLinkResourceList) (result PrivateLinkResourceList, err error) { + req, err := lastResults.privateLinkResourceListPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") + return + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client PrivateLinkResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, resourceName string) (result PrivateLinkResourceListIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/PrivateLinkResourcesClient.List") + defer func() { + sc := -1 + if result.Response().Response.Response != nil { + sc = result.page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.page, err = client.List(ctx, resourceGroupName, resourceName) + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/signalr.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/signalr.go similarity index 97% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/signalr.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/signalr.go index d0152b521b5c..c8d21baab007 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/signalr.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/signalr.go @@ -95,7 +95,7 @@ func (client Client) CheckNameAvailabilityPreparer(ctx context.Context, location "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -137,7 +137,7 @@ func (client Client) CheckNameAvailabilityResponder(resp *http.Response) (result // from the Azure Resource Manager API or the portal. // resourceName - the name of the SignalR resource. // parameters - parameters for the create or update operation -func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters *CreateParameters) (result CreateOrUpdateFuture, err error) { +func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName string, resourceName string, parameters *ResourceType) (result CreateOrUpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/Client.CreateOrUpdate") defer func() { @@ -151,7 +151,9 @@ func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName strin if err := validation.Validate([]validation.Validation{ {TargetValue: parameters, Constraints: []validation.Constraint{{Target: "parameters", Name: validation.Null, Rule: false, - Chain: []validation.Constraint{{Target: "parameters.Location", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + Chain: []validation.Constraint{{Target: "parameters.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "parameters.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + }}}}}); err != nil { return result, validation.NewError("signalr.Client", "CreateOrUpdate", err.Error()) } @@ -171,14 +173,14 @@ func (client Client) CreateOrUpdate(ctx context.Context, resourceGroupName strin } // CreateOrUpdatePreparer prepares the CreateOrUpdate request. -func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *CreateParameters) (*http.Request, error) { +func (client Client) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *ResourceType) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -285,7 +287,7 @@ func (client Client) DeletePreparer(ctx context.Context, resourceGroupName strin "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -383,7 +385,7 @@ func (client Client) GetPreparer(ctx context.Context, resourceGroupName string, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -463,7 +465,7 @@ func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGr "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -471,7 +473,7 @@ func (client Client) ListByResourceGroupPreparer(ctx context.Context, resourceGr preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -576,7 +578,7 @@ func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Requ "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -584,7 +586,7 @@ func (client Client) ListBySubscriptionPreparer(ctx context.Context) (*http.Requ preparer := autorest.CreatePreparer( autorest.AsGet(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/SignalR", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -690,7 +692,7 @@ func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName str "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -698,7 +700,7 @@ func (client Client) ListKeysPreparer(ctx context.Context, resourceGroupName str preparer := autorest.CreatePreparer( autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}/listKeys", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys", pathParameters), autorest.WithQueryParameters(queryParameters)) return preparer.Prepare((&http.Request{}).WithContext(ctx)) } @@ -762,7 +764,7 @@ func (client Client) RegenerateKeyPreparer(ctx context.Context, resourceGroupNam "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -771,7 +773,7 @@ func (client Client) RegenerateKeyPreparer(ctx context.Context, resourceGroupNam autorest.AsContentType("application/json; charset=utf-8"), autorest.AsPost(), autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/SignalR/{resourceName}/regenerateKey", pathParameters), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey", pathParameters), autorest.WithQueryParameters(queryParameters)) if parameters != nil { preparer = autorest.DecoratePreparer(preparer, @@ -869,7 +871,7 @@ func (client Client) RestartPreparer(ctx context.Context, resourceGroupName stri "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -927,7 +929,7 @@ func (client Client) RestartResponder(resp *http.Response) (result autorest.Resp // from the Azure Resource Manager API or the portal. // resourceName - the name of the SignalR resource. // parameters - parameters for the update operation -func (client Client) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters *UpdateParameters) (result UpdateFuture, err error) { +func (client Client) Update(ctx context.Context, resourceGroupName string, resourceName string, parameters *ResourceType) (result UpdateFuture, err error) { if tracing.IsEnabled() { ctx = tracing.StartSpan(ctx, fqdn+"/Client.Update") defer func() { @@ -954,14 +956,14 @@ func (client Client) Update(ctx context.Context, resourceGroupName string, resou } // UpdatePreparer prepares the Update request. -func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *UpdateParameters) (*http.Request, error) { +func (client Client) UpdatePreparer(ctx context.Context, resourceGroupName string, resourceName string, parameters *ResourceType) (*http.Request, error) { pathParameters := map[string]interface{}{ "resourceGroupName": autorest.Encode("path", resourceGroupName), "resourceName": autorest.Encode("path", resourceName), "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/usages.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/usages.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/usages.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/usages.go index a94def979f64..19d272828e09 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/usages.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/usages.go @@ -89,7 +89,7 @@ func (client UsagesClient) ListPreparer(ctx context.Context, location string) (* "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-10-01" + const APIVersion = "2020-05-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/version.go similarity index 94% rename from vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/version.go index ab1d0f25da97..bae3f1e10e52 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + Version() + " signalr/2018-10-01" + return "Azure-SDK-For-Go/" + Version() + " signalr/2020-05-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/modules.txt b/vendor/modules.txt index 6cbf737e8a90..5bac9e4aaef0 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -107,7 +107,7 @@ github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2019-11-01/subscriptio github.com/Azure/azure-sdk-for-go/services/resources/mgmt/2020-06-01/resources github.com/Azure/azure-sdk-for-go/services/search/mgmt/2020-03-13/search github.com/Azure/azure-sdk-for-go/services/servicebus/mgmt/2017-04-01/servicebus -github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2018-10-01/signalr +github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr github.com/Azure/azure-sdk-for-go/services/storage/mgmt/2019-06-01/storage github.com/Azure/azure-sdk-for-go/services/storagecache/mgmt/2020-03-01/storagecache github.com/Azure/azure-sdk-for-go/services/storagesync/mgmt/2020-03-01/storagesync From 32db874f73f745d2158eda12b891d38f616fc798 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Thu, 4 Feb 2021 05:45:43 -0600 Subject: [PATCH 02/15] Fix models being used --- .../signalr/signalr_service_resource.go | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index bd9bfd8a59b9..627a1f9bbe53 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -190,19 +190,19 @@ func resourceArmSignalRServiceCreate(d *schema.ResourceData, meta interface{}) e cors := d.Get("cors").([]interface{}) expandedTags := tags.Expand(t) - properties := &signalr.CreateOrUpdateProperties{ + properties := &signalr.Properties{ Cors: expandSignalRCors(cors), Features: expandSignalRFeatures(featureFlags), } - parameters := &signalr.CreateParameters{ + resourceType := &signalr.ResourceType{ Location: utils.String(location), Sku: expandSignalRServiceSku(sku), Tags: expandedTags, Properties: properties, } - future, err := client.CreateOrUpdate(ctx, resourceGroup, name, parameters) + future, err := client.CreateOrUpdate(ctx, resourceGroup, name, resourceType) if err != nil { return fmt.Errorf("Error creating or updating SignalR %q (Resource Group %q): %+v", name, resourceGroup, err) } @@ -291,33 +291,33 @@ func resourceArmSignalRServiceUpdate(d *schema.ResourceData, meta interface{}) e return err } - parameters := &signalr.UpdateParameters{} + resourceType := &signalr.ResourceType{} if d.HasChanges("cors", "features") { - parameters.Properties = &signalr.CreateOrUpdateProperties{} + resourceType.Properties = &signalr.Properties{} if d.HasChange("cors") { corsRaw := d.Get("cors").([]interface{}) - parameters.Properties.Cors = expandSignalRCors(corsRaw) + resourceType.Properties.Cors = expandSignalRCors(corsRaw) } if d.HasChange("features") { featuresRaw := d.Get("features").(*schema.Set).List() - parameters.Properties.Features = expandSignalRFeatures(featuresRaw) + resourceType.Properties.Features = expandSignalRFeatures(featuresRaw) } } if d.HasChange("sku") { sku := d.Get("sku").([]interface{}) - parameters.Sku = expandSignalRServiceSku(sku) + resourceType.Sku = expandSignalRServiceSku(sku) } if d.HasChange("tags") { tagsRaw := d.Get("tags").(map[string]interface{}) - parameters.Tags = tags.Expand(tagsRaw) + resourceType.Tags = tags.Expand(tagsRaw) } - future, err := client.Update(ctx, id.ResourceGroup, id.SignalRName, parameters) + future, err := client.Update(ctx, id.ResourceGroup, id.SignalRName, resourceType) if err != nil { return fmt.Errorf("updating SignalR Service %q (Resource Group %q): %+v", id.SignalRName, id.ResourceGroup, err) } From 587b5a63062e590b69a80fdc9414edde7bcb7964 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Tue, 9 Feb 2021 21:11:08 -0600 Subject: [PATCH 03/15] Update `acctests` make def to work --- GNUmakefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GNUmakefile b/GNUmakefile index b993ef5107d7..9914315f6782 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -104,7 +104,7 @@ testacc: fmtcheck TF_ACC=1 go test $(TEST) -v $(TESTARGS) -timeout $(TESTTIMEOUT) -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc" acctests: fmtcheck - TF_ACC=1 go test -v ./azurerm/internal/services/$(SERVICE)/tests/ $(TESTARGS) -timeout $(TESTTIMEOUT) -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc" + TF_ACC=1 go test -v ./azurerm/internal/services/$(SERVICE) $(TESTARGS) -timeout $(TESTTIMEOUT) -ldflags="-X=github.com/terraform-providers/terraform-provider-azurerm/version.ProviderVersion=acc" debugacc: fmtcheck TF_ACC=1 dlv test $(TEST) --headless --listen=:2345 --api-version=2 -- -test.v $(TESTARGS) From 6ff1dc2b61361513a9e4aa34131a8f0f2e17a628 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Tue, 9 Feb 2021 21:56:35 -0600 Subject: [PATCH 04/15] Expose `upstream_setting` --- .../signalr/signalr_service_resource.go | 90 +++++++++++++++++++ .../signalr/signalr_service_resource_test.go | 85 ++++++++++++++++++ website/docs/r/signalr_service.html.markdown | 21 +++++ 3 files changed, 196 insertions(+) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index 627a1f9bbe53..ab35f7fbdbcd 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -100,6 +100,35 @@ func resourceArmSignalRService() *schema.Resource { }, }, + "upstream_setting": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "category_pattern": { + Type: schema.TypeString, + Optional: true, + }, + + "event_pattern": { + Type: schema.TypeString, + Optional: true, + }, + + "hub_pattern": { + Type: schema.TypeString, + Optional: true, + }, + + "url_template": { + Type: schema.TypeString, + Required: true, + }, + }, + }, + }, + "cors": { Type: schema.TypeList, Optional: true, @@ -189,10 +218,12 @@ func resourceArmSignalRServiceCreate(d *schema.ResourceData, meta interface{}) e featureFlags := d.Get("features").(*schema.Set).List() cors := d.Get("cors").([]interface{}) expandedTags := tags.Expand(t) + upstreamSettings := d.Get("upstream_setting").(*schema.Set).List() properties := &signalr.Properties{ Cors: expandSignalRCors(cors), Features: expandSignalRFeatures(featureFlags), + Upstream: expandUpstreamSettings(upstreamSettings), } resourceType := &signalr.ResourceType{ @@ -271,6 +302,10 @@ func resourceArmSignalRServiceRead(d *schema.ResourceData, meta interface{}) err if err := d.Set("cors", flattenSignalRCors(properties.Cors)); err != nil { return fmt.Errorf("Error setting `cors`: %+v", err) } + + if err := d.Set("upstream_setting", flattenUpstreamSettings(properties.Upstream)); err != nil { + return fmt.Errorf("Error setting `upstream_setting`: %+v", err) + } } d.Set("primary_access_key", keys.PrimaryKey) @@ -390,6 +425,61 @@ func flattenSignalRFeatures(features *[]signalr.Feature) []interface{} { return result } +func expandUpstreamSettings(input []interface{}) *signalr.ServerlessUpstreamSettings { + upstreamTemplates := make([]signalr.UpstreamTemplate, 0) + + for _, upstreamSetting := range input { + setting := upstreamSetting.(map[string]interface{}) + + upstreamTemplate := &signalr.UpstreamTemplate{ + HubPattern: utils.String(setting["category_pattern"].(string)), + EventPattern: utils.String(setting["event_pattern"].(string)), + CategoryPattern: utils.String(setting["hub_pattern"].(string)), + URLTemplate: utils.String(setting["url_template"].(string)), + } + + upstreamTemplates = append(upstreamTemplates, *upstreamTemplate) + } + + return &signalr.ServerlessUpstreamSettings{ + Templates: &upstreamTemplates, + } +} + +func flattenUpstreamSettings(upstreamSettings *signalr.ServerlessUpstreamSettings) []interface{} { + if upstreamSettings == nil || upstreamSettings.Templates == nil { + return []interface{}{} + } + + result := make([]interface{}, 0) + for _, upstreamTemplate := range *upstreamSettings.Templates { + categoryPattern := "" + if upstreamTemplate.HubPattern != nil { + categoryPattern = *upstreamTemplate.HubPattern + } + eventPattern := "" + if upstreamTemplate.EventPattern != nil { + eventPattern = *upstreamTemplate.EventPattern + } + hubPattern := "" + if upstreamTemplate.HubPattern != nil { + hubPattern = *upstreamTemplate.HubPattern + } + urlTemplate := "" + if upstreamTemplate.URLTemplate != nil { + urlTemplate = *upstreamTemplate.URLTemplate + } + + result = append(result, map[string]interface{}{ + "category_pattern": categoryPattern, + "event_pattern": eventPattern, + "hub_pattern": hubPattern, + "url_template": urlTemplate, + }) + } + return result +} + func expandSignalRCors(input []interface{}) *signalr.CorsSettings { corsSettings := signalr.CorsSettings{} diff --git a/azurerm/internal/services/signalr/signalr_service_resource_test.go b/azurerm/internal/services/signalr/signalr_service_resource_test.go index 1d4155fcb21a..d3bb74434b9b 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource_test.go +++ b/azurerm/internal/services/signalr/signalr_service_resource_test.go @@ -332,6 +332,37 @@ func TestAccSignalRService_cors(t *testing.T) { }) } +func TestAccSignalRService_upstreamSetting(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_signalr_service", "test") + r := SignalRServiceResource{} + + data.ResourceTest(t, r, []resource.TestStep{ + { + Config: r.withUpstreamSettings(data), + Check: resource.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("upstream_setting.#").HasValue("4"), + check.That(data.ResourceName).Key("upstream_setting.0.category_pattern").DoesNotExist(), + check.That(data.ResourceName).Key("upstream_setting.0.event_pattern").DoesNotExist(), + check.That(data.ResourceName).Key("upstream_setting.0.hub_pattern").DoesNotExist(), + check.That(data.ResourceName).Key("upstream_setting.0.url_template").HasValue("http://foo.com"), + check.That(data.ResourceName).Key("upstream_setting.1.category_pattern").HasValue("connections,messages"), + check.That(data.ResourceName).Key("upstream_setting.1.event_pattern").HasValue("*"), + check.That(data.ResourceName).Key("upstream_setting.1.hub_pattern").HasValue("hub1"), + check.That(data.ResourceName).Key("upstream_setting.1.url_template").HasValue("http://foo.com"), + check.That(data.ResourceName).Key("upstream_setting.2.category_pattern").HasValue("*"), + check.That(data.ResourceName).Key("upstream_setting.2.event_pattern").HasValue("connect,disconnect"), + check.That(data.ResourceName).Key("upstream_setting.2.hub_pattern").HasValue("hub1,hub2"), + check.That(data.ResourceName).Key("upstream_setting.2.url_template").HasValue("http://foo3.com"), + check.That(data.ResourceName).Key("upstream_setting.3.category_pattern").HasValue("connections"), + check.That(data.ResourceName).Key("upstream_setting.3.event_pattern").HasValue("disconnect"), + check.That(data.ResourceName).Key("upstream_setting.3.hub_pattern").HasValue("*"), + check.That(data.ResourceName).Key("upstream_setting.3.url_template").HasValue("http://foo4.com"), + ), + }, + }) +} + func (r SignalRServiceResource) Exists(ctx context.Context, client *clients.Client, state *terraform.InstanceState) (*bool, error) { id, err := parse.ServiceID(state.ID) if err != nil { @@ -481,3 +512,57 @@ resource "azurerm_signalr_service" "test" { } `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, serviceMode) } + +func (r SignalRServiceResource) withUpstreamSettings(data acceptance.TestData) string { + return fmt.Sprintf(` +provider "azurerm" { + features {} +} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-%d" + location = "%s" +} + +resource "azurerm_signalr_service" "test" { + name = "acctestSignalR-%d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + + sku { + name = "Free_F1" + capacity = 1 + } + + features { + flag = "ServiceMode" + value = "Serverless" + } + + upstream_setting { + url_template = "http://foo.com" + } + + upstream_setting { + category_pattern = "connections,messages" + event_pattern = "*" + hub_pattern = "hub1" + url_template = "http://foo.com" + } + + upstream_setting { + category_pattern = "*" + event_pattern = "connect,disconnect" + hub_pattern = "hub1,hub2" + url_template = "http://foo3.com" + } + + upstream_setting { + category_pattern = "connections" + event_pattern = "disconnect" + hub_pattern = "*" + url_template = "http://foo4.com" + } +} + `, data.RandomInteger, data.Locations.Primary, data.RandomInteger) +} diff --git a/website/docs/r/signalr_service.html.markdown b/website/docs/r/signalr_service.html.markdown index dbb9c42435d0..17b772c3595d 100644 --- a/website/docs/r/signalr_service.html.markdown +++ b/website/docs/r/signalr_service.html.markdown @@ -36,6 +36,13 @@ resource "azurerm_signalr_service" "example" { flag = "ServiceMode" value = "Default" } + + upstream_setting { + category_pattern = "connections,messages" + event_pattern = "*" + hub_pattern = "hub1" + url_template = "http://foo.com" + } } ``` @@ -55,6 +62,8 @@ The following arguments are supported: * `features` - (Optional) A `features` block as documented below. +* `upstream_setting` - (Optional) An `upstream_setting` block as documented below. Using this block requires the SignalR service to be Serverless. + * `tags` - (Optional) A mapping of tags to assign to the resource. --- @@ -73,6 +82,18 @@ A `features` block supports the following: --- +An `upstream_setting` block supports the following: + +* `url_template` - (Required) The upstream URL Template. Possible values are `EnableConnectivityLogs`, `EnableMessagingLogs`, and `ServiceMode`. + +* `category_pattern` - (Optional) The matching pattern for category names. Possible values are `*`, multiple categories separated by commas `,`, and single categories. Ex: `connections,messages`, `*`, and `connections`. + +* `event_pattern` - (Optional) The matching pattern for event names. Possible values are `*`, multiple events separated by commas `,`, and single events. Ex: `connect,disconnect`, `*`, and `connect`. + +* `hub_pattern` - (Optional) The matching mattern for hub names. Possible values are `*`, multiple hubs separated by commas `,`, and single hubs. Ex: `hub1,hub1`, `*`, `hub1`. + +--- + A `sku` block supports the following: * `name` - (Required) Specifies which tier to use. Valid values are `Free_F1` and `Standard_S1`. From 60169275e6f5b45ce340849d196a1fbab63b0017 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Tue, 9 Feb 2021 22:03:02 -0600 Subject: [PATCH 05/15] Update upstream_setting --- .../services/signalr/signalr_service_resource.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index ab35f7fbdbcd..75f8a891dfc6 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -340,6 +340,11 @@ func resourceArmSignalRServiceUpdate(d *schema.ResourceData, meta interface{}) e featuresRaw := d.Get("features").(*schema.Set).List() resourceType.Properties.Features = expandSignalRFeatures(featuresRaw) } + + if d.HasChange("upstream_setting") { + featuresRaw := d.Get("upstream_setting").(*schema.Set).List() + resourceType.Properties.Upstream = expandUpstreamSettings(featuresRaw) + } } if d.HasChange("sku") { @@ -453,19 +458,17 @@ func flattenUpstreamSettings(upstreamSettings *signalr.ServerlessUpstreamSetting result := make([]interface{}, 0) for _, upstreamTemplate := range *upstreamSettings.Templates { - categoryPattern := "" + var categoryPattern, eventPattern, hubPattern, urlTemplate string + if upstreamTemplate.HubPattern != nil { categoryPattern = *upstreamTemplate.HubPattern } - eventPattern := "" if upstreamTemplate.EventPattern != nil { eventPattern = *upstreamTemplate.EventPattern } - hubPattern := "" if upstreamTemplate.HubPattern != nil { hubPattern = *upstreamTemplate.HubPattern } - urlTemplate := "" if upstreamTemplate.URLTemplate != nil { urlTemplate = *upstreamTemplate.URLTemplate } From e407225027396afbecf0abf532e886809bbe41dc Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Tue, 9 Feb 2021 23:29:11 -0600 Subject: [PATCH 06/15] Fix acceptance test --- .../signalr/signalr_service_resource.go | 38 ++++++++----------- .../signalr/signalr_service_resource_test.go | 27 ++++++------- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index 75f8a891dfc6..c5b2bff6f83e 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -103,7 +103,6 @@ func resourceArmSignalRService() *schema.Resource { "upstream_setting": { Type: schema.TypeSet, Optional: true, - Computed: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "category_pattern": { @@ -328,7 +327,7 @@ func resourceArmSignalRServiceUpdate(d *schema.ResourceData, meta interface{}) e resourceType := &signalr.ResourceType{} - if d.HasChanges("cors", "features") { + if d.HasChanges("cors", "features", "upstream_setting") { resourceType.Properties = &signalr.Properties{} if d.HasChange("cors") { @@ -437,9 +436,9 @@ func expandUpstreamSettings(input []interface{}) *signalr.ServerlessUpstreamSett setting := upstreamSetting.(map[string]interface{}) upstreamTemplate := &signalr.UpstreamTemplate{ - HubPattern: utils.String(setting["category_pattern"].(string)), + HubPattern: utils.String(setting["hub_pattern"].(string)), EventPattern: utils.String(setting["event_pattern"].(string)), - CategoryPattern: utils.String(setting["hub_pattern"].(string)), + CategoryPattern: utils.String(setting["category_pattern"].(string)), URLTemplate: utils.String(setting["url_template"].(string)), } @@ -452,33 +451,28 @@ func expandUpstreamSettings(input []interface{}) *signalr.ServerlessUpstreamSett } func flattenUpstreamSettings(upstreamSettings *signalr.ServerlessUpstreamSettings) []interface{} { + result := make([]interface{}, 0) if upstreamSettings == nil || upstreamSettings.Templates == nil { - return []interface{}{} + return result } - result := make([]interface{}, 0) - for _, upstreamTemplate := range *upstreamSettings.Templates { - var categoryPattern, eventPattern, hubPattern, urlTemplate string + for _, settings := range *upstreamSettings.Templates { + upstreamSetting := make(map[string]interface{}) - if upstreamTemplate.HubPattern != nil { - categoryPattern = *upstreamTemplate.HubPattern + if settings.CategoryPattern != nil { + upstreamSetting["category_pattern"] = *settings.CategoryPattern } - if upstreamTemplate.EventPattern != nil { - eventPattern = *upstreamTemplate.EventPattern + if settings.EventPattern != nil { + upstreamSetting["event_pattern"] = *settings.EventPattern } - if upstreamTemplate.HubPattern != nil { - hubPattern = *upstreamTemplate.HubPattern + if settings.HubPattern != nil { + upstreamSetting["hub_pattern"] = *settings.HubPattern } - if upstreamTemplate.URLTemplate != nil { - urlTemplate = *upstreamTemplate.URLTemplate + if settings.URLTemplate != nil { + upstreamSetting["url_template"] = *settings.URLTemplate } - result = append(result, map[string]interface{}{ - "category_pattern": categoryPattern, - "event_pattern": eventPattern, - "hub_pattern": hubPattern, - "url_template": urlTemplate, - }) + result = append(result, upstreamSetting) } return result } diff --git a/azurerm/internal/services/signalr/signalr_service_resource_test.go b/azurerm/internal/services/signalr/signalr_service_resource_test.go index d3bb74434b9b..476cc0da6b19 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource_test.go +++ b/azurerm/internal/services/signalr/signalr_service_resource_test.go @@ -342,24 +342,9 @@ func TestAccSignalRService_upstreamSetting(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("upstream_setting.#").HasValue("4"), - check.That(data.ResourceName).Key("upstream_setting.0.category_pattern").DoesNotExist(), - check.That(data.ResourceName).Key("upstream_setting.0.event_pattern").DoesNotExist(), - check.That(data.ResourceName).Key("upstream_setting.0.hub_pattern").DoesNotExist(), - check.That(data.ResourceName).Key("upstream_setting.0.url_template").HasValue("http://foo.com"), - check.That(data.ResourceName).Key("upstream_setting.1.category_pattern").HasValue("connections,messages"), - check.That(data.ResourceName).Key("upstream_setting.1.event_pattern").HasValue("*"), - check.That(data.ResourceName).Key("upstream_setting.1.hub_pattern").HasValue("hub1"), - check.That(data.ResourceName).Key("upstream_setting.1.url_template").HasValue("http://foo.com"), - check.That(data.ResourceName).Key("upstream_setting.2.category_pattern").HasValue("*"), - check.That(data.ResourceName).Key("upstream_setting.2.event_pattern").HasValue("connect,disconnect"), - check.That(data.ResourceName).Key("upstream_setting.2.hub_pattern").HasValue("hub1,hub2"), - check.That(data.ResourceName).Key("upstream_setting.2.url_template").HasValue("http://foo3.com"), - check.That(data.ResourceName).Key("upstream_setting.3.category_pattern").HasValue("connections"), - check.That(data.ResourceName).Key("upstream_setting.3.event_pattern").HasValue("disconnect"), - check.That(data.ResourceName).Key("upstream_setting.3.hub_pattern").HasValue("*"), - check.That(data.ResourceName).Key("upstream_setting.3.url_template").HasValue("http://foo4.com"), ), }, + data.ImportStep(), }) } @@ -539,6 +524,16 @@ resource "azurerm_signalr_service" "test" { value = "Serverless" } + features { + flag = "EnableConnectivityLogs" + value = "False" + } + + features { + flag = "EnableMessagingLogs" + value = "False" + } + upstream_setting { url_template = "http://foo.com" } From 18b16e6ad3d9043e94c2535a8823c2093f58bb0e Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Thu, 11 Feb 2021 21:51:38 -0600 Subject: [PATCH 07/15] Code review feedback changes --- .../signalr/signalr_service_resource.go | 80 ++++++++++++++----- .../signalr/signalr_service_resource_test.go | 33 ++++---- .../services/signalr/validate/upstream.go | 17 ++++ .../signalr/validate/upstream_test.go | 63 +++++++++++++++ website/docs/r/signalr_service.html.markdown | 20 ++--- 5 files changed, 166 insertions(+), 47 deletions(-) create mode 100644 azurerm/internal/services/signalr/validate/upstream.go create mode 100644 azurerm/internal/services/signalr/validate/upstream_test.go diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index c5b2bff6f83e..656f514e3cc1 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -3,6 +3,7 @@ package signalr import ( "fmt" "log" + "strings" "time" "github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr" @@ -13,6 +14,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/parse" + "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" @@ -100,29 +102,39 @@ func resourceArmSignalRService() *schema.Resource { }, }, - "upstream_setting": { + "upstream_endpoint": { Type: schema.TypeSet, Optional: true, Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "category_pattern": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, "event_pattern": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, "hub_pattern": { - Type: schema.TypeString, - Optional: true, + Type: schema.TypeList, + Required: true, + Elem: &schema.Schema{ + Type: schema.TypeString, + }, }, "url_template": { - Type: schema.TypeString, - Required: true, + Type: schema.TypeString, + Required: true, + ValidateFunc: validate.UrlTemplate, }, }, }, @@ -217,11 +229,18 @@ func resourceArmSignalRServiceCreate(d *schema.ResourceData, meta interface{}) e featureFlags := d.Get("features").(*schema.Set).List() cors := d.Get("cors").([]interface{}) expandedTags := tags.Expand(t) - upstreamSettings := d.Get("upstream_setting").(*schema.Set).List() + upstreamSettings := d.Get("upstream_endpoint").(*schema.Set).List() + + expandedFeatures := expandSignalRFeatures(featureFlags) + + // Upstream configurations are only allowed when the SignalR service is in `Serverless` mode + if upstreamSettings != nil && !signalRIsInServerlessMode(expandedFeatures) { + return fmt.Errorf("Upstream configurations are only allowed when the SignalR Service is in `Serverless` mode") + } properties := &signalr.Properties{ Cors: expandSignalRCors(cors), - Features: expandSignalRFeatures(featureFlags), + Features: expandedFeatures, Upstream: expandUpstreamSettings(upstreamSettings), } @@ -302,8 +321,8 @@ func resourceArmSignalRServiceRead(d *schema.ResourceData, meta interface{}) err return fmt.Errorf("Error setting `cors`: %+v", err) } - if err := d.Set("upstream_setting", flattenUpstreamSettings(properties.Upstream)); err != nil { - return fmt.Errorf("Error setting `upstream_setting`: %+v", err) + if err := d.Set("upstream_endpoint", flattenUpstreamSettings(properties.Upstream)); err != nil { + return fmt.Errorf("Error setting `upstream_endpoint`: %+v", err) } } @@ -327,7 +346,7 @@ func resourceArmSignalRServiceUpdate(d *schema.ResourceData, meta interface{}) e resourceType := &signalr.ResourceType{} - if d.HasChanges("cors", "features", "upstream_setting") { + if d.HasChanges("cors", "features", "upstream_endpoint") { resourceType.Properties = &signalr.Properties{} if d.HasChange("cors") { @@ -340,8 +359,8 @@ func resourceArmSignalRServiceUpdate(d *schema.ResourceData, meta interface{}) e resourceType.Properties.Features = expandSignalRFeatures(featuresRaw) } - if d.HasChange("upstream_setting") { - featuresRaw := d.Get("upstream_setting").(*schema.Set).List() + if d.HasChange("upstream_endpoint") { + featuresRaw := d.Get("upstream_endpoint").(*schema.Set).List() resourceType.Properties.Upstream = expandUpstreamSettings(featuresRaw) } } @@ -393,6 +412,20 @@ func resourceArmSignalRServiceDelete(d *schema.ResourceData, meta interface{}) e return nil } +func signalRIsInServerlessMode(features *[]signalr.Feature) bool { + if features == nil { + return false + } + + for _, feature := range *features { + if feature.Flag == signalr.ServiceMode && feature.Value != nil { + return *feature.Value == "Serverless" + } + } + + return false +} + func expandSignalRFeatures(input []interface{}) *[]signalr.Feature { features := make([]signalr.Feature, 0) for _, featureValue := range input { @@ -436,9 +469,9 @@ func expandUpstreamSettings(input []interface{}) *signalr.ServerlessUpstreamSett setting := upstreamSetting.(map[string]interface{}) upstreamTemplate := &signalr.UpstreamTemplate{ - HubPattern: utils.String(setting["hub_pattern"].(string)), - EventPattern: utils.String(setting["event_pattern"].(string)), - CategoryPattern: utils.String(setting["category_pattern"].(string)), + HubPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["hub_pattern"].([]interface{})), ",")), + EventPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["event_pattern"].([]interface{})), ",")), + CategoryPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["category_pattern"].([]interface{})), ",")), URLTemplate: utils.String(setting["url_template"].(string)), } @@ -460,13 +493,16 @@ func flattenUpstreamSettings(upstreamSettings *signalr.ServerlessUpstreamSetting upstreamSetting := make(map[string]interface{}) if settings.CategoryPattern != nil { - upstreamSetting["category_pattern"] = *settings.CategoryPattern + categoryPatterns := strings.Split(*settings.CategoryPattern, ",") + upstreamSetting["category_pattern"] = utils.FlattenStringSlice(&categoryPatterns) } if settings.EventPattern != nil { - upstreamSetting["event_pattern"] = *settings.EventPattern + eventPatterns := strings.Split(*settings.EventPattern, ",") + upstreamSetting["event_pattern"] = utils.FlattenStringSlice(&eventPatterns) } if settings.HubPattern != nil { - upstreamSetting["hub_pattern"] = *settings.HubPattern + hubPatterns := strings.Split(*settings.HubPattern, ",") + upstreamSetting["hub_pattern"] = utils.FlattenStringSlice(&hubPatterns) } if settings.URLTemplate != nil { upstreamSetting["url_template"] = *settings.URLTemplate diff --git a/azurerm/internal/services/signalr/signalr_service_resource_test.go b/azurerm/internal/services/signalr/signalr_service_resource_test.go index 476cc0da6b19..97cbee3ad6ff 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource_test.go +++ b/azurerm/internal/services/signalr/signalr_service_resource_test.go @@ -341,7 +341,7 @@ func TestAccSignalRService_upstreamSetting(t *testing.T) { Config: r.withUpstreamSettings(data), Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("upstream_setting.#").HasValue("4"), + check.That(data.ResourceName).Key("upstream_endpoint.#").HasValue("4"), ), }, data.ImportStep(), @@ -534,28 +534,31 @@ resource "azurerm_signalr_service" "test" { value = "False" } - upstream_setting { - url_template = "http://foo.com" + upstream_endpoint { + category_pattern = ["*"] + event_pattern = ["*"] + hub_pattern = ["*"] + url_template = "http://foo.com/{hub}/api/{category}/{event}" } - upstream_setting { - category_pattern = "connections,messages" - event_pattern = "*" - hub_pattern = "hub1" + upstream_endpoint { + category_pattern = ["connections", "messages"] + event_pattern = ["*"] + hub_pattern = ["hub1"] url_template = "http://foo.com" } - upstream_setting { - category_pattern = "*" - event_pattern = "connect,disconnect" - hub_pattern = "hub1,hub2" + upstream_endpoint { + category_pattern = ["*"] + event_pattern = ["connect", "disconnect"] + hub_pattern = ["hub1", "hub2"] url_template = "http://foo3.com" } - upstream_setting { - category_pattern = "connections" - event_pattern = "disconnect" - hub_pattern = "*" + upstream_endpoint { + category_pattern = ["connections"] + event_pattern = ["disconnect"] + hub_pattern = ["*"] url_template = "http://foo4.com" } } diff --git a/azurerm/internal/services/signalr/validate/upstream.go b/azurerm/internal/services/signalr/validate/upstream.go new file mode 100644 index 000000000000..7f62bac8045b --- /dev/null +++ b/azurerm/internal/services/signalr/validate/upstream.go @@ -0,0 +1,17 @@ +package validate + +import ( + "fmt" + "regexp" +) + +func UrlTemplate(v interface{}, k string) (warnings []string, errors []error) { + upstreamURL := v.(string) + + if !regexp.MustCompile(`^https?://[^\s]+$`).MatchString(upstreamURL) { + errors = append(errors, fmt.Errorf( + "%q must start with http:// or https:// and must not contain whitespaces: %q", k, upstreamURL)) + } + + return warnings, errors +} diff --git a/azurerm/internal/services/signalr/validate/upstream_test.go b/azurerm/internal/services/signalr/validate/upstream_test.go new file mode 100644 index 000000000000..359675ef940b --- /dev/null +++ b/azurerm/internal/services/signalr/validate/upstream_test.go @@ -0,0 +1,63 @@ +package validate + +import "testing" + +func TestUrlTemplate(t *testing.T) { + cases := []struct { + Input string + Valid bool + }{ + + { + // empty + Input: "", + Valid: false, + }, + + { + // not a url + Input: "not a url", + Valid: false, + }, + + { + // contains http + Input: "http", + Valid: false, + }, + + { + // not correct + Input: "http:/", + Valid: false, + }, + + { + // empty + Input: "http://", + Valid: false, + }, + + { + // right + Input: "http://abc.com", + Valid: true, + }, + + { + // multi path + Input: "https://abc.com/api/test", + Valid: true, + }, + } + for _, tc := range cases { + t.Logf("[DEBUG] Testing Value %s", tc.Input) + + _, errors := UrlTemplate(tc.Input, "test") + valid := len(errors) == 0 + + if tc.Valid != valid { + t.Fatalf("Expected %t but got %t", tc.Valid, valid) + } + } +} diff --git a/website/docs/r/signalr_service.html.markdown b/website/docs/r/signalr_service.html.markdown index 17b772c3595d..892004c5882b 100644 --- a/website/docs/r/signalr_service.html.markdown +++ b/website/docs/r/signalr_service.html.markdown @@ -37,10 +37,10 @@ resource "azurerm_signalr_service" "example" { value = "Default" } - upstream_setting { - category_pattern = "connections,messages" - event_pattern = "*" - hub_pattern = "hub1" + upstream_endpoint { + category_pattern = ["connections" , "messages"] + event_pattern = ["*"] + hub_pattern = ["hub1"] url_template = "http://foo.com" } } @@ -62,7 +62,7 @@ The following arguments are supported: * `features` - (Optional) A `features` block as documented below. -* `upstream_setting` - (Optional) An `upstream_setting` block as documented below. Using this block requires the SignalR service to be Serverless. +* `upstream_endpoint` - (Optional) An `upstream_endpoint` block as documented below. Using this block requires the SignalR service to be Serverless. When creating multiple blocks they will be processed in the order they are defined in. * `tags` - (Optional) A mapping of tags to assign to the resource. @@ -82,15 +82,15 @@ A `features` block supports the following: --- -An `upstream_setting` block supports the following: +An `upstream_endpoint` block supports the following: -* `url_template` - (Required) The upstream URL Template. Possible values are `EnableConnectivityLogs`, `EnableMessagingLogs`, and `ServiceMode`. +* `url_template` - (Required) The upstream URL Template. This can be a url or a template such as `http://host.com/{hub}/api/{category}/{event}`. -* `category_pattern` - (Optional) The matching pattern for category names. Possible values are `*`, multiple categories separated by commas `,`, and single categories. Ex: `connections,messages`, `*`, and `connections`. +* `category_pattern` - (Optional) The categories to match on, or `*` for all. -* `event_pattern` - (Optional) The matching pattern for event names. Possible values are `*`, multiple events separated by commas `,`, and single events. Ex: `connect,disconnect`, `*`, and `connect`. +* `event_pattern` - (Optional) The events to match on, or `*` for all. -* `hub_pattern` - (Optional) The matching mattern for hub names. Possible values are `*`, multiple hubs separated by commas `,`, and single hubs. Ex: `hub1,hub1`, `*`, `hub1`. +* `hub_pattern` - (Optional) The hubs to match on, or `*` for all. --- From 9aaba5e3c4110c1e95661974ef39f7cac139f480 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Fri, 12 Feb 2021 09:22:59 -0600 Subject: [PATCH 08/15] Rename test to match new property name --- .../services/signalr/signalr_service_resource_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource_test.go b/azurerm/internal/services/signalr/signalr_service_resource_test.go index 97cbee3ad6ff..65d034e8854e 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource_test.go +++ b/azurerm/internal/services/signalr/signalr_service_resource_test.go @@ -338,7 +338,7 @@ func TestAccSignalRService_upstreamSetting(t *testing.T) { data.ResourceTest(t, r, []resource.TestStep{ { - Config: r.withUpstreamSettings(data), + Config: r.withUpstreamEndpoints(data), Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("upstream_endpoint.#").HasValue("4"), @@ -498,7 +498,7 @@ resource "azurerm_signalr_service" "test" { `, data.RandomInteger, data.Locations.Primary, data.RandomInteger, serviceMode) } -func (r SignalRServiceResource) withUpstreamSettings(data acceptance.TestData) string { +func (r SignalRServiceResource) withUpstreamEndpoints(data acceptance.TestData) string { return fmt.Sprintf(` provider "azurerm" { features {} From d82b94d1b0d1682c4283157856133612d926917b Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Fri, 12 Feb 2021 09:25:58 -0600 Subject: [PATCH 09/15] No empty strings on upstream patterns --- .../services/signalr/signalr_service_resource.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index 656f514e3cc1..cd0fa293ef8c 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -14,7 +14,7 @@ import ( "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/parse" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/validate" + signalrValidate "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/signalr/validate" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" azSchema "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tf/schema" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" @@ -111,7 +111,8 @@ func resourceArmSignalRService() *schema.Resource { Type: schema.TypeList, Required: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, }, }, @@ -119,7 +120,8 @@ func resourceArmSignalRService() *schema.Resource { Type: schema.TypeList, Required: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, }, }, @@ -127,14 +129,15 @@ func resourceArmSignalRService() *schema.Resource { Type: schema.TypeList, Required: true, Elem: &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeString, + ValidateFunc: validation.StringIsNotEmpty, }, }, "url_template": { Type: schema.TypeString, Required: true, - ValidateFunc: validate.UrlTemplate, + ValidateFunc: signalrValidate.UrlTemplate, }, }, }, From e98d65ef0e074e0e6daa1dd288f07cc955c2a8d8 Mon Sep 17 00:00:00 2001 From: Jack Date: Thu, 11 Feb 2021 21:54:57 -0600 Subject: [PATCH 10/15] Update signalr_service.html.markdown --- website/docs/r/signalr_service.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/signalr_service.html.markdown b/website/docs/r/signalr_service.html.markdown index 892004c5882b..acf1b5e3161f 100644 --- a/website/docs/r/signalr_service.html.markdown +++ b/website/docs/r/signalr_service.html.markdown @@ -38,7 +38,7 @@ resource "azurerm_signalr_service" "example" { } upstream_endpoint { - category_pattern = ["connections" , "messages"] + category_pattern = ["connections", "messages"] event_pattern = ["*"] hub_pattern = ["hub1"] url_template = "http://foo.com" From c55b724d475c61bff383893af647d11ac265d949 Mon Sep 17 00:00:00 2001 From: jackofallops Date: Thu, 18 Feb 2021 16:55:37 +0000 Subject: [PATCH 11/15] dependencies update --- .../mgmt/2020-05-01/signalr/CHANGELOG.md | 6 +---- .../signalr/mgmt/2020-05-01/signalr/models.go | 22 ++++--------------- .../signalr/privateendpointconnections.go | 20 +++++++++++++++-- .../signalr/privatelinkresources.go | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md index 2df7a3c94f21..5d45fa9e651f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/CHANGELOG.md @@ -1,9 +1,5 @@ -Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82//specification/signalr/resource-manager/readme.md tag: `package-2018-10-01` +Generated from https://github.com/Azure/azure-rest-api-specs/tree/3c764635e7d442b3e74caf593029fcd440b3ef82//specification/signalr/resource-manager/readme.md tag: `package-2020-05-01` Code generator @microsoft.azure/autorest.go@2.1.171 -- Function `NewPrivateLinkResourceListPage` parameter(s) have been changed from `(func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error))` to `(PrivateLinkResourceList, func(context.Context, PrivateLinkResourceList) (PrivateLinkResourceList, error))` -- Function `NewOperationListPage` parameter(s) have been changed from `(func(context.Context, OperationList) (OperationList, error))` to `(OperationList, func(context.Context, OperationList) (OperationList, error))` -- Function `NewUsageListPage` parameter(s) have been changed from `(func(context.Context, UsageList) (UsageList, error))` to `(UsageList, func(context.Context, UsageList) (UsageList, error))` -- Function `NewResourceListPage` parameter(s) have been changed from `(func(context.Context, ResourceList) (ResourceList, error))` to `(ResourceList, func(context.Context, ResourceList) (ResourceList, error))` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go index 4dc5172cca43..b0c6fe2161c9 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/models.go @@ -518,24 +518,10 @@ func (pecp PrivateEndpointConnectionProperties) MarshalJSON() ([]byte, error) { // PrivateEndpointConnectionsDeleteFuture an abstraction for monitoring and retrieving the results of a // long-running operation. type PrivateEndpointConnectionsDeleteFuture struct { - azure.Future -} - -// Result returns the result of the asynchronous operation. -// If the operation has not completed it will return an error. -func (future *PrivateEndpointConnectionsDeleteFuture) Result(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { - var done bool - done, err = future.DoneWithContext(context.Background(), client) - if err != nil { - err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") - return - } - if !done { - err = azure.NewAsyncOpIncompleteError("signalr.PrivateEndpointConnectionsDeleteFuture") - return - } - ar.Response = future.Response() - return + azure.FutureAPI + // Result returns the result of the asynchronous operation. + // If the operation has not completed it will return an error. + Result func(PrivateEndpointConnectionsClient) (autorest.Response, error) } // PrivateLinkResource private link resource diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go index faab2191c75e..1a3f968ddd83 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privateendpointconnections.go @@ -68,7 +68,7 @@ func (client PrivateEndpointConnectionsClient) Delete(ctx context.Context, priva result, err = client.DeleteSender(req) if err != nil { - err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", result.Response(), "Failure sending request") + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsClient", "Delete", nil, "Failure sending request") return } @@ -105,7 +105,23 @@ func (client PrivateEndpointConnectionsClient) DeleteSender(req *http.Request) ( if err != nil { return } - future.Future, err = azure.NewFutureFromResponse(resp) + var azf azure.Future + azf, err = azure.NewFutureFromResponse(resp) + future.FutureAPI = &azf + future.Result = func(client PrivateEndpointConnectionsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "signalr.PrivateEndpointConnectionsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("signalr.PrivateEndpointConnectionsDeleteFuture") + return + } + ar.Response = future.Response() + return + } return } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go index f44ac63394b2..df293494e5fe 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/signalr/mgmt/2020-05-01/signalr/privatelinkresources.go @@ -79,6 +79,7 @@ func (client PrivateLinkResourcesClient) List(ctx context.Context, resourceGroup } if result.plrl.hasNextLink() && result.plrl.IsEmpty() { err = result.NextWithContext(ctx) + return } return @@ -140,7 +141,6 @@ func (client PrivateLinkResourcesClient) listNextResults(ctx context.Context, la result, err = client.ListResponder(resp) if err != nil { err = autorest.NewErrorWithError(err, "signalr.PrivateLinkResourcesClient", "listNextResults", resp, "Failure responding to next results request") - return } return } From 5332ba3d254a64c4f45b289195127eda4dce9b73 Mon Sep 17 00:00:00 2001 From: jackofallops Date: Thu, 18 Feb 2021 17:34:56 +0000 Subject: [PATCH 12/15] fix check for upstream setting --- azurerm/internal/services/signalr/signalr_service_resource.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index cd0fa293ef8c..049d8f322606 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -237,7 +237,7 @@ func resourceArmSignalRServiceCreate(d *schema.ResourceData, meta interface{}) e expandedFeatures := expandSignalRFeatures(featureFlags) // Upstream configurations are only allowed when the SignalR service is in `Serverless` mode - if upstreamSettings != nil && !signalRIsInServerlessMode(expandedFeatures) { + if len(upstreamSettings) > 0 && !signalRIsInServerlessMode(expandedFeatures) { return fmt.Errorf("Upstream configurations are only allowed when the SignalR Service is in `Serverless` mode") } From 56b3bab1858a9a50ad264baf2a4b938db9e920ea Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Tue, 16 Feb 2021 11:52:57 +0100 Subject: [PATCH 13/15] r/kubernetes_cluster: fixing pr comments --- .../kubernetes_cluster_data_source.go | 21 ++++++++++++++++--- .../kubernetes_cluster_node_pool_resource.go | 10 ++++----- ...ernetes_cluster_node_pool_resource_test.go | 2 +- .../kubernetes_cluster_upgrade_test.go | 2 +- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/azurerm/internal/services/containers/kubernetes_cluster_data_source.go b/azurerm/internal/services/containers/kubernetes_cluster_data_source.go index f02d14e90647..7dcb7e01d42a 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_data_source.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_data_source.go @@ -872,6 +872,11 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi } for _, profile := range *input { + agentType := "" + if profile.Type != "" { + agentType = string(profile.Type) + } + count := 0 if profile.Count != nil { count = int(*profile.Count) @@ -897,6 +902,11 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi name = *profile.Name } + vmSize := "" + if profile.VMSize != "" { + vmSize = string(profile.VMSize) + } + osDiskSizeGb := 0 if profile.OsDiskSizeGB != nil { osDiskSizeGb = int(*profile.OsDiskSizeGB) @@ -907,6 +917,11 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi vnetSubnetId = *profile.VnetSubnetID } + osType := "" + if profile.OsType != "" { + osType = string(profile.OsType) + } + orchestratorVersion := "" if profile.OrchestratorVersion != nil && *profile.OrchestratorVersion != "" { orchestratorVersion = *profile.OrchestratorVersion @@ -951,11 +966,11 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi "node_taints": nodeTaints, "orchestrator_version": orchestratorVersion, "os_disk_size_gb": osDiskSizeGb, - "os_type": string(profile.OsType), + "os_type": osType, "tags": tags.Flatten(profile.Tags), - "type": string(profile.Type), + "type": agentType, "upgrade_settings": flattenUpgradeSettings(profile.UpgradeSettings), - "vm_size": string(profile.VMSize), + "vm_size": vmSize, "vnet_subnet_id": vnetSubnetId, }) } diff --git a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 8a29bd870eb5..06a0a4e3a7bf 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -765,13 +765,13 @@ func expandUpgradeSettings(input []interface{}) *containerservice.AgentPoolUpgra } func flattenUpgradeSettings(input *containerservice.AgentPoolUpgradeSettings) []interface{} { - maxSurge := "" - if input != nil && input.MaxSurge != nil { - maxSurge = *input.MaxSurge + if input == nil { + return []interface{}{} } - if maxSurge == "" { - return []interface{}{} + maxSurge := "" + if input.MaxSurge != nil { + maxSurge = *input.MaxSurge } return []interface{}{ diff --git a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go index 1f2c81364ce6..3d1c07be4fbe 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go @@ -621,7 +621,7 @@ func testAccKubernetesClusterNodePool_upgradeSettings(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("upgrade_settings.#").HasValue("1"), - check.That(data.ResourceName).Key("upgrade_settings.0.max_surge").HasValue("4"), + check.That(data.ResourceName).Key("upgrade_settings.0.max_surge").HasValue("2"), ), }, data.ImportStep(), diff --git a/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go b/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go index 4541d2d7ae1c..7cc553c5e303 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go @@ -281,7 +281,7 @@ func TestAccKubernetesCluster_upgradeSettings(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.#").HasValue("1"), - check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.0.max_surge").HasValue("2"), + check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.0.max_surge").HasValue("4"), ), }, data.ImportStep(), From a6a1d705d6ee53526f16b20612195e03a0440a35 Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Fri, 19 Feb 2021 13:02:47 -0600 Subject: [PATCH 14/15] Address feedback --- .../signalr/signalr_service_resource.go | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/azurerm/internal/services/signalr/signalr_service_resource.go b/azurerm/internal/services/signalr/signalr_service_resource.go index 049d8f322606..846c7de43529 100644 --- a/azurerm/internal/services/signalr/signalr_service_resource.go +++ b/azurerm/internal/services/signalr/signalr_service_resource.go @@ -471,14 +471,14 @@ func expandUpstreamSettings(input []interface{}) *signalr.ServerlessUpstreamSett for _, upstreamSetting := range input { setting := upstreamSetting.(map[string]interface{}) - upstreamTemplate := &signalr.UpstreamTemplate{ + upstreamTemplate := signalr.UpstreamTemplate{ HubPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["hub_pattern"].([]interface{})), ",")), EventPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["event_pattern"].([]interface{})), ",")), CategoryPattern: utils.String(strings.Join(*utils.ExpandStringSlice(setting["category_pattern"].([]interface{})), ",")), URLTemplate: utils.String(setting["url_template"].(string)), } - upstreamTemplates = append(upstreamTemplates, *upstreamTemplate) + upstreamTemplates = append(upstreamTemplates, upstreamTemplate) } return &signalr.ServerlessUpstreamSettings{ @@ -493,25 +493,35 @@ func flattenUpstreamSettings(upstreamSettings *signalr.ServerlessUpstreamSetting } for _, settings := range *upstreamSettings.Templates { - upstreamSetting := make(map[string]interface{}) - + categoryPattern := make([]interface{}, 0) if settings.CategoryPattern != nil { categoryPatterns := strings.Split(*settings.CategoryPattern, ",") - upstreamSetting["category_pattern"] = utils.FlattenStringSlice(&categoryPatterns) + categoryPattern = utils.FlattenStringSlice(&categoryPatterns) } + + eventPattern := make([]interface{}, 0) if settings.EventPattern != nil { eventPatterns := strings.Split(*settings.EventPattern, ",") - upstreamSetting["event_pattern"] = utils.FlattenStringSlice(&eventPatterns) + eventPattern = utils.FlattenStringSlice(&eventPatterns) } + + hubPattern := make([]interface{}, 0) if settings.HubPattern != nil { hubPatterns := strings.Split(*settings.HubPattern, ",") - upstreamSetting["hub_pattern"] = utils.FlattenStringSlice(&hubPatterns) + hubPattern = utils.FlattenStringSlice(&hubPatterns) } + + urlTemplate := "" if settings.URLTemplate != nil { - upstreamSetting["url_template"] = *settings.URLTemplate + urlTemplate = *settings.URLTemplate } - result = append(result, upstreamSetting) + result = append(result, map[string]interface{}{ + "url_template": urlTemplate, + "hub_pattern": hubPattern, + "event_pattern": eventPattern, + "category_pattern": categoryPattern, + }) } return result } From 9c13912add7696d3cebf903da37172d0cc95aebb Mon Sep 17 00:00:00 2001 From: Jack Batzner Date: Fri, 19 Feb 2021 13:16:39 -0600 Subject: [PATCH 15/15] Revert "r/kubernetes_cluster: fixing pr comments" This reverts commit 56b3bab1858a9a50ad264baf2a4b938db9e920ea. --- .../kubernetes_cluster_data_source.go | 21 +++---------------- .../kubernetes_cluster_node_pool_resource.go | 10 ++++----- ...ernetes_cluster_node_pool_resource_test.go | 2 +- .../kubernetes_cluster_upgrade_test.go | 2 +- 4 files changed, 10 insertions(+), 25 deletions(-) diff --git a/azurerm/internal/services/containers/kubernetes_cluster_data_source.go b/azurerm/internal/services/containers/kubernetes_cluster_data_source.go index 7dcb7e01d42a..f02d14e90647 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_data_source.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_data_source.go @@ -872,11 +872,6 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi } for _, profile := range *input { - agentType := "" - if profile.Type != "" { - agentType = string(profile.Type) - } - count := 0 if profile.Count != nil { count = int(*profile.Count) @@ -902,11 +897,6 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi name = *profile.Name } - vmSize := "" - if profile.VMSize != "" { - vmSize = string(profile.VMSize) - } - osDiskSizeGb := 0 if profile.OsDiskSizeGB != nil { osDiskSizeGb = int(*profile.OsDiskSizeGB) @@ -917,11 +907,6 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi vnetSubnetId = *profile.VnetSubnetID } - osType := "" - if profile.OsType != "" { - osType = string(profile.OsType) - } - orchestratorVersion := "" if profile.OrchestratorVersion != nil && *profile.OrchestratorVersion != "" { orchestratorVersion = *profile.OrchestratorVersion @@ -966,11 +951,11 @@ func flattenKubernetesClusterDataSourceAgentPoolProfiles(input *[]containerservi "node_taints": nodeTaints, "orchestrator_version": orchestratorVersion, "os_disk_size_gb": osDiskSizeGb, - "os_type": osType, + "os_type": string(profile.OsType), "tags": tags.Flatten(profile.Tags), - "type": agentType, + "type": string(profile.Type), "upgrade_settings": flattenUpgradeSettings(profile.UpgradeSettings), - "vm_size": vmSize, + "vm_size": string(profile.VMSize), "vnet_subnet_id": vnetSubnetId, }) } diff --git a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go index 06a0a4e3a7bf..8a29bd870eb5 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource.go @@ -765,15 +765,15 @@ func expandUpgradeSettings(input []interface{}) *containerservice.AgentPoolUpgra } func flattenUpgradeSettings(input *containerservice.AgentPoolUpgradeSettings) []interface{} { - if input == nil { - return []interface{}{} - } - maxSurge := "" - if input.MaxSurge != nil { + if input != nil && input.MaxSurge != nil { maxSurge = *input.MaxSurge } + if maxSurge == "" { + return []interface{}{} + } + return []interface{}{ map[string]interface{}{ "max_surge": maxSurge, diff --git a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go index 3d1c07be4fbe..1f2c81364ce6 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_node_pool_resource_test.go @@ -621,7 +621,7 @@ func testAccKubernetesClusterNodePool_upgradeSettings(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("upgrade_settings.#").HasValue("1"), - check.That(data.ResourceName).Key("upgrade_settings.0.max_surge").HasValue("2"), + check.That(data.ResourceName).Key("upgrade_settings.0.max_surge").HasValue("4"), ), }, data.ImportStep(), diff --git a/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go b/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go index 7cc553c5e303..4541d2d7ae1c 100644 --- a/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go +++ b/azurerm/internal/services/containers/kubernetes_cluster_upgrade_test.go @@ -281,7 +281,7 @@ func TestAccKubernetesCluster_upgradeSettings(t *testing.T) { Check: resource.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.#").HasValue("1"), - check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.0.max_surge").HasValue("4"), + check.That(data.ResourceName).Key("default_node_pool.0.upgrade_settings.0.max_surge").HasValue("2"), ), }, data.ImportStep(),