diff --git a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/hanaonazureapi/models.go b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/hanaonazureapi/models.go index 81bdb3436a03..3076387057d0 100644 --- a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/hanaonazureapi/models.go +++ b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/hanaonazureapi/models.go @@ -23,3 +23,4 @@ import original "github.com/Azure/azure-sdk-for-go/services/preview/hanaonazure/ type HanaInstancesClientAPI = original.HanaInstancesClientAPI type OperationsClientAPI = original.OperationsClientAPI +type SapMonitorsClientAPI = original.SapMonitorsClientAPI diff --git a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go index fc057ed57290..e32f4baf2adc 100644 --- a/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go +++ b/profiles/preview/preview/hanaonazure/mgmt/hanaonazure/models.go @@ -101,6 +101,8 @@ type HanaInstancesListResult = original.HanaInstancesListResult type HanaInstancesListResultIterator = original.HanaInstancesListResultIterator type HanaInstancesListResultPage = original.HanaInstancesListResultPage type HanaInstancesRestartFuture = original.HanaInstancesRestartFuture +type HanaInstancesShutdownFuture = original.HanaInstancesShutdownFuture +type HanaInstancesStartFuture = original.HanaInstancesStartFuture type HardwareProfile = original.HardwareProfile type IPAddress = original.IPAddress type MonitoringDetails = original.MonitoringDetails @@ -110,6 +112,14 @@ type Operation = original.Operation type OperationList = original.OperationList type OperationsClient = original.OperationsClient type Resource = original.Resource +type SapMonitor = original.SapMonitor +type SapMonitorListResult = original.SapMonitorListResult +type SapMonitorListResultIterator = original.SapMonitorListResultIterator +type SapMonitorListResultPage = original.SapMonitorListResultPage +type SapMonitorProperties = original.SapMonitorProperties +type SapMonitorsClient = original.SapMonitorsClient +type SapMonitorsCreateFuture = original.SapMonitorsCreateFuture +type SapMonitorsDeleteFuture = original.SapMonitorsDeleteFuture type StorageProfile = original.StorageProfile type Tags = original.Tags @@ -134,6 +144,18 @@ func NewOperationsClient(subscriptionID string) OperationsClient { func NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { return original.NewOperationsClientWithBaseURI(baseURI, subscriptionID) } +func NewSapMonitorListResultIterator(page SapMonitorListResultPage) SapMonitorListResultIterator { + return original.NewSapMonitorListResultIterator(page) +} +func NewSapMonitorListResultPage(getNextPage func(context.Context, SapMonitorListResult) (SapMonitorListResult, error)) SapMonitorListResultPage { + return original.NewSapMonitorListResultPage(getNextPage) +} +func NewSapMonitorsClient(subscriptionID string) SapMonitorsClient { + return original.NewSapMonitorsClient(subscriptionID) +} +func NewSapMonitorsClientWithBaseURI(baseURI string, subscriptionID string) SapMonitorsClient { + return original.NewSapMonitorsClientWithBaseURI(baseURI, subscriptionID) +} func NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { return original.NewWithBaseURI(baseURI, subscriptionID) } diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go index afbb6e81184c..b6ae72c9b6fb 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanainstances.go @@ -653,6 +653,158 @@ func (client HanaInstancesClient) RestartResponder(resp *http.Response) (result return } +// Shutdown the operation to shutdown a SAP HANA instance. +// Parameters: +// resourceGroupName - name of the resource group. +// hanaInstanceName - name of the SAP HANA on Azure instance. +func (client HanaInstancesClient) Shutdown(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result HanaInstancesShutdownFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HanaInstancesClient.Shutdown") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.ShutdownPreparer(ctx, resourceGroupName, hanaInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Shutdown", nil, "Failure preparing request") + return + } + + result, err = client.ShutdownSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Shutdown", result.Response(), "Failure sending request") + return + } + + return +} + +// ShutdownPreparer prepares the Shutdown request. +func (client HanaInstancesClient) ShutdownPreparer(ctx context.Context, resourceGroupName string, hanaInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hanaInstanceName": autorest.Encode("path", hanaInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/hanaInstances/{hanaInstanceName}/shutdown", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ShutdownSender sends the Shutdown request. The method will close the +// http.Response Body if it receives an error. +func (client HanaInstancesClient) ShutdownSender(req *http.Request) (future HanaInstancesShutdownFuture, 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 +} + +// ShutdownResponder handles the response to the Shutdown request. The method always +// closes the http.Response Body. +func (client HanaInstancesClient) ShutdownResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + +// Start the operation to start a SAP HANA instance. +// Parameters: +// resourceGroupName - name of the resource group. +// hanaInstanceName - name of the SAP HANA on Azure instance. +func (client HanaInstancesClient) Start(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result HanaInstancesStartFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HanaInstancesClient.Start") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.StartPreparer(ctx, resourceGroupName, hanaInstanceName) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Start", nil, "Failure preparing request") + return + } + + result, err = client.StartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesClient", "Start", result.Response(), "Failure sending request") + return + } + + return +} + +// StartPreparer prepares the Start request. +func (client HanaInstancesClient) StartPreparer(ctx context.Context, resourceGroupName string, hanaInstanceName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "hanaInstanceName": autorest.Encode("path", hanaInstanceName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/hanaInstances/{hanaInstanceName}/start", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StartSender sends the Start request. The method will close the +// http.Response Body if it receives an error. +func (client HanaInstancesClient) StartSender(req *http.Request) (future HanaInstancesStartFuture, 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 +} + +// StartResponder handles the response to the Start request. The method always +// closes the http.Response Body. +func (client HanaInstancesClient) StartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted), + autorest.ByClosing()) + result.Response = resp + return +} + // Update patches the Tags field of a SAP HANA instance for the specified subscription, resource group, and instance // name. // Parameters: diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go index 7458e1083b81..1a2908a67e53 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/hanaonazureapi/interfaces.go @@ -38,7 +38,20 @@ type HanaInstancesClientAPI interface { List(ctx context.Context) (result hanaonazure.HanaInstancesListResultPage, err error) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result hanaonazure.HanaInstancesListResultPage, err error) Restart(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result hanaonazure.HanaInstancesRestartFuture, err error) + Shutdown(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result hanaonazure.HanaInstancesShutdownFuture, err error) + Start(ctx context.Context, resourceGroupName string, hanaInstanceName string) (result hanaonazure.HanaInstancesStartFuture, err error) Update(ctx context.Context, resourceGroupName string, hanaInstanceName string, tagsParameter hanaonazure.Tags) (result hanaonazure.HanaInstance, err error) } var _ HanaInstancesClientAPI = (*hanaonazure.HanaInstancesClient)(nil) + +// SapMonitorsClientAPI contains the set of methods on the SapMonitorsClient type. +type SapMonitorsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, sapMonitorName string, sapMonitorParameter hanaonazure.SapMonitor) (result hanaonazure.SapMonitorsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, sapMonitorName string) (result hanaonazure.SapMonitorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, sapMonitorName string) (result hanaonazure.SapMonitor, err error) + List(ctx context.Context) (result hanaonazure.SapMonitorListResultPage, err error) + Update(ctx context.Context, resourceGroupName string, sapMonitorName string, tagsParameter hanaonazure.Tags) (result hanaonazure.SapMonitor, err error) +} + +var _ SapMonitorsClientAPI = (*hanaonazure.SapMonitorsClient)(nil) diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go index 3ba7cd7ec301..3cb1017481ed 100644 --- a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/models.go @@ -548,6 +548,52 @@ func (future *HanaInstancesRestartFuture) Result(client HanaInstancesClient) (ar return } +// HanaInstancesShutdownFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type HanaInstancesShutdownFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *HanaInstancesShutdownFuture) Result(client HanaInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesShutdownFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hanaonazure.HanaInstancesShutdownFuture") + return + } + ar.Response = future.Response() + return +} + +// HanaInstancesStartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type HanaInstancesStartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *HanaInstancesStartFuture) Result(client HanaInstancesClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.HanaInstancesStartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hanaonazure.HanaInstancesStartFuture") + return + } + ar.Response = future.Response() + return +} + // HardwareProfile specifies the hardware settings for the HANA instance. type HardwareProfile struct { // HardwareType - READ-ONLY; Name of the hardware type (vendor and/or their product name). Possible values include: 'CiscoUCS', 'HPE' @@ -636,6 +682,320 @@ func (r Resource) MarshalJSON() ([]byte, error) { return json.Marshal(objectMap) } +// SapMonitor SAP monitor info on Azure (ARM properties and SAP monitor properties) +type SapMonitor struct { + autorest.Response `json:"-"` + // SapMonitorProperties - SAP monitor properties + *SapMonitorProperties `json:"properties,omitempty"` + // ID - READ-ONLY; Resource ID + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Resource name + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; Resource type + Type *string `json:"type,omitempty"` + // Location - Resource location + Location *string `json:"location,omitempty"` + // Tags - READ-ONLY; Resource tags + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for SapMonitor. +func (sm SapMonitor) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if sm.SapMonitorProperties != nil { + objectMap["properties"] = sm.SapMonitorProperties + } + if sm.Location != nil { + objectMap["location"] = sm.Location + } + return json.Marshal(objectMap) +} + +// UnmarshalJSON is the custom unmarshaler for SapMonitor struct. +func (sm *SapMonitor) 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 sapMonitorProperties SapMonitorProperties + err = json.Unmarshal(*v, &sapMonitorProperties) + if err != nil { + return err + } + sm.SapMonitorProperties = &sapMonitorProperties + } + case "id": + if v != nil { + var ID string + err = json.Unmarshal(*v, &ID) + if err != nil { + return err + } + sm.ID = &ID + } + case "name": + if v != nil { + var name string + err = json.Unmarshal(*v, &name) + if err != nil { + return err + } + sm.Name = &name + } + case "type": + if v != nil { + var typeVar string + err = json.Unmarshal(*v, &typeVar) + if err != nil { + return err + } + sm.Type = &typeVar + } + case "location": + if v != nil { + var location string + err = json.Unmarshal(*v, &location) + if err != nil { + return err + } + sm.Location = &location + } + case "tags": + if v != nil { + var tags map[string]*string + err = json.Unmarshal(*v, &tags) + if err != nil { + return err + } + sm.Tags = tags + } + } + } + + return nil +} + +// SapMonitorListResult the response from the List SAP monitors operation. +type SapMonitorListResult struct { + autorest.Response `json:"-"` + // Value - The list of SAP monitors. + Value *[]SapMonitor `json:"value,omitempty"` + // NextLink - The URL to get the next set of SAP monitors. + NextLink *string `json:"nextLink,omitempty"` +} + +// SapMonitorListResultIterator provides access to a complete listing of SapMonitor values. +type SapMonitorListResultIterator struct { + i int + page SapMonitorListResultPage +} + +// 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 *SapMonitorListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorListResultIterator.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 *SapMonitorListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SapMonitorListResultIterator) 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 SapMonitorListResultIterator) Response() SapMonitorListResult { + 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 SapMonitorListResultIterator) Value() SapMonitor { + if !iter.page.NotDone() { + return SapMonitor{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SapMonitorListResultIterator type. +func NewSapMonitorListResultIterator(page SapMonitorListResultPage) SapMonitorListResultIterator { + return SapMonitorListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (smlr SapMonitorListResult) IsEmpty() bool { + return smlr.Value == nil || len(*smlr.Value) == 0 +} + +// sapMonitorListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (smlr SapMonitorListResult) sapMonitorListResultPreparer(ctx context.Context) (*http.Request, error) { + if smlr.NextLink == nil || len(to.String(smlr.NextLink)) < 1 { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(smlr.NextLink))) +} + +// SapMonitorListResultPage contains a page of SapMonitor values. +type SapMonitorListResultPage struct { + fn func(context.Context, SapMonitorListResult) (SapMonitorListResult, error) + smlr SapMonitorListResult +} + +// 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 *SapMonitorListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorListResultPage.NextWithContext") + defer func() { + sc := -1 + if page.Response().Response.Response != nil { + sc = page.Response().Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + next, err := page.fn(ctx, page.smlr) + if err != nil { + return err + } + page.smlr = next + 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 *SapMonitorListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SapMonitorListResultPage) NotDone() bool { + return !page.smlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SapMonitorListResultPage) Response() SapMonitorListResult { + return page.smlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SapMonitorListResultPage) Values() []SapMonitor { + if page.smlr.IsEmpty() { + return nil + } + return *page.smlr.Value +} + +// Creates a new instance of the SapMonitorListResultPage type. +func NewSapMonitorListResultPage(getNextPage func(context.Context, SapMonitorListResult) (SapMonitorListResult, error)) SapMonitorListResultPage { + return SapMonitorListResultPage{fn: getNextPage} +} + +// SapMonitorProperties describes the properties of a SAP monitor. +type SapMonitorProperties struct { + // HanaSubnet - Specifies the SAP monitor unique ID. + HanaSubnet *string `json:"hanaSubnet,omitempty"` + // HanaHostname - Hostname of the HANA instance. + HanaHostname *string `json:"hanaHostname,omitempty"` + // HanaDbName - Database name of the HANA instance. + HanaDbName *string `json:"hanaDbName,omitempty"` + // HanaDbSQLPort - Database port of the HANA instance. + HanaDbSQLPort *int32 `json:"hanaDbSqlPort,omitempty"` + // HanaDbUsername - Database username of the HANA instance. + HanaDbUsername *string `json:"hanaDbUsername,omitempty"` + // HanaDbPassword - Database password of the HANA instance. + HanaDbPassword *string `json:"hanaDbPassword,omitempty"` + // ProvisioningState - READ-ONLY; State of provisioning of the HanaInstance. Possible values include: 'Accepted', 'Creating', 'Updating', 'Failed', 'Succeeded', 'Deleting', 'Migrating' + ProvisioningState HanaProvisioningStatesEnum `json:"provisioningState,omitempty"` +} + +// SapMonitorsCreateFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SapMonitorsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SapMonitorsCreateFuture) Result(client SapMonitorsClient) (sm SapMonitor, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hanaonazure.SapMonitorsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if sm.Response.Response, err = future.GetResult(sender); err == nil && sm.Response.Response.StatusCode != http.StatusNoContent { + sm, err = client.CreateResponder(sm.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsCreateFuture", "Result", sm.Response.Response, "Failure responding to request") + } + } + return +} + +// SapMonitorsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type SapMonitorsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SapMonitorsDeleteFuture) Result(client SapMonitorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("hanaonazure.SapMonitorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + // StorageProfile specifies the storage settings for the HANA instance disks. type StorageProfile struct { // NfsIPAddress - READ-ONLY; IP Address to connect to storage. diff --git a/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/sapmonitors.go b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/sapmonitors.go new file mode 100644 index 000000000000..38fb2ca5a57b --- /dev/null +++ b/services/preview/hanaonazure/mgmt/2017-11-03-preview/hanaonazure/sapmonitors.go @@ -0,0 +1,465 @@ +package hanaonazure + +// 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" +) + +// SapMonitorsClient is the HANA on Azure Client +type SapMonitorsClient struct { + BaseClient +} + +// NewSapMonitorsClient creates an instance of the SapMonitorsClient client. +func NewSapMonitorsClient(subscriptionID string) SapMonitorsClient { + return NewSapMonitorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSapMonitorsClientWithBaseURI creates an instance of the SapMonitorsClient client. +func NewSapMonitorsClientWithBaseURI(baseURI string, subscriptionID string) SapMonitorsClient { + return SapMonitorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create creates a SAP monitor for the specified subscription, resource group, and resource name. +// Parameters: +// resourceGroupName - name of the resource group. +// sapMonitorName - name of the SAP monitor resource. +// sapMonitorParameter - request body representing a SAP Monitor +func (client SapMonitorsClient) Create(ctx context.Context, resourceGroupName string, sapMonitorName string, sapMonitorParameter SapMonitor) (result SapMonitorsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreatePreparer(ctx, resourceGroupName, sapMonitorName, sapMonitorParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client SapMonitorsClient) CreatePreparer(ctx context.Context, resourceGroupName string, sapMonitorName string, sapMonitorParameter SapMonitor) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sapMonitorName": autorest.Encode("path", sapMonitorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-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.HanaOnAzure/sapMonitors/{sapMonitorName}", pathParameters), + autorest.WithJSON(sapMonitorParameter), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateSender sends the Create request. The method will close the +// http.Response Body if it receives an error. +func (client SapMonitorsClient) CreateSender(req *http.Request) (future SapMonitorsCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client SapMonitorsClient) CreateResponder(resp *http.Response) (result SapMonitor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete deletes a SAP monitor with the specified subscription, resource group, and monitor name. +// Parameters: +// resourceGroupName - name of the resource group. +// sapMonitorName - name of the SAP monitor resource. +func (client SapMonitorsClient) Delete(ctx context.Context, resourceGroupName string, sapMonitorName string) (result SapMonitorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, sapMonitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client SapMonitorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, sapMonitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sapMonitorName": autorest.Encode("path", sapMonitorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-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.HanaOnAzure/sapMonitors/{sapMonitorName}", 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 SapMonitorsClient) DeleteSender(req *http.Request) (future SapMonitorsDeleteFuture, 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 SapMonitorsClient) 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 properties of a SAP monitor for the specified subscription, resource group, and resource name. +// Parameters: +// resourceGroupName - name of the resource group. +// sapMonitorName - name of the SAP monitor resource. +func (client SapMonitorsClient) Get(ctx context.Context, resourceGroupName string, sapMonitorName string) (result SapMonitor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.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, resourceGroupName, sapMonitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SapMonitorsClient) GetPreparer(ctx context.Context, resourceGroupName string, sapMonitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sapMonitorName": autorest.Encode("path", sapMonitorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-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.HanaOnAzure/sapMonitors/{sapMonitorName}", 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 SapMonitorsClient) GetSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// GetResponder handles the response to the Get request. The method always +// closes the http.Response Body. +func (client SapMonitorsClient) GetResponder(resp *http.Response) (result SapMonitor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List gets a list of SAP monitors in the specified subscription. The operations returns various properties of each +// SAP monitor. +func (client SapMonitorsClient) List(ctx context.Context) (result SapMonitorListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.List") + defer func() { + sc := -1 + if result.smlr.Response.Response != nil { + sc = result.smlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.smlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "List", resp, "Failure sending request") + return + } + + result.smlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "List", resp, "Failure responding to request") + } + + return +} + +// ListPreparer prepares the List request. +func (client SapMonitorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.HanaOnAzure/sapMonitors", 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 SapMonitorsClient) ListSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client SapMonitorsClient) ListResponder(resp *http.Response) (result SapMonitorListResult, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listNextResults retrieves the next set of results, if any. +func (client SapMonitorsClient) listNextResults(ctx context.Context, lastResults SapMonitorListResult) (result SapMonitorListResult, err error) { + req, err := lastResults.sapMonitorListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "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, "hanaonazure.SapMonitorsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SapMonitorsClient) ListComplete(ctx context.Context) (result SapMonitorListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.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) + return +} + +// Update patches the Tags field of a SAP monitor for the specified subscription, resource group, and monitor name. +// Parameters: +// resourceGroupName - name of the resource group. +// sapMonitorName - name of the SAP monitor resource. +// tagsParameter - request body that only contains the new Tags field +func (client SapMonitorsClient) Update(ctx context.Context, resourceGroupName string, sapMonitorName string, tagsParameter Tags) (result SapMonitor, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SapMonitorsClient.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, resourceGroupName, sapMonitorName, tagsParameter) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "hanaonazure.SapMonitorsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client SapMonitorsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, sapMonitorName string, tagsParameter Tags) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "sapMonitorName": autorest.Encode("path", sapMonitorName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2017-11-03-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPatch(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.HanaOnAzure/sapMonitors/{sapMonitorName}", pathParameters), + autorest.WithJSON(tagsParameter), + autorest.WithQueryParameters(queryParameters)) + 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 SapMonitorsClient) UpdateSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// UpdateResponder handles the response to the Update request. The method always +// closes the http.Response Body. +func (client SapMonitorsClient) UpdateResponder(resp *http.Response) (result SapMonitor, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +}