diff --git a/profiles/preview/preview/eventhub/mgmt/eventhub/models.go b/profiles/preview/preview/eventhub/mgmt/eventhub/models.go index 3bc3ebaa5fcd..f9709366acc5 100644 --- a/profiles/preview/preview/eventhub/mgmt/eventhub/models.go +++ b/profiles/preview/preview/eventhub/mgmt/eventhub/models.go @@ -63,6 +63,7 @@ const ( SkuTierStandard SkuTier = original.SkuTierStandard ) +type AvailableClustersList = original.AvailableClustersList type BaseClient = original.BaseClient type Cluster = original.Cluster type ClusterListResult = original.ClusterListResult @@ -72,9 +73,12 @@ type ClusterProperties = original.ClusterProperties type ClusterQuotaConfigurationProperties = original.ClusterQuotaConfigurationProperties type ClusterSku = original.ClusterSku type ClustersClient = original.ClustersClient +type ClustersDeleteFuture = original.ClustersDeleteFuture type ClustersPatchFuture = original.ClustersPatchFuture +type ClustersPutFuture = original.ClustersPutFuture type ConfigurationClient = original.ConfigurationClient type EHNamespace = original.EHNamespace +type EHNamespaceIDListResult = original.EHNamespaceIDListResult type EHNamespaceListResult = original.EHNamespaceListResult type EHNamespaceListResultIterator = original.EHNamespaceListResultIterator type EHNamespaceListResultPage = original.EHNamespaceListResultPage diff --git a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/clusters.go b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/clusters.go index 091df7d6c3c6..d6cf3dbde990 100644 --- a/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/clusters.go +++ b/services/preview/eventhub/mgmt/2018-01-01-preview/eventhub/clusters.go @@ -42,6 +42,92 @@ func NewClustersClientWithBaseURI(baseURI string, subscriptionID string) Cluster return ClustersClient{NewWithBaseURI(baseURI, subscriptionID)} } +// Delete deletes an existing Event Hubs Cluster. This operation is idempotent. +// Parameters: +// resourceGroupName - name of the resource group within the Azure subscription. +// clusterName - the name of the Event Hubs Cluster. +func (client ClustersClient) Delete(ctx context.Context, resourceGroupName string, clusterName string) (result ClustersDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.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: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("eventhub.ClustersClient", "Delete", err.Error()) + } + + req, err := client.DeletePreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client ClustersClient) DeletePreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "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.AsDelete(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/clusters/{clusterName}", 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 ClustersClient) DeleteSender(req *http.Request) (future ClustersDeleteFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, 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 ClustersClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // Get gets the resource description of the specified Event Hubs Cluster. // Parameters: // resourceGroupName - name of the resource group within the Azure subscription. @@ -129,6 +215,74 @@ func (client ClustersClient) GetResponder(resp *http.Response) (result Cluster, return } +// ListAvailableClusters list the quantity of available pre-provisioned Event Hubs Clusters, indexed by Azure region. +func (client ClustersClient) ListAvailableClusters(ctx context.Context) (result AvailableClustersList, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListAvailableClusters") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ListAvailableClustersPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListAvailableClusters", nil, "Failure preparing request") + return + } + + resp, err := client.ListAvailableClustersSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListAvailableClusters", resp, "Failure sending request") + return + } + + result, err = client.ListAvailableClustersResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListAvailableClusters", resp, "Failure responding to request") + } + + return +} + +// ListAvailableClustersPreparer prepares the ListAvailableClusters request. +func (client ClustersClient) ListAvailableClustersPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2018-01-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.EventHub/availableClusters"), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListAvailableClustersSender sends the ListAvailableClusters request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ListAvailableClustersSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListAvailableClustersResponder handles the response to the ListAvailableClusters request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListAvailableClustersResponder(resp *http.Response) (result AvailableClustersList, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // ListByResourceGroup lists the available Event Hubs Clusters within an ARM resource group. // Parameters: // resourceGroupName - name of the resource group within the Azure subscription. @@ -249,6 +403,93 @@ func (client ClustersClient) ListByResourceGroupComplete(ctx context.Context, re return } +// ListNamespaces list all Event Hubs Namespace IDs in an Event Hubs Dedicated Cluster. +// Parameters: +// resourceGroupName - name of the resource group within the Azure subscription. +// clusterName - the name of the Event Hubs Cluster. +func (client ClustersClient) ListNamespaces(ctx context.Context, resourceGroupName string, clusterName string) (result EHNamespaceIDListResult, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.ListNamespaces") + 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: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("eventhub.ClustersClient", "ListNamespaces", err.Error()) + } + + req, err := client.ListNamespacesPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListNamespaces", nil, "Failure preparing request") + return + } + + resp, err := client.ListNamespacesSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListNamespaces", resp, "Failure sending request") + return + } + + result, err = client.ListNamespacesResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "ListNamespaces", resp, "Failure responding to request") + } + + return +} + +// ListNamespacesPreparer prepares the ListNamespaces request. +func (client ClustersClient) ListNamespacesPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "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/clusters/{clusterName}/namespaces", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListNamespacesSender sends the ListNamespaces request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) ListNamespacesSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListNamespacesResponder handles the response to the ListNamespaces request. The method always +// closes the http.Response Body. +func (client ClustersClient) ListNamespacesResponder(resp *http.Response) (result EHNamespaceIDListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + // Patch modifies mutable properties on the Event Hubs Cluster. This operation is idempotent. // Parameters: // resourceGroupName - name of the resource group within the Azure subscription. @@ -338,3 +579,90 @@ func (client ClustersClient) PatchResponder(resp *http.Response) (result Cluster result.Response = autorest.Response{Response: resp} return } + +// Put creates or updates an instance of an Event Hubs Cluster. +// Parameters: +// resourceGroupName - name of the resource group within the Azure subscription. +// clusterName - the name of the Event Hubs Cluster. +func (client ClustersClient) Put(ctx context.Context, resourceGroupName string, clusterName string) (result ClustersPutFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/ClustersClient.Put") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.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: clusterName, + Constraints: []validation.Constraint{{Target: "clusterName", Name: validation.MaxLength, Rule: 50, Chain: nil}, + {Target: "clusterName", Name: validation.MinLength, Rule: 6, Chain: nil}}}}); err != nil { + return result, validation.NewError("eventhub.ClustersClient", "Put", err.Error()) + } + + req, err := client.PutPreparer(ctx, resourceGroupName, clusterName) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "Put", nil, "Failure preparing request") + return + } + + result, err = client.PutSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersClient", "Put", result.Response(), "Failure sending request") + return + } + + return +} + +// PutPreparer prepares the Put request. +func (client ClustersClient) PutPreparer(ctx context.Context, resourceGroupName string, clusterName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "clusterName": autorest.Encode("path", clusterName), + "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.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.EventHub/clusters/{clusterName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// PutSender sends the Put request. The method will close the +// http.Response Body if it receives an error. +func (client ClustersClient) PutSender(req *http.Request) (future ClustersPutFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// PutResponder handles the response to the Put request. The method always +// closes the http.Response Body. +func (client ClustersClient) PutResponder(resp *http.Response) (result Cluster, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} 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 213fca1621f7..ed7dcfff11cf 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 @@ -32,9 +32,13 @@ var _ OperationsClientAPI = (*eventhub.OperationsClient)(nil) // ClustersClientAPI contains the set of methods on the ClustersClient type. type ClustersClientAPI interface { + Delete(ctx context.Context, resourceGroupName string, clusterName string) (result eventhub.ClustersDeleteFuture, err error) Get(ctx context.Context, resourceGroupName string, clusterName string) (result eventhub.Cluster, err error) + ListAvailableClusters(ctx context.Context) (result eventhub.AvailableClustersList, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result eventhub.ClusterListResultPage, err error) + ListNamespaces(ctx context.Context, resourceGroupName string, clusterName string) (result eventhub.EHNamespaceIDListResult, err error) Patch(ctx context.Context, resourceGroupName string, clusterName string, parameters eventhub.Cluster) (result eventhub.ClustersPatchFuture, err error) + Put(ctx context.Context, resourceGroupName string, clusterName string) (result eventhub.ClustersPutFuture, err error) } var _ ClustersClientAPI = (*eventhub.ClustersClient)(nil) 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 0581a5091e84..8cf6f4a03fa9 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 @@ -104,6 +104,13 @@ func PossibleSkuTierValues() []SkuTier { return []SkuTier{SkuTierBasic, SkuTierStandard} } +// AvailableClustersList the response of the List Available Clusters operation. +type AvailableClustersList struct { + autorest.Response `json:"-"` + // Value - The count of readily available and pre-provisioned Event Hubs Clusters per region. + Value *[]map[string]*int32 `json:"value,omitempty"` +} + // Cluster single Event Hubs Cluster resource in List or Get operations. type Cluster struct { autorest.Response `json:"-"` @@ -400,6 +407,29 @@ func (cqcp ClusterQuotaConfigurationProperties) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// ClustersDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ClustersDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersDeleteFuture) Result(client ClustersClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("eventhub.ClustersDeleteFuture") + return + } + ar.Response = future.Response() + return +} + // ClusterSku SKU parameters particular to a cluster instance. type ClusterSku struct { // Name - Name of this SKU. @@ -437,6 +467,34 @@ func (future *ClustersPatchFuture) Result(client ClustersClient) (c Cluster, err return } +// ClustersPutFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type ClustersPutFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ClustersPutFuture) Result(client ClustersClient) (c Cluster, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersPutFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("eventhub.ClustersPutFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if c.Response.Response, err = future.GetResult(sender); err == nil && c.Response.Response.StatusCode != http.StatusNoContent { + c, err = client.PutResponder(c.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "eventhub.ClustersPutFuture", "Result", c.Response.Response, "Failure responding to request") + } + } + return +} + // EHNamespace single Namespace item in List or Get Operation type EHNamespace struct { autorest.Response `json:"-"` @@ -561,6 +619,13 @@ func (en *EHNamespace) UnmarshalJSON(body []byte) error { return nil } +// EHNamespaceIDListResult the response of the List Namespace IDs operation +type EHNamespaceIDListResult struct { + autorest.Response `json:"-"` + // Value - Result of the List Namespace IDs operation + Value *[]string `json:"value,omitempty"` +} + // EHNamespaceListResult the response of the List Namespace operation type EHNamespaceListResult struct { autorest.Response `json:"-"`