diff --git a/profiles/preview/preview/eventhub/mgmt/eventhub/models.go b/profiles/preview/preview/eventhub/mgmt/eventhub/models.go index 8e50aea1db74..43c7fc4ad6b9 100644 --- a/profiles/preview/preview/eventhub/mgmt/eventhub/models.go +++ b/profiles/preview/preview/eventhub/mgmt/eventhub/models.go @@ -29,6 +29,13 @@ const ( DefaultBaseURI = original.DefaultBaseURI ) +type DefaultAction = original.DefaultAction + +const ( + Allow DefaultAction = original.Allow + Deny DefaultAction = original.Deny +) + type IPAction = original.IPAction const ( @@ -36,6 +43,12 @@ const ( Reject IPAction = original.Reject ) +type NetworkRuleIPAction = original.NetworkRuleIPAction + +const ( + NetworkRuleIPActionAllow NetworkRuleIPAction = original.NetworkRuleIPActionAllow +) + type SkuName = original.SkuName const ( @@ -72,9 +85,13 @@ type IPFilterRuleListResult = original.IPFilterRuleListResult type IPFilterRuleListResultIterator = original.IPFilterRuleListResultIterator type IPFilterRuleListResultPage = original.IPFilterRuleListResultPage type IPFilterRuleProperties = original.IPFilterRuleProperties +type NWRuleSetIPRules = original.NWRuleSetIPRules +type NWRuleSetVirtualNetworkRules = original.NWRuleSetVirtualNetworkRules type NamespacesClient = original.NamespacesClient type NamespacesCreateOrUpdateFuture = original.NamespacesCreateOrUpdateFuture type NamespacesDeleteFuture = original.NamespacesDeleteFuture +type NetworkRuleSet = original.NetworkRuleSet +type NetworkRuleSetProperties = original.NetworkRuleSetProperties type Operation = original.Operation type OperationDisplay = original.OperationDisplay type OperationListResult = original.OperationListResult @@ -83,6 +100,7 @@ type OperationListResultPage = original.OperationListResultPage type OperationsClient = original.OperationsClient type Resource = original.Resource type Sku = original.Sku +type Subnet = original.Subnet type TrackedResource = original.TrackedResource type VirtualNetworkRule = original.VirtualNetworkRule type VirtualNetworkRuleListResult = original.VirtualNetworkRuleListResult @@ -150,9 +168,15 @@ func NewVirtualNetworkRuleListResultPage(getNextPage func(context.Context, Virtu func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } +func PossibleDefaultActionValues() []DefaultAction { + return original.PossibleDefaultActionValues() +} func PossibleIPActionValues() []IPAction { return original.PossibleIPActionValues() } +func PossibleNetworkRuleIPActionValues() []NetworkRuleIPAction { + return original.PossibleNetworkRuleIPActionValues() +} func PossibleSkuNameValues() []SkuName { return original.PossibleSkuNameValues() } diff --git a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/eventhubapi/interfaces.go b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/eventhubapi/interfaces.go index 7ab0d6a3439c..213fca1621f7 100644 --- a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/eventhubapi/interfaces.go +++ b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/eventhubapi/interfaces.go @@ -51,12 +51,14 @@ var _ ConfigurationClientAPI = (*eventhub.ConfigurationClient)(nil) type NamespacesClientAPI interface { CreateOrUpdate(ctx context.Context, resourceGroupName string, namespaceName string, parameters eventhub.EHNamespace) (result eventhub.NamespacesCreateOrUpdateFuture, err error) CreateOrUpdateIPFilterRule(ctx context.Context, resourceGroupName string, namespaceName string, IPFilterRuleName string, parameters eventhub.IPFilterRule) (result eventhub.IPFilterRule, err error) + CreateOrUpdateNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string, parameters eventhub.NetworkRuleSet) (result eventhub.NetworkRuleSet, err error) CreateOrUpdateVirtualNetworkRule(ctx context.Context, resourceGroupName string, namespaceName string, virtualNetworkRuleName string, parameters eventhub.VirtualNetworkRule) (result eventhub.VirtualNetworkRule, err error) Delete(ctx context.Context, resourceGroupName string, namespaceName string) (result eventhub.NamespacesDeleteFuture, err error) DeleteIPFilterRule(ctx context.Context, resourceGroupName string, namespaceName string, IPFilterRuleName string) (result autorest.Response, err error) DeleteVirtualNetworkRule(ctx context.Context, resourceGroupName string, namespaceName string, virtualNetworkRuleName string) (result autorest.Response, err error) Get(ctx context.Context, resourceGroupName string, namespaceName string) (result eventhub.EHNamespace, err error) GetIPFilterRule(ctx context.Context, resourceGroupName string, namespaceName string, IPFilterRuleName string) (result eventhub.IPFilterRule, err error) + GetNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string) (result eventhub.NetworkRuleSet, err error) GetVirtualNetworkRule(ctx context.Context, resourceGroupName string, namespaceName string, virtualNetworkRuleName string) (result eventhub.VirtualNetworkRule, err error) List(ctx context.Context) (result eventhub.EHNamespaceListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result eventhub.EHNamespaceListResultPage, err error) diff --git a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/models.go b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/models.go index e0e0d8c0dccd..0581a5091e84 100644 --- a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/models.go +++ b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/models.go @@ -31,6 +31,21 @@ import ( // The package's fully qualified name. const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub" +// DefaultAction enumerates the values for default action. +type DefaultAction string + +const ( + // Allow ... + Allow DefaultAction = "Allow" + // Deny ... + Deny DefaultAction = "Deny" +) + +// PossibleDefaultActionValues returns an array of possible values for the DefaultAction const type. +func PossibleDefaultActionValues() []DefaultAction { + return []DefaultAction{Allow, Deny} +} + // IPAction enumerates the values for ip action. type IPAction string @@ -46,6 +61,19 @@ func PossibleIPActionValues() []IPAction { return []IPAction{Accept, Reject} } +// NetworkRuleIPAction enumerates the values for network rule ip action. +type NetworkRuleIPAction string + +const ( + // NetworkRuleIPActionAllow ... + NetworkRuleIPActionAllow NetworkRuleIPAction = "Allow" +) + +// PossibleNetworkRuleIPActionValues returns an array of possible values for the NetworkRuleIPAction const type. +func PossibleNetworkRuleIPActionValues() []NetworkRuleIPAction { + return []NetworkRuleIPAction{NetworkRuleIPActionAllow} +} + // SkuName enumerates the values for sku name. type SkuName string @@ -1000,6 +1028,114 @@ func (future *NamespacesDeleteFuture) Result(client NamespacesClient) (ar autore return } +// NetworkRuleSet description of topic resource. +type NetworkRuleSet struct { + autorest.Response `json:"-"` + // NetworkRuleSetProperties - NetworkRuleSet properties + *NetworkRuleSetProperties `json:"properties,omitempty"` + // ID - Resource Id + ID *string `json:"id,omitempty"` + // Name - Resource name + Name *string `json:"name,omitempty"` + // Type - Resource type + Type *string `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for NetworkRuleSet. +func (nrs NetworkRuleSet) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if nrs.NetworkRuleSetProperties != nil { + objectMap["properties"] = nrs.NetworkRuleSetProperties + } + if nrs.ID != nil { + objectMap["id"] = nrs.ID + } + if nrs.Name != nil { + objectMap["name"] = nrs.Name + } + if nrs.Type != nil { + objectMap["type"] = nrs.Type + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for NetworkRuleSet struct. +func (nrs *NetworkRuleSet) 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 networkRuleSetProperties NetworkRuleSetProperties + err = json.Unmarshal(*v, &networkRuleSetProperties) + if err != nil { + return err + } + nrs.NetworkRuleSetProperties = &networkRuleSetProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + nrs.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + nrs.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + nrs.Type = &typeVar + } + } + } + + return nil +} + +// NetworkRuleSetProperties networkRuleSet properties +type NetworkRuleSetProperties struct { + // DefaultAction - Default Action for Network Rule Set. Possible values include: 'Allow', 'Deny' + DefaultAction DefaultAction `json:"defaultAction,omitempty"` + // VirtualNetworkRules - List VirtualNetwork Rules + VirtualNetworkRules *[]NWRuleSetVirtualNetworkRules `json:"virtualNetworkRules,omitempty"` + // IPRules - List of IpRules + IPRules *[]NWRuleSetIPRules `json:"ipRules,omitempty"` +} + +// NWRuleSetIPRules the response from the List namespace operation. +type NWRuleSetIPRules struct { + // IPMask - IP Mask + IPMask *string `json:"ipMask,omitempty"` + // Action - The IP Filter Action. Possible values include: 'NetworkRuleIPActionAllow' + Action NetworkRuleIPAction `json:"action,omitempty"` +} + +// NWRuleSetVirtualNetworkRules the response from the List namespace operation. +type NWRuleSetVirtualNetworkRules struct { + // Subnet - Subnet properties + Subnet *Subnet `json:"subnet,omitempty"` + // IgnoreMissingVnetServiceEndpoint - Value that indicates whether to ignore missing Vnet Service Endpoint + IgnoreMissingVnetServiceEndpoint *bool `json:"ignoreMissingVnetServiceEndpoint,omitempty"` +} + // Operation a Event Hub REST API operation type Operation struct { // Name - Operation name: {provider}/{resource}/{operation} @@ -1185,6 +1321,12 @@ type Sku struct { Capacity *int32 `json:"capacity,omitempty"` } +// Subnet properties supplied for Subnet +type Subnet struct { + // ID - Resource ID of Virtual Network Subnet + ID *string `json:"id,omitempty"` +} + // TrackedResource definition of an Azure resource. type TrackedResource struct { // Location - Resource location diff --git a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/namespaces.go b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/namespaces.go index 6dff9ba16b95..a1df214702ab 100644 --- a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/namespaces.go +++ b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/namespaces.go @@ -240,6 +240,96 @@ func (client NamespacesClient) CreateOrUpdateIPFilterRuleResponder(resp *http.Re return } +// CreateOrUpdateNetworkRuleSet create or update NetworkRuleSet for a Namespace. +// Parameters: +// resourceGroupName - name of the resource group within the Azure subscription. +// namespaceName - the Namespace name +// parameters - the Namespace IpFilterRule. +func (client NamespacesClient) CreateOrUpdateNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string, parameters NetworkRuleSet) (result NetworkRuleSet, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.CreateOrUpdateNetworkRuleSet") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("eventhub.NamespacesClient", "CreateOrUpdateNetworkRuleSet", err.Error()) + } + + req, err := client.CreateOrUpdateNetworkRuleSetPreparer(ctx, resourceGroupName, namespaceName, parameters) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateNetworkRuleSet", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateNetworkRuleSetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateNetworkRuleSet", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateNetworkRuleSetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "CreateOrUpdateNetworkRuleSet", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdateNetworkRuleSetPreparer prepares the CreateOrUpdateNetworkRuleSet request. +func (client NamespacesClient) CreateOrUpdateNetworkRuleSetPreparer(ctx context.Context, resourceGroupName string, namespaceName string, parameters NetworkRuleSet) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01-preview" + 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.EventHub/namespaces/{namespaceName}/networkRuleSets/default", pathParameters), + autorest.WithJSON(parameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateNetworkRuleSetSender sends the CreateOrUpdateNetworkRuleSet request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) CreateOrUpdateNetworkRuleSetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateNetworkRuleSetResponder handles the response to the CreateOrUpdateNetworkRuleSet request. The method always +// closes the http.Response Body. +func (client NamespacesClient) CreateOrUpdateNetworkRuleSetResponder(resp *http.Response) (result NetworkRuleSet, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // CreateOrUpdateVirtualNetworkRule creates or updates an VirtualNetworkRule for a Namespace. // Parameters: // resourceGroupName - name of the resource group within the Azure subscription. @@ -778,6 +868,93 @@ func (client NamespacesClient) GetIPFilterRuleResponder(resp *http.Response) (re return } +// GetNetworkRuleSet gets NetworkRuleSet for a Namespace. +// Parameters: +// resourceGroupName - name of the resource group within the Azure subscription. +// namespaceName - the Namespace name +func (client NamespacesClient) GetNetworkRuleSet(ctx context.Context, resourceGroupName string, namespaceName string) (result NetworkRuleSet, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/NamespacesClient.GetNetworkRuleSet") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: resourceGroupName, + Constraints: []validation.Constraint{{Target: "resourceGroupName", Name: validation.MaxLength, Rule: 90, Chain: nil}, + {Target: "resourceGroupName", Name: validation.MinLength, Rule: 1, Chain: nil}}}, + {TargetValue: namespaceName, + Constraints: []validation.Constraint{{Target: "namespaceName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "namespaceName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("eventhub.NamespacesClient", "GetNetworkRuleSet", err.Error()) + } + + req, err := client.GetNetworkRuleSetPreparer(ctx, resourceGroupName, namespaceName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetNetworkRuleSet", nil, "Failure preparing request") + return + } + + resp, err := client.GetNetworkRuleSetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetNetworkRuleSet", resp, "Failure sending request") + return + } + + result, err = client.GetNetworkRuleSetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.NamespacesClient", "GetNetworkRuleSet", resp, "Failure responding to request") + } + + return +} + +// GetNetworkRuleSetPreparer prepares the GetNetworkRuleSet request. +func (client NamespacesClient) GetNetworkRuleSetPreparer(ctx context.Context, resourceGroupName string, namespaceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "namespaceName": autorest.Encode("path", namespaceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/namespaces/{namespaceName}/networkRuleSets/default", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetNetworkRuleSetSender sends the GetNetworkRuleSet request. The method will close the +// http.Response Body if it receives an error. +func (client NamespacesClient) GetNetworkRuleSetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetNetworkRuleSetResponder handles the response to the GetNetworkRuleSet request. The method always +// closes the http.Response Body. +func (client NamespacesClient) GetNetworkRuleSetResponder(resp *http.Response) (result NetworkRuleSet, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // GetVirtualNetworkRule gets an VirtualNetworkRule for a Namespace by rule name. // Parameters: // resourceGroupName - name of the resource group within the Azure subscription.