diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/apikeys.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/apikeys.go new file mode 100644 index 000000000000..3a2ce324247d --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/apikeys.go @@ -0,0 +1,320 @@ +package datadog + +// 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/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// APIKeysClient is the client for the APIKeys methods of the Datadog service. +type APIKeysClient struct { + BaseClient +} + +// NewAPIKeysClient creates an instance of the APIKeysClient client. +func NewAPIKeysClient(subscriptionID string) APIKeysClient { + return NewAPIKeysClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewAPIKeysClientWithBaseURI creates an instance of the APIKeysClient 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 NewAPIKeysClientWithBaseURI(baseURI string, subscriptionID string) APIKeysClient { + return APIKeysClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// GetDefaultKey sends the get default key request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client APIKeysClient) GetDefaultKey(ctx context.Context, resourceGroupName string, monitorName string) (result APIKey, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.GetDefaultKey") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.GetDefaultKeyPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "GetDefaultKey", nil, "Failure preparing request") + return + } + + resp, err := client.GetDefaultKeySender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "GetDefaultKey", resp, "Failure sending request") + return + } + + result, err = client.GetDefaultKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "GetDefaultKey", resp, "Failure responding to request") + } + + return +} + +// GetDefaultKeyPreparer prepares the GetDefaultKey request. +func (client APIKeysClient) GetDefaultKeyPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/getDefaultKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// GetDefaultKeySender sends the GetDefaultKey request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) GetDefaultKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// GetDefaultKeyResponder handles the response to the GetDefaultKey request. The method always +// closes the http.Response Body. +func (client APIKeysClient) GetDefaultKeyResponder(resp *http.Response) (result APIKey, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client APIKeysClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result APIKeyListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.List") + defer func() { + sc := -1 + if result.aklr.Response.Response != nil { + sc = result.aklr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.aklr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "List", resp, "Failure sending request") + return + } + + result.aklr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "List", resp, "Failure responding to request") + } + if result.aklr.hasNextLink() && result.aklr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client APIKeysClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/listApiKeys", 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 APIKeysClient) 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 APIKeysClient) ListResponder(resp *http.Response) (result APIKeyListResponse, 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 APIKeysClient) listNextResults(ctx context.Context, lastResults APIKeyListResponse) (result APIKeyListResponse, err error) { + req, err := lastResults.aPIKeyListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.APIKeysClient", "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, "datadog.APIKeysClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client APIKeysClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result APIKeyListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.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, monitorName) + return +} + +// SetDefaultKey sends the set default key request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client APIKeysClient) SetDefaultKey(ctx context.Context, resourceGroupName string, monitorName string, body *APIKey) (result autorest.Response, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeysClient.SetDefaultKey") + defer func() { + sc := -1 + if result.Response != nil { + sc = result.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Key", Name: validation.Null, Rule: true, Chain: nil}}}}}}); err != nil { + return result, validation.NewError("datadog.APIKeysClient", "SetDefaultKey", err.Error()) + } + + req, err := client.SetDefaultKeyPreparer(ctx, resourceGroupName, monitorName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "SetDefaultKey", nil, "Failure preparing request") + return + } + + resp, err := client.SetDefaultKeySender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "SetDefaultKey", resp, "Failure sending request") + return + } + + result, err = client.SetDefaultKeyResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.APIKeysClient", "SetDefaultKey", resp, "Failure responding to request") + } + + return +} + +// SetDefaultKeyPreparer prepares the SetDefaultKey request. +func (client APIKeysClient) SetDefaultKeyPreparer(ctx context.Context, resourceGroupName string, monitorName string, body *APIKey) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/setDefaultKey", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// SetDefaultKeySender sends the SetDefaultKey request. The method will close the +// http.Response Body if it receives an error. +func (client APIKeysClient) SetDefaultKeySender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// SetDefaultKeyResponder handles the response to the SetDefaultKey request. The method always +// closes the http.Response Body. +func (client APIKeysClient) SetDefaultKeyResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByClosing()) + result.Response = resp + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/client.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/client.go new file mode 100644 index 000000000000..f2bfcb35d8ca --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/client.go @@ -0,0 +1,52 @@ +// Package datadog implements the Azure ARM Datadog service API version 2020-02-01-preview. +// +// +package datadog + +// 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 ( + "github.com/Azure/go-autorest/autorest" +) + +const ( + // DefaultBaseURI is the default URI used for the service Datadog + DefaultBaseURI = "https://management.azure.com" +) + +// BaseClient is the base client for Datadog. +type BaseClient struct { + autorest.Client + BaseURI string + SubscriptionID string +} + +// New creates an instance of the BaseClient client. +func New(subscriptionID string) BaseClient { + return NewWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewWithBaseURI creates an instance of the BaseClient 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 NewWithBaseURI(baseURI string, subscriptionID string) BaseClient { + return BaseClient{ + Client: autorest.NewClientWithUserAgent(UserAgent()), + BaseURI: baseURI, + SubscriptionID: subscriptionID, + } +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/datadogapi/interfaces.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/datadogapi/interfaces.go new file mode 100644 index 000000000000..b7af6cbec226 --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/datadogapi/interfaces.go @@ -0,0 +1,107 @@ +package datadogapi + +// 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/azure-sdk-for-go/services/preview/datadog/mgmt/2020-02-01-preview/datadog" + "github.com/Azure/go-autorest/autorest" +) + +// APIKeysClientAPI contains the set of methods on the APIKeysClient type. +type APIKeysClientAPI interface { + GetDefaultKey(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.APIKey, err error) + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.APIKeyListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.APIKeyListResponseIterator, err error) + SetDefaultKey(ctx context.Context, resourceGroupName string, monitorName string, body *datadog.APIKey) (result autorest.Response, err error) +} + +var _ APIKeysClientAPI = (*datadog.APIKeysClient)(nil) + +// HostsClientAPI contains the set of methods on the HostsClient type. +type HostsClientAPI interface { + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.HostListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.HostListResponseIterator, err error) +} + +var _ HostsClientAPI = (*datadog.HostsClient)(nil) + +// LinkedResourcesClientAPI contains the set of methods on the LinkedResourcesClient type. +type LinkedResourcesClientAPI interface { + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.LinkedResourceListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.LinkedResourceListResponseIterator, err error) +} + +var _ LinkedResourcesClientAPI = (*datadog.LinkedResourcesClient)(nil) + +// MonitoredResourcesClientAPI contains the set of methods on the MonitoredResourcesClient type. +type MonitoredResourcesClientAPI interface { + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitoredResourceListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitoredResourceListResponseIterator, err error) +} + +var _ MonitoredResourcesClientAPI = (*datadog.MonitoredResourcesClient)(nil) + +// OperationsClientAPI contains the set of methods on the OperationsClient type. +type OperationsClientAPI interface { + List(ctx context.Context) (result datadog.OperationListResultPage, err error) + ListComplete(ctx context.Context) (result datadog.OperationListResultIterator, err error) +} + +var _ OperationsClientAPI = (*datadog.OperationsClient)(nil) + +// MonitorsClientAPI contains the set of methods on the MonitorsClient type. +type MonitorsClientAPI interface { + Create(ctx context.Context, resourceGroupName string, monitorName string, body *datadog.MonitorResource) (result datadog.MonitorsCreateFuture, err error) + Delete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitorsDeleteFuture, err error) + Get(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitorResource, err error) + List(ctx context.Context) (result datadog.MonitorResourceListResponsePage, err error) + ListComplete(ctx context.Context) (result datadog.MonitorResourceListResponseIterator, err error) + ListByResourceGroup(ctx context.Context, resourceGroupName string) (result datadog.MonitorResourceListResponsePage, err error) + ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result datadog.MonitorResourceListResponseIterator, err error) + Update(ctx context.Context, resourceGroupName string, monitorName string, body *datadog.MonitorResourceUpdateParameters) (result datadog.MonitorResource, err error) +} + +var _ MonitorsClientAPI = (*datadog.MonitorsClient)(nil) + +// RefreshSetPasswordClientAPI contains the set of methods on the RefreshSetPasswordClient type. +type RefreshSetPasswordClientAPI interface { + Get(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.SetPasswordLink, err error) +} + +var _ RefreshSetPasswordClientAPI = (*datadog.RefreshSetPasswordClient)(nil) + +// TagRulesClientAPI contains the set of methods on the TagRulesClient type. +type TagRulesClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, body *datadog.MonitoringTagRules) (result datadog.MonitoringTagRules, err error) + Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string) (result datadog.MonitoringTagRules, err error) + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitoringTagRulesListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.MonitoringTagRulesListResponseIterator, err error) +} + +var _ TagRulesClientAPI = (*datadog.TagRulesClient)(nil) + +// SingleSignOnConfigurationsClientAPI contains the set of methods on the SingleSignOnConfigurationsClient type. +type SingleSignOnConfigurationsClientAPI interface { + CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, body *datadog.SingleSignOnResource) (result datadog.SingleSignOnConfigurationsCreateOrUpdateFuture, err error) + Get(ctx context.Context, resourceGroupName string, monitorName string, configurationName string) (result datadog.SingleSignOnResource, err error) + List(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.SingleSignOnResourceListResponsePage, err error) + ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result datadog.SingleSignOnResourceListResponseIterator, err error) +} + +var _ SingleSignOnConfigurationsClientAPI = (*datadog.SingleSignOnConfigurationsClient)(nil) diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/enums.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/enums.go new file mode 100644 index 000000000000..a1824a74bd22 --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/enums.go @@ -0,0 +1,141 @@ +package datadog + +// 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. + +// LiftrResourceCategories enumerates the values for liftr resource categories. +type LiftrResourceCategories string + +const ( + // MonitorLogs ... + MonitorLogs LiftrResourceCategories = "MonitorLogs" + // Unknown ... + Unknown LiftrResourceCategories = "Unknown" +) + +// PossibleLiftrResourceCategoriesValues returns an array of possible values for the LiftrResourceCategories const type. +func PossibleLiftrResourceCategoriesValues() []LiftrResourceCategories { + return []LiftrResourceCategories{MonitorLogs, Unknown} +} + +// ManagedIdentityTypes enumerates the values for managed identity types. +type ManagedIdentityTypes string + +const ( + // SystemAssigned ... + SystemAssigned ManagedIdentityTypes = "SystemAssigned" + // UserAssigned ... + UserAssigned ManagedIdentityTypes = "UserAssigned" +) + +// PossibleManagedIdentityTypesValues returns an array of possible values for the ManagedIdentityTypes const type. +func PossibleManagedIdentityTypesValues() []ManagedIdentityTypes { + return []ManagedIdentityTypes{SystemAssigned, UserAssigned} +} + +// MarketplaceSubscriptionStatus enumerates the values for marketplace subscription status. +type MarketplaceSubscriptionStatus string + +const ( + // Active ... + Active MarketplaceSubscriptionStatus = "Active" + // Suspended ... + Suspended MarketplaceSubscriptionStatus = "Suspended" +) + +// PossibleMarketplaceSubscriptionStatusValues returns an array of possible values for the MarketplaceSubscriptionStatus const type. +func PossibleMarketplaceSubscriptionStatusValues() []MarketplaceSubscriptionStatus { + return []MarketplaceSubscriptionStatus{Active, Suspended} +} + +// MonitoringStatus enumerates the values for monitoring status. +type MonitoringStatus string + +const ( + // Disabled ... + Disabled MonitoringStatus = "Disabled" + // Enabled ... + Enabled MonitoringStatus = "Enabled" +) + +// PossibleMonitoringStatusValues returns an array of possible values for the MonitoringStatus const type. +func PossibleMonitoringStatusValues() []MonitoringStatus { + return []MonitoringStatus{Disabled, Enabled} +} + +// ProvisioningState enumerates the values for provisioning state. +type ProvisioningState string + +const ( + // Accepted ... + Accepted ProvisioningState = "Accepted" + // Canceled ... + Canceled ProvisioningState = "Canceled" + // Creating ... + Creating ProvisioningState = "Creating" + // Deleted ... + Deleted ProvisioningState = "Deleted" + // Deleting ... + Deleting ProvisioningState = "Deleting" + // Failed ... + Failed ProvisioningState = "Failed" + // NotSpecified ... + NotSpecified ProvisioningState = "NotSpecified" + // Succeeded ... + Succeeded ProvisioningState = "Succeeded" + // Updating ... + Updating ProvisioningState = "Updating" +) + +// PossibleProvisioningStateValues returns an array of possible values for the ProvisioningState const type. +func PossibleProvisioningStateValues() []ProvisioningState { + return []ProvisioningState{Accepted, Canceled, Creating, Deleted, Deleting, Failed, NotSpecified, Succeeded, Updating} +} + +// SingleSignOnStates enumerates the values for single sign on states. +type SingleSignOnStates string + +const ( + // Disable ... + Disable SingleSignOnStates = "Disable" + // Enable ... + Enable SingleSignOnStates = "Enable" + // Existing ... + Existing SingleSignOnStates = "Existing" + // Initial ... + Initial SingleSignOnStates = "Initial" +) + +// PossibleSingleSignOnStatesValues returns an array of possible values for the SingleSignOnStates const type. +func PossibleSingleSignOnStatesValues() []SingleSignOnStates { + return []SingleSignOnStates{Disable, Enable, Existing, Initial} +} + +// TagAction enumerates the values for tag action. +type TagAction string + +const ( + // Exclude ... + Exclude TagAction = "Exclude" + // Include ... + Include TagAction = "Include" +) + +// PossibleTagActionValues returns an array of possible values for the TagAction const type. +func PossibleTagActionValues() []TagAction { + return []TagAction{Exclude, Include} +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/hosts.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/hosts.go new file mode 100644 index 000000000000..389c29532e5a --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/hosts.go @@ -0,0 +1,158 @@ +package datadog + +// 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" +) + +// HostsClient is the client for the Hosts methods of the Datadog service. +type HostsClient struct { + BaseClient +} + +// NewHostsClient creates an instance of the HostsClient client. +func NewHostsClient(subscriptionID string) HostsClient { + return NewHostsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewHostsClientWithBaseURI creates an instance of the HostsClient 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 NewHostsClientWithBaseURI(baseURI string, subscriptionID string) HostsClient { + return HostsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client HostsClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result HostListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostsClient.List") + defer func() { + sc := -1 + if result.hlr.Response.Response != nil { + sc = result.hlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.HostsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.hlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.HostsClient", "List", resp, "Failure sending request") + return + } + + result.hlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.HostsClient", "List", resp, "Failure responding to request") + } + if result.hlr.hasNextLink() && result.hlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client HostsClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/listHosts", 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 HostsClient) 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 HostsClient) ListResponder(resp *http.Response) (result HostListResponse, 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 HostsClient) listNextResults(ctx context.Context, lastResults HostListResponse) (result HostListResponse, err error) { + req, err := lastResults.hostListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.HostsClient", "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, "datadog.HostsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.HostsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client HostsClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result HostListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostsClient.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, monitorName) + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/linkedresources.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/linkedresources.go new file mode 100644 index 000000000000..0f6ddffcd76e --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/linkedresources.go @@ -0,0 +1,158 @@ +package datadog + +// 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" +) + +// LinkedResourcesClient is the client for the LinkedResources methods of the Datadog service. +type LinkedResourcesClient struct { + BaseClient +} + +// NewLinkedResourcesClient creates an instance of the LinkedResourcesClient client. +func NewLinkedResourcesClient(subscriptionID string) LinkedResourcesClient { + return NewLinkedResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewLinkedResourcesClientWithBaseURI creates an instance of the LinkedResourcesClient 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 NewLinkedResourcesClientWithBaseURI(baseURI string, subscriptionID string) LinkedResourcesClient { + return LinkedResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client LinkedResourcesClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result LinkedResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LinkedResourcesClient.List") + defer func() { + sc := -1 + if result.lrlr.Response.Response != nil { + sc = result.lrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.LinkedResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.lrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.LinkedResourcesClient", "List", resp, "Failure sending request") + return + } + + result.lrlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.LinkedResourcesClient", "List", resp, "Failure responding to request") + } + if result.lrlr.hasNextLink() && result.lrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client LinkedResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/listLinkedResources", 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 LinkedResourcesClient) 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 LinkedResourcesClient) ListResponder(resp *http.Response) (result LinkedResourceListResponse, 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 LinkedResourcesClient) listNextResults(ctx context.Context, lastResults LinkedResourceListResponse) (result LinkedResourceListResponse, err error) { + req, err := lastResults.linkedResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.LinkedResourcesClient", "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, "datadog.LinkedResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.LinkedResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client LinkedResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result LinkedResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LinkedResourcesClient.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, monitorName) + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/models.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/models.go new file mode 100644 index 000000000000..f7b8a71a9bc3 --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/models.go @@ -0,0 +1,1720 @@ +package datadog + +// 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" + "encoding/json" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "github.com/Azure/go-autorest/autorest/to" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// The package's fully qualified name. +const fqdn = "github.com/Azure/azure-sdk-for-go/services/preview/datadog/mgmt/2020-02-01-preview/datadog" + +// APIKey ... +type APIKey struct { + autorest.Response `json:"-"` + // CreatedBy - The user that created the API key. + CreatedBy *string `json:"createdBy,omitempty"` + // Name - The name of the API key. + Name *string `json:"name,omitempty"` + // Key - The value of the API key. + Key *string `json:"key,omitempty"` + // Created - The time of creation of the API key. + Created *string `json:"created,omitempty"` +} + +// APIKeyListResponse response of a list operation. +type APIKeyListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]APIKey `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// APIKeyListResponseIterator provides access to a complete listing of APIKey values. +type APIKeyListResponseIterator struct { + i int + page APIKeyListResponsePage +} + +// 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 *APIKeyListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeyListResponseIterator.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 *APIKeyListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter APIKeyListResponseIterator) 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 APIKeyListResponseIterator) Response() APIKeyListResponse { + 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 APIKeyListResponseIterator) Value() APIKey { + if !iter.page.NotDone() { + return APIKey{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the APIKeyListResponseIterator type. +func NewAPIKeyListResponseIterator(page APIKeyListResponsePage) APIKeyListResponseIterator { + return APIKeyListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (aklr APIKeyListResponse) IsEmpty() bool { + return aklr.Value == nil || len(*aklr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (aklr APIKeyListResponse) hasNextLink() bool { + return aklr.NextLink != nil && len(*aklr.NextLink) != 0 +} + +// aPIKeyListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (aklr APIKeyListResponse) aPIKeyListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !aklr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(aklr.NextLink))) +} + +// APIKeyListResponsePage contains a page of APIKey values. +type APIKeyListResponsePage struct { + fn func(context.Context, APIKeyListResponse) (APIKeyListResponse, error) + aklr APIKeyListResponse +} + +// 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 *APIKeyListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/APIKeyListResponsePage.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.aklr) + if err != nil { + return err + } + page.aklr = 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 *APIKeyListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page APIKeyListResponsePage) NotDone() bool { + return !page.aklr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page APIKeyListResponsePage) Response() APIKeyListResponse { + return page.aklr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page APIKeyListResponsePage) Values() []APIKey { + if page.aklr.IsEmpty() { + return nil + } + return *page.aklr.Value +} + +// Creates a new instance of the APIKeyListResponsePage type. +func NewAPIKeyListResponsePage(getNextPage func(context.Context, APIKeyListResponse) (APIKeyListResponse, error)) APIKeyListResponsePage { + return APIKeyListResponsePage{fn: getNextPage} +} + +// ErrorResponseBody ... +type ErrorResponseBody struct { + Code *string `json:"code,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` + Details *[]ErrorResponseBody `json:"details,omitempty"` +} + +// FilteringTag the definition of a filtering tag. Filtering tags are used for capturing resources and +// include/exclude them from being monitored. +type FilteringTag struct { + // Name - The name (also known as the key) of the tag. + Name *string `json:"name,omitempty"` + // Value - The value of the tag. + Value *string `json:"value,omitempty"` + // Action - Possible values include: 'Include', 'Exclude' + Action TagAction `json:"action,omitempty"` +} + +// Host ... +type Host struct { + // Name - The name of the host. + Name *string `json:"name,omitempty"` + // Aliases - The aliases for the host. + Aliases *[]string `json:"aliases,omitempty"` + // Apps - The Datadog integrations reporting metrics for the host. + Apps *[]string `json:"apps,omitempty"` + Meta *HostMetadata `json:"meta,omitempty"` +} + +// HostListResponse response of a list operation. +type HostListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]Host `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// HostListResponseIterator provides access to a complete listing of Host values. +type HostListResponseIterator struct { + i int + page HostListResponsePage +} + +// 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 *HostListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostListResponseIterator.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 *HostListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter HostListResponseIterator) 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 HostListResponseIterator) Response() HostListResponse { + 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 HostListResponseIterator) Value() Host { + if !iter.page.NotDone() { + return Host{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the HostListResponseIterator type. +func NewHostListResponseIterator(page HostListResponsePage) HostListResponseIterator { + return HostListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (hlr HostListResponse) IsEmpty() bool { + return hlr.Value == nil || len(*hlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (hlr HostListResponse) hasNextLink() bool { + return hlr.NextLink != nil && len(*hlr.NextLink) != 0 +} + +// hostListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (hlr HostListResponse) hostListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !hlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(hlr.NextLink))) +} + +// HostListResponsePage contains a page of Host values. +type HostListResponsePage struct { + fn func(context.Context, HostListResponse) (HostListResponse, error) + hlr HostListResponse +} + +// 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 *HostListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/HostListResponsePage.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.hlr) + if err != nil { + return err + } + page.hlr = 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 *HostListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page HostListResponsePage) NotDone() bool { + return !page.hlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page HostListResponsePage) Response() HostListResponse { + return page.hlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page HostListResponsePage) Values() []Host { + if page.hlr.IsEmpty() { + return nil + } + return *page.hlr.Value +} + +// Creates a new instance of the HostListResponsePage type. +func NewHostListResponsePage(getNextPage func(context.Context, HostListResponse) (HostListResponse, error)) HostListResponsePage { + return HostListResponsePage{fn: getNextPage} +} + +// HostMetadata ... +type HostMetadata struct { + // AgentVersion - The agent version. + AgentVersion *string `json:"agentVersion,omitempty"` + InstallMethod *InstallMethod `json:"installMethod,omitempty"` + LogsAgent *LogsAgent `json:"logsAgent,omitempty"` +} + +// IdentityProperties ... +type IdentityProperties struct { + // PrincipalID - READ-ONLY; The identity ID. + PrincipalID *string `json:"principalId,omitempty"` + // TenantID - READ-ONLY; The tenant ID of resource. + TenantID *string `json:"tenantId,omitempty"` + // Type - Possible values include: 'SystemAssigned', 'UserAssigned' + Type ManagedIdentityTypes `json:"type,omitempty"` +} + +// MarshalJSON is the custom marshaler for IdentityProperties. +func (IP IdentityProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if IP.Type != "" { + objectMap["type"] = IP.Type + } + return json.Marshal(objectMap) +} + +// InstallMethod ... +type InstallMethod struct { + // Tool - The tool. + Tool *string `json:"tool,omitempty"` + // ToolVersion - The tool version. + ToolVersion *string `json:"toolVersion,omitempty"` + // InstallerVersion - The installer version. + InstallerVersion *string `json:"installerVersion,omitempty"` +} + +// LinkedResource the definition of a linked resource. +type LinkedResource struct { + // ID - The ARM id of the linked resource. + ID *string `json:"id,omitempty"` +} + +// LinkedResourceListResponse response of a list operation. +type LinkedResourceListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]LinkedResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// LinkedResourceListResponseIterator provides access to a complete listing of LinkedResource values. +type LinkedResourceListResponseIterator struct { + i int + page LinkedResourceListResponsePage +} + +// 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 *LinkedResourceListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LinkedResourceListResponseIterator.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 *LinkedResourceListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter LinkedResourceListResponseIterator) 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 LinkedResourceListResponseIterator) Response() LinkedResourceListResponse { + 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 LinkedResourceListResponseIterator) Value() LinkedResource { + if !iter.page.NotDone() { + return LinkedResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the LinkedResourceListResponseIterator type. +func NewLinkedResourceListResponseIterator(page LinkedResourceListResponsePage) LinkedResourceListResponseIterator { + return LinkedResourceListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (lrlr LinkedResourceListResponse) IsEmpty() bool { + return lrlr.Value == nil || len(*lrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (lrlr LinkedResourceListResponse) hasNextLink() bool { + return lrlr.NextLink != nil && len(*lrlr.NextLink) != 0 +} + +// linkedResourceListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (lrlr LinkedResourceListResponse) linkedResourceListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !lrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(lrlr.NextLink))) +} + +// LinkedResourceListResponsePage contains a page of LinkedResource values. +type LinkedResourceListResponsePage struct { + fn func(context.Context, LinkedResourceListResponse) (LinkedResourceListResponse, error) + lrlr LinkedResourceListResponse +} + +// 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 *LinkedResourceListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/LinkedResourceListResponsePage.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.lrlr) + if err != nil { + return err + } + page.lrlr = 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 *LinkedResourceListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page LinkedResourceListResponsePage) NotDone() bool { + return !page.lrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page LinkedResourceListResponsePage) Response() LinkedResourceListResponse { + return page.lrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page LinkedResourceListResponsePage) Values() []LinkedResource { + if page.lrlr.IsEmpty() { + return nil + } + return *page.lrlr.Value +} + +// Creates a new instance of the LinkedResourceListResponsePage type. +func NewLinkedResourceListResponsePage(getNextPage func(context.Context, LinkedResourceListResponse) (LinkedResourceListResponse, error)) LinkedResourceListResponsePage { + return LinkedResourceListResponsePage{fn: getNextPage} +} + +// LogRules set of rules for sending logs for the Monitor resource. +type LogRules struct { + // SendAadLogs - Flag specifying if AAD logs should be sent for the Monitor resource. + SendAadLogs *bool `json:"sendAadLogs,omitempty"` + // SendSubscriptionLogs - Flag specifying if Azure subscription logs should be sent for the Monitor resource. + SendSubscriptionLogs *bool `json:"sendSubscriptionLogs,omitempty"` + // SendResourceLogs - Flag specifying if Azure resource logs should be sent for the Monitor resource. + SendResourceLogs *bool `json:"sendResourceLogs,omitempty"` + // FilteringTags - List of filtering tags to be used for capturing logs. This only takes effect if SendResourceLogs flag is enabled. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags. + FilteringTags *[]FilteringTag `json:"filteringTags,omitempty"` +} + +// LogsAgent ... +type LogsAgent struct { + // Transport - The transport. + Transport *string `json:"transport,omitempty"` +} + +// MetricRules set of rules for sending metrics for the Monitor resource. +type MetricRules struct { + // FilteringTags - List of filtering tags to be used for capturing metrics. If empty, all resources will be captured. If only Exclude action is specified, the rules will apply to the list of all available resources. If Include actions are specified, the rules will only include resources with the associated tags. + FilteringTags *[]FilteringTag `json:"filteringTags,omitempty"` +} + +// MonitoredResource the properties of a resource currently being monitored by the Datadog monitor resource. +type MonitoredResource struct { + // ID - The ARM id of the resource. + ID *string `json:"id,omitempty"` + // SendingMetrics - Flag indicating if resource is sending metrics to Datadog. + SendingMetrics *bool `json:"sendingMetrics,omitempty"` + // ReasonForMetricsStatus - Reason for why the resource is sending metrics (or why it is not sending). + ReasonForMetricsStatus *string `json:"reasonForMetricsStatus,omitempty"` + // SendingLogs - Flag indicating if resource is sending logs to Datadog. + SendingLogs *bool `json:"sendingLogs,omitempty"` + // ReasonForLogsStatus - Reason for why the resource is sending logs (or why it is not sending). + ReasonForLogsStatus *string `json:"reasonForLogsStatus,omitempty"` +} + +// MonitoredResourceListResponse response of a list operation. +type MonitoredResourceListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]MonitoredResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MonitoredResourceListResponseIterator provides access to a complete listing of MonitoredResource values. +type MonitoredResourceListResponseIterator struct { + i int + page MonitoredResourceListResponsePage +} + +// 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 *MonitoredResourceListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoredResourceListResponseIterator.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 *MonitoredResourceListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MonitoredResourceListResponseIterator) 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 MonitoredResourceListResponseIterator) Response() MonitoredResourceListResponse { + 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 MonitoredResourceListResponseIterator) Value() MonitoredResource { + if !iter.page.NotDone() { + return MonitoredResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MonitoredResourceListResponseIterator type. +func NewMonitoredResourceListResponseIterator(page MonitoredResourceListResponsePage) MonitoredResourceListResponseIterator { + return MonitoredResourceListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mrlr MonitoredResourceListResponse) IsEmpty() bool { + return mrlr.Value == nil || len(*mrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mrlr MonitoredResourceListResponse) hasNextLink() bool { + return mrlr.NextLink != nil && len(*mrlr.NextLink) != 0 +} + +// monitoredResourceListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mrlr MonitoredResourceListResponse) monitoredResourceListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !mrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mrlr.NextLink))) +} + +// MonitoredResourceListResponsePage contains a page of MonitoredResource values. +type MonitoredResourceListResponsePage struct { + fn func(context.Context, MonitoredResourceListResponse) (MonitoredResourceListResponse, error) + mrlr MonitoredResourceListResponse +} + +// 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 *MonitoredResourceListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoredResourceListResponsePage.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.mrlr) + if err != nil { + return err + } + page.mrlr = 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 *MonitoredResourceListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MonitoredResourceListResponsePage) NotDone() bool { + return !page.mrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MonitoredResourceListResponsePage) Response() MonitoredResourceListResponse { + return page.mrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MonitoredResourceListResponsePage) Values() []MonitoredResource { + if page.mrlr.IsEmpty() { + return nil + } + return *page.mrlr.Value +} + +// Creates a new instance of the MonitoredResourceListResponsePage type. +func NewMonitoredResourceListResponsePage(getNextPage func(context.Context, MonitoredResourceListResponse) (MonitoredResourceListResponse, error)) MonitoredResourceListResponsePage { + return MonitoredResourceListResponsePage{fn: getNextPage} +} + +// MonitoringTagRules capture logs and metrics of Azure resources based on ARM tags. +type MonitoringTagRules struct { + autorest.Response `json:"-"` + // Name - READ-ONLY; Name of the rule set. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; The id of the rule set. + ID *string `json:"id,omitempty"` + // Type - READ-ONLY; The type of the rule set. + Type *string `json:"type,omitempty"` + Properties *MonitoringTagRulesProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for MonitoringTagRules. +func (mtr MonitoringTagRules) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mtr.Properties != nil { + objectMap["properties"] = mtr.Properties + } + return json.Marshal(objectMap) +} + +// MonitoringTagRulesListResponse response of a list operation. +type MonitoringTagRulesListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]MonitoringTagRules `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MonitoringTagRulesListResponseIterator provides access to a complete listing of MonitoringTagRules values. +type MonitoringTagRulesListResponseIterator struct { + i int + page MonitoringTagRulesListResponsePage +} + +// 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 *MonitoringTagRulesListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoringTagRulesListResponseIterator.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 *MonitoringTagRulesListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MonitoringTagRulesListResponseIterator) 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 MonitoringTagRulesListResponseIterator) Response() MonitoringTagRulesListResponse { + 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 MonitoringTagRulesListResponseIterator) Value() MonitoringTagRules { + if !iter.page.NotDone() { + return MonitoringTagRules{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MonitoringTagRulesListResponseIterator type. +func NewMonitoringTagRulesListResponseIterator(page MonitoringTagRulesListResponsePage) MonitoringTagRulesListResponseIterator { + return MonitoringTagRulesListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mtrlr MonitoringTagRulesListResponse) IsEmpty() bool { + return mtrlr.Value == nil || len(*mtrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mtrlr MonitoringTagRulesListResponse) hasNextLink() bool { + return mtrlr.NextLink != nil && len(*mtrlr.NextLink) != 0 +} + +// monitoringTagRulesListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mtrlr MonitoringTagRulesListResponse) monitoringTagRulesListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !mtrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mtrlr.NextLink))) +} + +// MonitoringTagRulesListResponsePage contains a page of MonitoringTagRules values. +type MonitoringTagRulesListResponsePage struct { + fn func(context.Context, MonitoringTagRulesListResponse) (MonitoringTagRulesListResponse, error) + mtrlr MonitoringTagRulesListResponse +} + +// 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 *MonitoringTagRulesListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoringTagRulesListResponsePage.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.mtrlr) + if err != nil { + return err + } + page.mtrlr = 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 *MonitoringTagRulesListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MonitoringTagRulesListResponsePage) NotDone() bool { + return !page.mtrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MonitoringTagRulesListResponsePage) Response() MonitoringTagRulesListResponse { + return page.mtrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MonitoringTagRulesListResponsePage) Values() []MonitoringTagRules { + if page.mtrlr.IsEmpty() { + return nil + } + return *page.mtrlr.Value +} + +// Creates a new instance of the MonitoringTagRulesListResponsePage type. +func NewMonitoringTagRulesListResponsePage(getNextPage func(context.Context, MonitoringTagRulesListResponse) (MonitoringTagRulesListResponse, error)) MonitoringTagRulesListResponsePage { + return MonitoringTagRulesListResponsePage{fn: getNextPage} +} + +// MonitoringTagRulesProperties definition of the properties for a TagRules resource. +type MonitoringTagRulesProperties struct { + LogRules *LogRules `json:"logRules,omitempty"` + MetricRules *MetricRules `json:"metricRules,omitempty"` +} + +// MonitorProperties properties specific to the monitor resource. +type MonitorProperties struct { + // ProvisioningState - Possible values include: 'Accepted', 'Creating', 'Updating', 'Deleting', 'Succeeded', 'Failed', 'Canceled', 'Deleted', 'NotSpecified' + ProvisioningState ProvisioningState `json:"provisioningState,omitempty"` + // MonitoringStatus - Possible values include: 'Enabled', 'Disabled' + MonitoringStatus MonitoringStatus `json:"monitoringStatus,omitempty"` + // MarketplaceSubscriptionStatus - Possible values include: 'Active', 'Suspended' + MarketplaceSubscriptionStatus MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + DatadogOrganizationProperties *OrganizationProperties `json:"datadogOrganizationProperties,omitempty"` + UserInfo *UserInfo `json:"userInfo,omitempty"` + // LiftrResourceCategory - Possible values include: 'Unknown', 'MonitorLogs' + LiftrResourceCategory LiftrResourceCategories `json:"liftrResourceCategory,omitempty"` + // LiftrResourcePreference - READ-ONLY; The priority of the resource. + LiftrResourcePreference *int32 `json:"liftrResourcePreference,omitempty"` +} + +// MarshalJSON is the custom marshaler for MonitorProperties. +func (mp MonitorProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mp.ProvisioningState != "" { + objectMap["provisioningState"] = mp.ProvisioningState + } + if mp.MonitoringStatus != "" { + objectMap["monitoringStatus"] = mp.MonitoringStatus + } + if mp.MarketplaceSubscriptionStatus != "" { + objectMap["marketplaceSubscriptionStatus"] = mp.MarketplaceSubscriptionStatus + } + if mp.DatadogOrganizationProperties != nil { + objectMap["datadogOrganizationProperties"] = mp.DatadogOrganizationProperties + } + if mp.UserInfo != nil { + objectMap["userInfo"] = mp.UserInfo + } + if mp.LiftrResourceCategory != "" { + objectMap["liftrResourceCategory"] = mp.LiftrResourceCategory + } + return json.Marshal(objectMap) +} + +// MonitorResource ... +type MonitorResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; ARM id of the monitor resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the monitor resource. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the monitor resource. + Type *string `json:"type,omitempty"` + Sku *ResourceSku `json:"sku,omitempty"` + Properties *MonitorProperties `json:"properties,omitempty"` + Identity *IdentityProperties `json:"identity,omitempty"` + Tags map[string]*string `json:"tags"` + Location *string `json:"location,omitempty"` +} + +// MarshalJSON is the custom marshaler for MonitorResource. +func (mr MonitorResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mr.Sku != nil { + objectMap["sku"] = mr.Sku + } + if mr.Properties != nil { + objectMap["properties"] = mr.Properties + } + if mr.Identity != nil { + objectMap["identity"] = mr.Identity + } + if mr.Tags != nil { + objectMap["tags"] = mr.Tags + } + if mr.Location != nil { + objectMap["location"] = mr.Location + } + return json.Marshal(objectMap) +} + +// MonitorResourceListResponse response of a list operation. +type MonitorResourceListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]MonitorResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// MonitorResourceListResponseIterator provides access to a complete listing of MonitorResource values. +type MonitorResourceListResponseIterator struct { + i int + page MonitorResourceListResponsePage +} + +// 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 *MonitorResourceListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorResourceListResponseIterator.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 *MonitorResourceListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter MonitorResourceListResponseIterator) 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 MonitorResourceListResponseIterator) Response() MonitorResourceListResponse { + 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 MonitorResourceListResponseIterator) Value() MonitorResource { + if !iter.page.NotDone() { + return MonitorResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the MonitorResourceListResponseIterator type. +func NewMonitorResourceListResponseIterator(page MonitorResourceListResponsePage) MonitorResourceListResponseIterator { + return MonitorResourceListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (mrlr MonitorResourceListResponse) IsEmpty() bool { + return mrlr.Value == nil || len(*mrlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (mrlr MonitorResourceListResponse) hasNextLink() bool { + return mrlr.NextLink != nil && len(*mrlr.NextLink) != 0 +} + +// monitorResourceListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (mrlr MonitorResourceListResponse) monitorResourceListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !mrlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(mrlr.NextLink))) +} + +// MonitorResourceListResponsePage contains a page of MonitorResource values. +type MonitorResourceListResponsePage struct { + fn func(context.Context, MonitorResourceListResponse) (MonitorResourceListResponse, error) + mrlr MonitorResourceListResponse +} + +// 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 *MonitorResourceListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorResourceListResponsePage.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.mrlr) + if err != nil { + return err + } + page.mrlr = 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 *MonitorResourceListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page MonitorResourceListResponsePage) NotDone() bool { + return !page.mrlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page MonitorResourceListResponsePage) Response() MonitorResourceListResponse { + return page.mrlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page MonitorResourceListResponsePage) Values() []MonitorResource { + if page.mrlr.IsEmpty() { + return nil + } + return *page.mrlr.Value +} + +// Creates a new instance of the MonitorResourceListResponsePage type. +func NewMonitorResourceListResponsePage(getNextPage func(context.Context, MonitorResourceListResponse) (MonitorResourceListResponse, error)) MonitorResourceListResponsePage { + return MonitorResourceListResponsePage{fn: getNextPage} +} + +// MonitorResourceUpdateParameters the parameters for a PATCH request to a monitor resource. +type MonitorResourceUpdateParameters struct { + Properties *MonitorUpdateProperties `json:"properties,omitempty"` + // Tags - The new tags of the monitor resource. + Tags map[string]*string `json:"tags"` +} + +// MarshalJSON is the custom marshaler for MonitorResourceUpdateParameters. +func (mrup MonitorResourceUpdateParameters) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if mrup.Properties != nil { + objectMap["properties"] = mrup.Properties + } + if mrup.Tags != nil { + objectMap["tags"] = mrup.Tags + } + return json.Marshal(objectMap) +} + +// MonitorsCreateFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type MonitorsCreateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *MonitorsCreateFuture) Result(client MonitorsClient) (mr MonitorResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsCreateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("datadog.MonitorsCreateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if mr.Response.Response, err = future.GetResult(sender); err == nil && mr.Response.Response.StatusCode != http.StatusNoContent { + mr, err = client.CreateResponder(mr.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsCreateFuture", "Result", mr.Response.Response, "Failure responding to request") + } + } + return +} + +// MonitorsDeleteFuture an abstraction for monitoring and retrieving the results of a long-running operation. +type MonitorsDeleteFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *MonitorsDeleteFuture) Result(client MonitorsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsDeleteFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("datadog.MonitorsDeleteFuture") + return + } + ar.Response = future.Response() + return +} + +// MonitorUpdateProperties the set of properties that can be update in a PATCH request to a monitor resource. +type MonitorUpdateProperties struct { + // MonitoringStatus - Possible values include: 'Enabled', 'Disabled' + MonitoringStatus MonitoringStatus `json:"monitoringStatus,omitempty"` +} + +// OperationDisplay the object that represents the operation. +type OperationDisplay struct { + // Provider - Service provider, i.e., Microsoft.Datadog. + Provider *string `json:"provider,omitempty"` + // Resource - Type on which the operation is performed, e.g., 'monitors'. + Resource *string `json:"resource,omitempty"` + // Operation - Operation type, e.g., read, write, delete, etc. + Operation *string `json:"operation,omitempty"` + // Description - Description of the operation, e.g., 'Write monitors'. + Description *string `json:"description,omitempty"` +} + +// OperationListResult result of GET request to list the Microsoft.Datadog operations. +type OperationListResult struct { + autorest.Response `json:"-"` + // Value - List of operations supported by the Microsoft.Datadog provider. + Value *[]OperationResult `json:"value,omitempty"` + // NextLink - URL to get the next set of operation list results if there are any. + NextLink *string `json:"nextLink,omitempty"` +} + +// OperationListResultIterator provides access to a complete listing of OperationResult values. +type OperationListResultIterator struct { + i int + page OperationListResultPage +} + +// 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 *OperationListResultIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultIterator.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 *OperationListResultIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter OperationListResultIterator) 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 OperationListResultIterator) Response() OperationListResult { + 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 OperationListResultIterator) Value() OperationResult { + if !iter.page.NotDone() { + return OperationResult{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the OperationListResultIterator type. +func NewOperationListResultIterator(page OperationListResultPage) OperationListResultIterator { + return OperationListResultIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (olr OperationListResult) IsEmpty() bool { + return olr.Value == nil || len(*olr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (olr OperationListResult) hasNextLink() bool { + return olr.NextLink != nil && len(*olr.NextLink) != 0 +} + +// operationListResultPreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (olr OperationListResult) operationListResultPreparer(ctx context.Context) (*http.Request, error) { + if !olr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(olr.NextLink))) +} + +// OperationListResultPage contains a page of OperationResult values. +type OperationListResultPage struct { + fn func(context.Context, OperationListResult) (OperationListResult, error) + olr OperationListResult +} + +// 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 *OperationListResultPage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationListResultPage.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.olr) + if err != nil { + return err + } + page.olr = 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 *OperationListResultPage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page OperationListResultPage) NotDone() bool { + return !page.olr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page OperationListResultPage) Response() OperationListResult { + return page.olr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page OperationListResultPage) Values() []OperationResult { + if page.olr.IsEmpty() { + return nil + } + return *page.olr.Value +} + +// Creates a new instance of the OperationListResultPage type. +func NewOperationListResultPage(getNextPage func(context.Context, OperationListResult) (OperationListResult, error)) OperationListResultPage { + return OperationListResultPage{fn: getNextPage} +} + +// OperationResult a Microsoft.Datadog REST API operation. +type OperationResult struct { + // Name - Operation name, i.e., {provider}/{resource}/{operation}. + Name *string `json:"name,omitempty"` + Display *OperationDisplay `json:"display,omitempty"` + // IsDataAction - Indicates whether the operation is a data action + IsDataAction *bool `json:"isDataAction,omitempty"` +} + +// OrganizationProperties ... +type OrganizationProperties struct { + // Name - READ-ONLY; Name of the Datadog organization. + Name *string `json:"name,omitempty"` + // ID - READ-ONLY; Id of the Datadog organization. + ID *string `json:"id,omitempty"` + // LinkingAuthCode - The auth code used to linking to an existing datadog organization. + LinkingAuthCode *string `json:"linkingAuthCode,omitempty"` + // LinkingClientID - The client_id from an existing in exchange for an auth token to link organization. + LinkingClientID *string `json:"linkingClientId,omitempty"` + // EnterpriseAppID - The Id of the Enterprise App used for Single sign on. + EnterpriseAppID *string `json:"enterpriseAppId,omitempty"` +} + +// MarshalJSON is the custom marshaler for OrganizationProperties. +func (op OrganizationProperties) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if op.LinkingAuthCode != nil { + objectMap["linkingAuthCode"] = op.LinkingAuthCode + } + if op.LinkingClientID != nil { + objectMap["linkingClientId"] = op.LinkingClientID + } + if op.EnterpriseAppID != nil { + objectMap["enterpriseAppId"] = op.EnterpriseAppID + } + return json.Marshal(objectMap) +} + +// ResourceProviderDefaultErrorResponse ... +type ResourceProviderDefaultErrorResponse struct { + Error *ErrorResponseBody `json:"error,omitempty"` +} + +// ResourceSku ... +type ResourceSku struct { + // Name - Name of the SKU. + Name *string `json:"name,omitempty"` +} + +// SetPasswordLink ... +type SetPasswordLink struct { + autorest.Response `json:"-"` + SetPasswordLink *string `json:"setPasswordLink,omitempty"` +} + +// SingleSignOnConfigurationsCreateOrUpdateFuture an abstraction for monitoring and retrieving the results of a +// long-running operation. +type SingleSignOnConfigurationsCreateOrUpdateFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *SingleSignOnConfigurationsCreateOrUpdateFuture) Result(client SingleSignOnConfigurationsClient) (ssor SingleSignOnResource, err error) { + var done bool + done, err = future.DoneWithContext(context.Background(), client) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsCreateOrUpdateFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("datadog.SingleSignOnConfigurationsCreateOrUpdateFuture") + return + } + sender := autorest.DecorateSender(client, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) + if ssor.Response.Response, err = future.GetResult(sender); err == nil && ssor.Response.Response.StatusCode != http.StatusNoContent { + ssor, err = client.CreateOrUpdateResponder(ssor.Response.Response) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsCreateOrUpdateFuture", "Result", ssor.Response.Response, "Failure responding to request") + } + } + return +} + +// SingleSignOnProperties ... +type SingleSignOnProperties struct { + // SingleSignOnState - Possible values include: 'Initial', 'Enable', 'Disable', 'Existing' + SingleSignOnState SingleSignOnStates `json:"singleSignOnState,omitempty"` + // EnterpriseAppID - The Id of the Enterprise App used for Single sign-on. + EnterpriseAppID *string `json:"enterpriseAppId,omitempty"` + // SingleSignOnURL - The login URL specific to this Datadog Organization. + SingleSignOnURL *string `json:"singleSignOnUrl,omitempty"` +} + +// SingleSignOnResource ... +type SingleSignOnResource struct { + autorest.Response `json:"-"` + // ID - READ-ONLY; ARM id of the resource. + ID *string `json:"id,omitempty"` + // Name - READ-ONLY; Name of the configuration. + Name *string `json:"name,omitempty"` + // Type - READ-ONLY; The type of the resource. + Type *string `json:"type,omitempty"` + Properties *SingleSignOnProperties `json:"properties,omitempty"` +} + +// MarshalJSON is the custom marshaler for SingleSignOnResource. +func (ssor SingleSignOnResource) MarshalJSON() ([]byte, error) { + objectMap := make(map[string]interface{}) + if ssor.Properties != nil { + objectMap["properties"] = ssor.Properties + } + return json.Marshal(objectMap) +} + +// SingleSignOnResourceListResponse response of a list operation. +type SingleSignOnResourceListResponse struct { + autorest.Response `json:"-"` + // Value - Results of a list operation. + Value *[]SingleSignOnResource `json:"value,omitempty"` + // NextLink - Link to the next set of results, if any. + NextLink *string `json:"nextLink,omitempty"` +} + +// SingleSignOnResourceListResponseIterator provides access to a complete listing of SingleSignOnResource +// values. +type SingleSignOnResourceListResponseIterator struct { + i int + page SingleSignOnResourceListResponsePage +} + +// 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 *SingleSignOnResourceListResponseIterator) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnResourceListResponseIterator.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 *SingleSignOnResourceListResponseIterator) Next() error { + return iter.NextWithContext(context.Background()) +} + +// NotDone returns true if the enumeration should be started or is not yet complete. +func (iter SingleSignOnResourceListResponseIterator) 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 SingleSignOnResourceListResponseIterator) Response() SingleSignOnResourceListResponse { + 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 SingleSignOnResourceListResponseIterator) Value() SingleSignOnResource { + if !iter.page.NotDone() { + return SingleSignOnResource{} + } + return iter.page.Values()[iter.i] +} + +// Creates a new instance of the SingleSignOnResourceListResponseIterator type. +func NewSingleSignOnResourceListResponseIterator(page SingleSignOnResourceListResponsePage) SingleSignOnResourceListResponseIterator { + return SingleSignOnResourceListResponseIterator{page: page} +} + +// IsEmpty returns true if the ListResult contains no values. +func (ssorlr SingleSignOnResourceListResponse) IsEmpty() bool { + return ssorlr.Value == nil || len(*ssorlr.Value) == 0 +} + +// hasNextLink returns true if the NextLink is not empty. +func (ssorlr SingleSignOnResourceListResponse) hasNextLink() bool { + return ssorlr.NextLink != nil && len(*ssorlr.NextLink) != 0 +} + +// singleSignOnResourceListResponsePreparer prepares a request to retrieve the next set of results. +// It returns nil if no more results exist. +func (ssorlr SingleSignOnResourceListResponse) singleSignOnResourceListResponsePreparer(ctx context.Context) (*http.Request, error) { + if !ssorlr.hasNextLink() { + return nil, nil + } + return autorest.Prepare((&http.Request{}).WithContext(ctx), + autorest.AsJSON(), + autorest.AsGet(), + autorest.WithBaseURL(to.String(ssorlr.NextLink))) +} + +// SingleSignOnResourceListResponsePage contains a page of SingleSignOnResource values. +type SingleSignOnResourceListResponsePage struct { + fn func(context.Context, SingleSignOnResourceListResponse) (SingleSignOnResourceListResponse, error) + ssorlr SingleSignOnResourceListResponse +} + +// 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 *SingleSignOnResourceListResponsePage) NextWithContext(ctx context.Context) (err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnResourceListResponsePage.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.ssorlr) + if err != nil { + return err + } + page.ssorlr = 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 *SingleSignOnResourceListResponsePage) Next() error { + return page.NextWithContext(context.Background()) +} + +// NotDone returns true if the page enumeration should be started or is not yet complete. +func (page SingleSignOnResourceListResponsePage) NotDone() bool { + return !page.ssorlr.IsEmpty() +} + +// Response returns the raw server response from the last page request. +func (page SingleSignOnResourceListResponsePage) Response() SingleSignOnResourceListResponse { + return page.ssorlr +} + +// Values returns the slice of values for the current page or nil if there are no values. +func (page SingleSignOnResourceListResponsePage) Values() []SingleSignOnResource { + if page.ssorlr.IsEmpty() { + return nil + } + return *page.ssorlr.Value +} + +// Creates a new instance of the SingleSignOnResourceListResponsePage type. +func NewSingleSignOnResourceListResponsePage(getNextPage func(context.Context, SingleSignOnResourceListResponse) (SingleSignOnResourceListResponse, error)) SingleSignOnResourceListResponsePage { + return SingleSignOnResourceListResponsePage{fn: getNextPage} +} + +// UserInfo ... +type UserInfo struct { + // Name - Name of the user + Name *string `json:"name,omitempty"` + // EmailAddress - Email of the user used by Datadog for contacting them if needed + EmailAddress *string `json:"emailAddress,omitempty"` + // PhoneNumber - Phone number of the user used by Datadog for contacting them if needed + PhoneNumber *string `json:"phoneNumber,omitempty"` +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitoredresources.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitoredresources.go new file mode 100644 index 000000000000..d3d49a7b46ae --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitoredresources.go @@ -0,0 +1,159 @@ +package datadog + +// 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" +) + +// MonitoredResourcesClient is the client for the MonitoredResources methods of the Datadog service. +type MonitoredResourcesClient struct { + BaseClient +} + +// NewMonitoredResourcesClient creates an instance of the MonitoredResourcesClient client. +func NewMonitoredResourcesClient(subscriptionID string) MonitoredResourcesClient { + return NewMonitoredResourcesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMonitoredResourcesClientWithBaseURI creates an instance of the MonitoredResourcesClient 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 NewMonitoredResourcesClientWithBaseURI(baseURI string, subscriptionID string) MonitoredResourcesClient { + return MonitoredResourcesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client MonitoredResourcesClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result MonitoredResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoredResourcesClient.List") + defer func() { + sc := -1 + if result.mrlr.Response.Response != nil { + sc = result.mrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitoredResourcesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.mrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.MonitoredResourcesClient", "List", resp, "Failure sending request") + return + } + + result.mrlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitoredResourcesClient", "List", resp, "Failure responding to request") + } + if result.mrlr.hasNextLink() && result.mrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client MonitoredResourcesClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/listMonitoredResources", 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 MonitoredResourcesClient) 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 MonitoredResourcesClient) ListResponder(resp *http.Response) (result MonitoredResourceListResponse, 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 MonitoredResourcesClient) listNextResults(ctx context.Context, lastResults MonitoredResourceListResponse) (result MonitoredResourceListResponse, err error) { + req, err := lastResults.monitoredResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.MonitoredResourcesClient", "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, "datadog.MonitoredResourcesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitoredResourcesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client MonitoredResourcesClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result MonitoredResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitoredResourcesClient.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, monitorName) + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitors.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitors.go new file mode 100644 index 000000000000..656e8b4cf24e --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/monitors.go @@ -0,0 +1,600 @@ +package datadog + +// 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/autorest/validation" + "github.com/Azure/go-autorest/tracing" + "net/http" +) + +// MonitorsClient is the client for the Monitors methods of the Datadog service. +type MonitorsClient struct { + BaseClient +} + +// NewMonitorsClient creates an instance of the MonitorsClient client. +func NewMonitorsClient(subscriptionID string) MonitorsClient { + return NewMonitorsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewMonitorsClientWithBaseURI creates an instance of the MonitorsClient 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 NewMonitorsClientWithBaseURI(baseURI string, subscriptionID string) MonitorsClient { + return MonitorsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Create sends the create request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client MonitorsClient) Create(ctx context.Context, resourceGroupName string, monitorName string, body *MonitorResource) (result MonitorsCreateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.Create") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + if err := validation.Validate([]validation.Validation{ + {TargetValue: body, + Constraints: []validation.Constraint{{Target: "body", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Sku", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Sku.Name", Name: validation.Null, Rule: true, Chain: nil}}}, + {Target: "body.Properties", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.UserInfo", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.UserInfo.Name", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.UserInfo.Name", Name: validation.MaxLength, Rule: 50, Chain: nil}}}, + {Target: "body.Properties.UserInfo.EmailAddress", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.UserInfo.EmailAddress", Name: validation.Pattern, Rule: `^[A-Za-z0-9._%+-]+@(?:[A-Za-z0-9-]+\.)+[A-Za-z]{2,}$`, Chain: nil}}}, + {Target: "body.Properties.UserInfo.PhoneNumber", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "body.Properties.UserInfo.PhoneNumber", Name: validation.MaxLength, Rule: 40, Chain: nil}}}, + }}, + }}, + {Target: "body.Location", Name: validation.Null, Rule: true, Chain: nil}, + }}}}}); err != nil { + return result, validation.NewError("datadog.MonitorsClient", "Create", err.Error()) + } + + req, err := client.CreatePreparer(ctx, resourceGroupName, monitorName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Create", nil, "Failure preparing request") + return + } + + result, err = client.CreateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Create", result.Response(), "Failure sending request") + return + } + + return +} + +// CreatePreparer prepares the Create request. +func (client MonitorsClient) CreatePreparer(ctx context.Context, resourceGroupName string, monitorName string, body *MonitorResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 MonitorsClient) CreateSender(req *http.Request) (future MonitorsCreateFuture, 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 +} + +// CreateResponder handles the response to the Create request. The method always +// closes the http.Response Body. +func (client MonitorsClient) CreateResponder(resp *http.Response) (result MonitorResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Delete sends the delete request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client MonitorsClient) Delete(ctx context.Context, resourceGroupName string, monitorName string) (result MonitorsDeleteFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.Delete") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.DeletePreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Delete", nil, "Failure preparing request") + return + } + + result, err = client.DeleteSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Delete", result.Response(), "Failure sending request") + return + } + + return +} + +// DeletePreparer prepares the Delete request. +func (client MonitorsClient) DeletePreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}", 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 MonitorsClient) DeleteSender(req *http.Request) (future MonitorsDeleteFuture, 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 MonitorsClient) 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 sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client MonitorsClient) Get(ctx context.Context, resourceGroupName string, monitorName string) (result MonitorResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.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, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client MonitorsClient) GetPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}", 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 MonitorsClient) 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 MonitorsClient) GetResponder(resp *http.Response) (result MonitorResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +func (client MonitorsClient) List(ctx context.Context) (result MonitorResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.List") + defer func() { + sc := -1 + if result.mrlr.Response.Response != nil { + sc = result.mrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.mrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "List", resp, "Failure sending request") + return + } + + result.mrlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "List", resp, "Failure responding to request") + } + if result.mrlr.hasNextLink() && result.mrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client MonitorsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.Datadog/monitors", 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 MonitorsClient) 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 MonitorsClient) ListResponder(resp *http.Response) (result MonitorResourceListResponse, 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 MonitorsClient) listNextResults(ctx context.Context, lastResults MonitorResourceListResponse) (result MonitorResourceListResponse, err error) { + req, err := lastResults.monitorResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.MonitorsClient", "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, "datadog.MonitorsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client MonitorsClient) ListComplete(ctx context.Context) (result MonitorResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.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 +} + +// ListByResourceGroup sends the list by resource group request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +func (client MonitorsClient) ListByResourceGroup(ctx context.Context, resourceGroupName string) (result MonitorResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.ListByResourceGroup") + defer func() { + sc := -1 + if result.mrlr.Response.Response != nil { + sc = result.mrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listByResourceGroupNextResults + req, err := client.ListByResourceGroupPreparer(ctx, resourceGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "ListByResourceGroup", nil, "Failure preparing request") + return + } + + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.mrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "ListByResourceGroup", resp, "Failure sending request") + return + } + + result.mrlr, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "ListByResourceGroup", resp, "Failure responding to request") + } + if result.mrlr.hasNextLink() && result.mrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListByResourceGroupPreparer prepares the ListByResourceGroup request. +func (client MonitorsClient) ListByResourceGroupPreparer(ctx context.Context, resourceGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the +// http.Response Body if it receives an error. +func (client MonitorsClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always +// closes the http.Response Body. +func (client MonitorsClient) ListByResourceGroupResponder(resp *http.Response) (result MonitorResourceListResponse, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// listByResourceGroupNextResults retrieves the next set of results, if any. +func (client MonitorsClient) listByResourceGroupNextResults(ctx context.Context, lastResults MonitorResourceListResponse) (result MonitorResourceListResponse, err error) { + req, err := lastResults.monitorResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.MonitorsClient", "listByResourceGroupNextResults", nil, "Failure preparing next results request") + } + if req == nil { + return + } + resp, err := client.ListByResourceGroupSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + return result, autorest.NewErrorWithError(err, "datadog.MonitorsClient", "listByResourceGroupNextResults", resp, "Failure sending next results request") + } + result, err = client.ListByResourceGroupResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "listByResourceGroupNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListByResourceGroupComplete enumerates all values, automatically crossing page boundaries as required. +func (client MonitorsClient) ListByResourceGroupComplete(ctx context.Context, resourceGroupName string) (result MonitorResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.ListByResourceGroup") + 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.ListByResourceGroup(ctx, resourceGroupName) + return +} + +// Update sends the update request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client MonitorsClient) Update(ctx context.Context, resourceGroupName string, monitorName string, body *MonitorResourceUpdateParameters) (result MonitorResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/MonitorsClient.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, monitorName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Update", nil, "Failure preparing request") + return + } + + resp, err := client.UpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Update", resp, "Failure sending request") + return + } + + result, err = client.UpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.MonitorsClient", "Update", resp, "Failure responding to request") + } + + return +} + +// UpdatePreparer prepares the Update request. +func (client MonitorsClient) UpdatePreparer(ctx context.Context, resourceGroupName string, monitorName string, body *MonitorResourceUpdateParameters) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + 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 MonitorsClient) 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 MonitorsClient) UpdateResponder(resp *http.Response) (result MonitorResource, 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/services/preview/datadog/mgmt/2020-02-01-preview/datadog/operations.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/operations.go new file mode 100644 index 000000000000..f433ad495e09 --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/operations.go @@ -0,0 +1,149 @@ +package datadog + +// 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" +) + +// OperationsClient is the client for the Operations methods of the Datadog service. +type OperationsClient struct { + BaseClient +} + +// NewOperationsClient creates an instance of the OperationsClient client. +func NewOperationsClient(subscriptionID string) OperationsClient { + return NewOperationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewOperationsClientWithBaseURI creates an instance of the OperationsClient 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 NewOperationsClientWithBaseURI(baseURI string, subscriptionID string) OperationsClient { + return OperationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// List sends the list request. +func (client OperationsClient) List(ctx context.Context) (result OperationListResultPage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.List") + defer func() { + sc := -1 + if result.olr.Response.Response != nil { + sc = result.olr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.OperationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.olr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.OperationsClient", "List", resp, "Failure sending request") + return + } + + result.olr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.OperationsClient", "List", resp, "Failure responding to request") + } + if result.olr.hasNextLink() && result.olr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPath("/providers/Microsoft.Datadog/operations"), + 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 OperationsClient) ListSender(req *http.Request) (*http.Response, error) { + return client.Send(req, autorest.DoRetryForStatusCodes(client.RetryAttempts, client.RetryDuration, autorest.StatusCodesForRetry...)) +} + +// ListResponder handles the response to the List request. The method always +// closes the http.Response Body. +func (client OperationsClient) ListResponder(resp *http.Response) (result OperationListResult, 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 OperationsClient) listNextResults(ctx context.Context, lastResults OperationListResult) (result OperationListResult, err error) { + req, err := lastResults.operationListResultPreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.OperationsClient", "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, "datadog.OperationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.OperationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client OperationsClient) ListComplete(ctx context.Context) (result OperationListResultIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/OperationsClient.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 +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/refreshsetpassword.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/refreshsetpassword.go new file mode 100644 index 000000000000..c0e3b9bcb1f6 --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/refreshsetpassword.go @@ -0,0 +1,118 @@ +package datadog + +// 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" +) + +// RefreshSetPasswordClient is the client for the RefreshSetPassword methods of the Datadog service. +type RefreshSetPasswordClient struct { + BaseClient +} + +// NewRefreshSetPasswordClient creates an instance of the RefreshSetPasswordClient client. +func NewRefreshSetPasswordClient(subscriptionID string) RefreshSetPasswordClient { + return NewRefreshSetPasswordClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewRefreshSetPasswordClientWithBaseURI creates an instance of the RefreshSetPasswordClient 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 NewRefreshSetPasswordClientWithBaseURI(baseURI string, subscriptionID string) RefreshSetPasswordClient { + return RefreshSetPasswordClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client RefreshSetPasswordClient) Get(ctx context.Context, resourceGroupName string, monitorName string) (result SetPasswordLink, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/RefreshSetPasswordClient.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, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.RefreshSetPasswordClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.RefreshSetPasswordClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.RefreshSetPasswordClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client RefreshSetPasswordClient) GetPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-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.Datadog/monitors/{monitorName}/refreshSetPasswordLink", 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 RefreshSetPasswordClient) 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 RefreshSetPasswordClient) GetResponder(resp *http.Response) (result SetPasswordLink, 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/services/preview/datadog/mgmt/2020-02-01-preview/datadog/singlesignonconfigurations.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/singlesignonconfigurations.go new file mode 100644 index 000000000000..056a11ca816b --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/singlesignonconfigurations.go @@ -0,0 +1,319 @@ +package datadog + +// 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" +) + +// SingleSignOnConfigurationsClient is the client for the SingleSignOnConfigurations methods of the Datadog service. +type SingleSignOnConfigurationsClient struct { + BaseClient +} + +// NewSingleSignOnConfigurationsClient creates an instance of the SingleSignOnConfigurationsClient client. +func NewSingleSignOnConfigurationsClient(subscriptionID string) SingleSignOnConfigurationsClient { + return NewSingleSignOnConfigurationsClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewSingleSignOnConfigurationsClientWithBaseURI creates an instance of the SingleSignOnConfigurationsClient 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 NewSingleSignOnConfigurationsClientWithBaseURI(baseURI string, subscriptionID string) SingleSignOnConfigurationsClient { + return SingleSignOnConfigurationsClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client SingleSignOnConfigurationsClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, body *SingleSignOnResource) (result SingleSignOnConfigurationsCreateOrUpdateFuture, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnConfigurationsClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response() != nil { + sc = result.Response().StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, monitorName, configurationName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + result, err = client.CreateOrUpdateSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "CreateOrUpdate", result.Response(), "Failure sending request") + return + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client SingleSignOnConfigurationsClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, monitorName string, configurationName string, body *SingleSignOnResource) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.ID = nil + body.Name = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client SingleSignOnConfigurationsClient) CreateOrUpdateSender(req *http.Request) (future SingleSignOnConfigurationsCreateOrUpdateFuture, 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 +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client SingleSignOnConfigurationsClient) CreateOrUpdateResponder(resp *http.Response) (result SingleSignOnResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client SingleSignOnConfigurationsClient) Get(ctx context.Context, resourceGroupName string, monitorName string, configurationName string) (result SingleSignOnResource, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnConfigurationsClient.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, monitorName, configurationName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client SingleSignOnConfigurationsClient) GetPreparer(ctx context.Context, resourceGroupName string, monitorName string, configurationName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "configurationName": autorest.Encode("path", configurationName), + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}/singleSignOnConfigurations/{configurationName}", 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 SingleSignOnConfigurationsClient) 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 SingleSignOnConfigurationsClient) GetResponder(resp *http.Response) (result SingleSignOnResource, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client SingleSignOnConfigurationsClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result SingleSignOnResourceListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnConfigurationsClient.List") + defer func() { + sc := -1 + if result.ssorlr.Response.Response != nil { + sc = result.ssorlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.ssorlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "List", resp, "Failure sending request") + return + } + + result.ssorlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "List", resp, "Failure responding to request") + } + if result.ssorlr.hasNextLink() && result.ssorlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client SingleSignOnConfigurationsClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}/singleSignOnConfigurations", 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 SingleSignOnConfigurationsClient) 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 SingleSignOnConfigurationsClient) ListResponder(resp *http.Response) (result SingleSignOnResourceListResponse, 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 SingleSignOnConfigurationsClient) listNextResults(ctx context.Context, lastResults SingleSignOnResourceListResponse) (result SingleSignOnResourceListResponse, err error) { + req, err := lastResults.singleSignOnResourceListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "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, "datadog.SingleSignOnConfigurationsClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.SingleSignOnConfigurationsClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client SingleSignOnConfigurationsClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result SingleSignOnResourceListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/SingleSignOnConfigurationsClient.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, monitorName) + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/tagrules.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/tagrules.go new file mode 100644 index 000000000000..e071b6eb395d --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/tagrules.go @@ -0,0 +1,318 @@ +package datadog + +// 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" +) + +// TagRulesClient is the client for the TagRules methods of the Datadog service. +type TagRulesClient struct { + BaseClient +} + +// NewTagRulesClient creates an instance of the TagRulesClient client. +func NewTagRulesClient(subscriptionID string) TagRulesClient { + return NewTagRulesClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewTagRulesClientWithBaseURI creates an instance of the TagRulesClient 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 NewTagRulesClientWithBaseURI(baseURI string, subscriptionID string) TagRulesClient { + return TagRulesClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// CreateOrUpdate sends the create or update request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client TagRulesClient) CreateOrUpdate(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, body *MonitoringTagRules) (result MonitoringTagRules, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagRulesClient.CreateOrUpdate") + defer func() { + sc := -1 + if result.Response.Response != nil { + sc = result.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + req, err := client.CreateOrUpdatePreparer(ctx, resourceGroupName, monitorName, ruleSetName, body) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "CreateOrUpdate", nil, "Failure preparing request") + return + } + + resp, err := client.CreateOrUpdateSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "CreateOrUpdate", resp, "Failure sending request") + return + } + + result, err = client.CreateOrUpdateResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "CreateOrUpdate", resp, "Failure responding to request") + } + + return +} + +// CreateOrUpdatePreparer prepares the CreateOrUpdate request. +func (client TagRulesClient) CreateOrUpdatePreparer(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string, body *MonitoringTagRules) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleSetName": autorest.Encode("path", ruleSetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-01-preview" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + body.Name = nil + body.ID = nil + body.Type = nil + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPut(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}", pathParameters), + autorest.WithQueryParameters(queryParameters)) + if body != nil { + preparer = autorest.DecoratePreparer(preparer, + autorest.WithJSON(body)) + } + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the +// http.Response Body if it receives an error. +func (client TagRulesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) { + return client.Send(req, azure.DoRetryWithRegistration(client.Client)) +} + +// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always +// closes the http.Response Body. +func (client TagRulesClient) CreateOrUpdateResponder(resp *http.Response) (result MonitoringTagRules, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// Get sends the get request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client TagRulesClient) Get(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string) (result MonitoringTagRules, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagRulesClient.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, monitorName, ruleSetName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "Get", nil, "Failure preparing request") + return + } + + resp, err := client.GetSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "Get", resp, "Failure sending request") + return + } + + result, err = client.GetResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "Get", resp, "Failure responding to request") + } + + return +} + +// GetPreparer prepares the Get request. +func (client TagRulesClient) GetPreparer(ctx context.Context, resourceGroupName string, monitorName string, ruleSetName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "ruleSetName": autorest.Encode("path", ruleSetName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}/tagRules/{ruleSetName}", 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 TagRulesClient) 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 TagRulesClient) GetResponder(resp *http.Response) (result MonitoringTagRules, err error) { + err = autorest.Respond( + resp, + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// List sends the list request. +// Parameters: +// resourceGroupName - the name of the resource group to which the Datadog resource belongs. +// monitorName - monitor resource name +func (client TagRulesClient) List(ctx context.Context, resourceGroupName string, monitorName string) (result MonitoringTagRulesListResponsePage, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagRulesClient.List") + defer func() { + sc := -1 + if result.mtrlr.Response.Response != nil { + sc = result.mtrlr.Response.Response.StatusCode + } + tracing.EndSpan(ctx, sc, err) + }() + } + result.fn = client.listNextResults + req, err := client.ListPreparer(ctx, resourceGroupName, monitorName) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "List", nil, "Failure preparing request") + return + } + + resp, err := client.ListSender(req) + if err != nil { + result.mtrlr.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "List", resp, "Failure sending request") + return + } + + result.mtrlr, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "List", resp, "Failure responding to request") + } + if result.mtrlr.hasNextLink() && result.mtrlr.IsEmpty() { + err = result.NextWithContext(ctx) + } + + return +} + +// ListPreparer prepares the List request. +func (client TagRulesClient) ListPreparer(ctx context.Context, resourceGroupName string, monitorName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "monitorName": autorest.Encode("path", monitorName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2020-02-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.Datadog/monitors/{monitorName}/tagRules", 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 TagRulesClient) 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 TagRulesClient) ListResponder(resp *http.Response) (result MonitoringTagRulesListResponse, 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 TagRulesClient) listNextResults(ctx context.Context, lastResults MonitoringTagRulesListResponse) (result MonitoringTagRulesListResponse, err error) { + req, err := lastResults.monitoringTagRulesListResponsePreparer(ctx) + if err != nil { + return result, autorest.NewErrorWithError(err, "datadog.TagRulesClient", "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, "datadog.TagRulesClient", "listNextResults", resp, "Failure sending next results request") + } + result, err = client.ListResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "datadog.TagRulesClient", "listNextResults", resp, "Failure responding to next results request") + } + return +} + +// ListComplete enumerates all values, automatically crossing page boundaries as required. +func (client TagRulesClient) ListComplete(ctx context.Context, resourceGroupName string, monitorName string) (result MonitoringTagRulesListResponseIterator, err error) { + if tracing.IsEnabled() { + ctx = tracing.StartSpan(ctx, fqdn+"/TagRulesClient.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, monitorName) + return +} diff --git a/services/preview/datadog/mgmt/2020-02-01-preview/datadog/version.go b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/version.go new file mode 100644 index 000000000000..7834e7d73cfb --- /dev/null +++ b/services/preview/datadog/mgmt/2020-02-01-preview/datadog/version.go @@ -0,0 +1,30 @@ +package datadog + +import "github.com/Azure/azure-sdk-for-go/version" + +// 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. + +// UserAgent returns the UserAgent string to use when sending http.Requests. +func UserAgent() string { + return "Azure-SDK-For-Go/" + Version() + " datadog/2020-02-01-preview" +} + +// Version returns the semantic version (see http://semver.org) of the client. +func Version() string { + return version.Number +}