// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
// Code generated by Microsoft (R) Go Code Generator. DO NOT EDIT.

package armsql_test

import (
	"context"
	"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
	"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
	"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/sql/armsql/v2"
	"log"
)

// Generated from example definition: 2025-02-01-preview/ManagedDatabaseSecurityEventsGetMax.json
func ExampleManagedDatabaseSecurityEventsClient_NewListByDatabasePager_getTheManagedDatabaseSSecurityEventsWithMaximalParameters() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armsql.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagedDatabaseSecurityEventsClient().NewListByDatabasePager("testrg", "testcl", "database1", &armsql.ManagedDatabaseSecurityEventsClientListByDatabaseOptions{
		Filter:    to.Ptr("ShowServerRecords eq true"),
		Skip:      to.Ptr[int64](0),
		Skiptoken: to.Ptr("eyJCbG9iTmFtZURhdGVUaW1lIjoiXC9EYXRlKDE1MTIyODg4MTIwMTArMDIwMClcLyIsIkJsb2JOYW1lUm9sbG92ZXJJbmRleCI6IjAiLCJFbmREYXRlIjoiXC9EYXRlKDE1MTI0NjYyMDA1MjkpXC8iLCJJc1NraXBUb2tlblNldCI6ZmFsc2UsIklzVjJCbG9iVGltZUZvcm1hdCI6dHJ1ZSwiU2hvd1NlcnZlclJlY29yZHMiOmZhbHNlLCJTa2lwVmFsdWUiOjAsIlRha2VWYWx1ZSI6MTB9"),
		Top:       to.Ptr[int64](1)})
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armsql.ManagedDatabaseSecurityEventsClientListByDatabaseResponse{
		// 	SecurityEventCollection: armsql.SecurityEventCollection{
		// 		NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/database1/securityEvents?$skipToken=C9EYXRlKDE1MTIyODg4MTIwMTArMDIwMClcLyIsIkJsb2JOYW1lUm9sbC9EYXRlKDE1MTIyODg4MTIwMTArMDIwMClcLyIsIkJsb2JOYW1lUm9sbC9EYXRlKDE1MTIyODg4MTIwMTArMDIwMClcLyIsIkJsb2JOYW1lUm9sbC9EYXRlKDE1MTIyODg4MTIwMTArMDIwMClcLyIsIkJsb2JOYW1lUm9sb&api-version=2017-10-01-preview"),
		// 		Value: []*armsql.SecurityEvent{
		// 			{
		// 				Name: to.Ptr("06364798761800000000000000001"),
		// 				Type: to.Ptr("Microsoft.Sql/servers/databases/securityEvents"),
		// 				ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/database1/securityEvents/06364798761800000000000000001"),
		// 				Properties: &armsql.SecurityEventProperties{
		// 					ApplicationName: to.Ptr("myApp"),
		// 					ClientIP: to.Ptr("10.166.113.220"),
		// 					Database: to.Ptr("database1"),
		// 					EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-24T10:13:24.729Z"); return t}()),
		// 					PrincipalName: to.Ptr("maliciousUser"),
		// 					SecurityEventSQLInjectionAdditionalProperties: &armsql.SecurityEventSQLInjectionAdditionalProperties{
		// 						ErrorCode: to.Ptr[int32](0),
		// 						ErrorMessage: to.Ptr(""),
		// 						ErrorSeverity: to.Ptr[int32](0),
		// 						Statement: to.Ptr("select * from sys.databases where database_id like '' or 1 = 1 --' and family = 'test11'"),
		// 						StatementHighlightLength: to.Ptr[int32](13),
		// 						StatementHighlightOffset: to.Ptr[int32](52),
		// 						ThreatID: to.Ptr("1"),
		// 					},
		// 					SecurityEventType: to.Ptr(armsql.SecurityEventTypeSQLInjectionExploit),
		// 					Server: to.Ptr("testcl"),
		// 					Subscription: to.Ptr("00000000-1111-2222-3333-444444444444"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}

// Generated from example definition: 2025-02-01-preview/ManagedDatabaseSecurityEventsGetMin.json
func ExampleManagedDatabaseSecurityEventsClient_NewListByDatabasePager_getTheManagedDatabaseSSecurityEventsWithMinimalParameters() {
	cred, err := azidentity.NewDefaultAzureCredential(nil)
	if err != nil {
		log.Fatalf("failed to obtain a credential: %v", err)
	}
	ctx := context.Background()
	clientFactory, err := armsql.NewClientFactory("00000000-1111-2222-3333-444444444444", cred, nil)
	if err != nil {
		log.Fatalf("failed to create client: %v", err)
	}
	pager := clientFactory.NewManagedDatabaseSecurityEventsClient().NewListByDatabasePager("testrg", "testcl", "database1", nil)
	for pager.More() {
		page, err := pager.NextPage(ctx)
		if err != nil {
			log.Fatalf("failed to advance page: %v", err)
		}
		for _, v := range page.Value {
			// You could use page here. We use blank identifier for just demo purposes.
			_ = v
		}
		// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
		// page = armsql.ManagedDatabaseSecurityEventsClientListByDatabaseResponse{
		// 	SecurityEventCollection: armsql.SecurityEventCollection{
		// 		Value: []*armsql.SecurityEvent{
		// 			{
		// 				Name: to.Ptr("06364798761800000000000000001"),
		// 				Type: to.Ptr("Microsoft.Sql/servers/databases/securityEvents"),
		// 				ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/database1/securityEvents/06364798761800000000000000001"),
		// 				Properties: &armsql.SecurityEventProperties{
		// 					ApplicationName: to.Ptr("myApp"),
		// 					ClientIP: to.Ptr("10.166.113.220"),
		// 					Database: to.Ptr("database1"),
		// 					EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-24T10:13:24.729Z"); return t}()),
		// 					PrincipalName: to.Ptr("maliciousUser"),
		// 					SecurityEventSQLInjectionAdditionalProperties: &armsql.SecurityEventSQLInjectionAdditionalProperties{
		// 						ErrorCode: to.Ptr[int32](0),
		// 						ErrorMessage: to.Ptr(""),
		// 						ErrorSeverity: to.Ptr[int32](0),
		// 						Statement: to.Ptr("select * from sys.databases where database_id like '' or 1 = 1 --' and family = 'test11'"),
		// 						StatementHighlightLength: to.Ptr[int32](13),
		// 						StatementHighlightOffset: to.Ptr[int32](52),
		// 						ThreatID: to.Ptr("1"),
		// 					},
		// 					SecurityEventType: to.Ptr(armsql.SecurityEventTypeSQLInjectionExploit),
		// 					Server: to.Ptr("testcl"),
		// 					Subscription: to.Ptr("00000000-1111-2222-3333-444444444444"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("06364798761800000000000000002"),
		// 				Type: to.Ptr("Microsoft.Sql/servers/databases/securityEvents"),
		// 				ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/database1/securityEvents/06364798761800000000000000002"),
		// 				Properties: &armsql.SecurityEventProperties{
		// 					ApplicationName: to.Ptr("myApp"),
		// 					ClientIP: to.Ptr("10.166.113.220"),
		// 					Database: to.Ptr("database1"),
		// 					EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-24T10:11:14.121Z"); return t}()),
		// 					PrincipalName: to.Ptr("maliciousUser"),
		// 					SecurityEventSQLInjectionAdditionalProperties: &armsql.SecurityEventSQLInjectionAdditionalProperties{
		// 						ErrorCode: to.Ptr[int32](0),
		// 						ErrorMessage: to.Ptr(""),
		// 						ErrorSeverity: to.Ptr[int32](0),
		// 						Statement: to.Ptr("select * from sys.databases where database_id like '' or 1 = 1 --' and family = 'test10'"),
		// 						StatementHighlightLength: to.Ptr[int32](13),
		// 						StatementHighlightOffset: to.Ptr[int32](52),
		// 						ThreatID: to.Ptr("1"),
		// 					},
		// 					SecurityEventType: to.Ptr(armsql.SecurityEventTypeSQLInjectionExploit),
		// 					Server: to.Ptr("testcl"),
		// 					Subscription: to.Ptr("00000000-1111-2222-3333-444444444444"),
		// 				},
		// 			},
		// 			{
		// 				Name: to.Ptr("06364798761800000000000000003"),
		// 				Type: to.Ptr("Microsoft.Sql/servers/databases/securityEvents"),
		// 				ID: to.Ptr("/subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/testrg/providers/Microsoft.Sql/managedInstances/testcl/databases/database1/securityEvents/06364798761800000000000000003"),
		// 				Properties: &armsql.SecurityEventProperties{
		// 					ApplicationName: to.Ptr("myApp"),
		// 					ClientIP: to.Ptr("10.166.113.220"),
		// 					Database: to.Ptr("database1"),
		// 					EventTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2017-12-24T10:03:17.066Z"); return t}()),
		// 					PrincipalName: to.Ptr("maliciousUser"),
		// 					SecurityEventSQLInjectionAdditionalProperties: &armsql.SecurityEventSQLInjectionAdditionalProperties{
		// 						ErrorCode: to.Ptr[int32](0),
		// 						ErrorMessage: to.Ptr(""),
		// 						ErrorSeverity: to.Ptr[int32](0),
		// 						Statement: to.Ptr("select * from sys.databases where database_id like '' or 1 = 1 --' and family = 'test9'"),
		// 						StatementHighlightLength: to.Ptr[int32](13),
		// 						StatementHighlightOffset: to.Ptr[int32](52),
		// 						ThreatID: to.Ptr("1"),
		// 					},
		// 					SecurityEventType: to.Ptr(armsql.SecurityEventTypeSQLInjectionExploit),
		// 					Server: to.Ptr("testcl"),
		// 					Subscription: to.Ptr("00000000-1111-2222-3333-444444444444"),
		// 				},
		// 			},
		// 		},
		// 	},
		// }
	}
}
