diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/CHANGELOG.md b/sdk/resourcemanager/servicefabric/armservicefabric/CHANGELOG.md index d4d7da964b25..134f02595352 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/CHANGELOG.md +++ b/sdk/resourcemanager/servicefabric/armservicefabric/CHANGELOG.md @@ -1,5 +1,16 @@ # Release History +## 2.0.0 (2023-12-22) +### Breaking Changes + +- Operation `*ApplicationTypeVersionsClient.List` has supported pagination, use `*ApplicationTypeVersionsClient.NewListPager` instead. +- Operation `*ApplicationTypesClient.List` has supported pagination, use `*ApplicationTypesClient.NewListPager` instead. +- Operation `*ApplicationsClient.List` has supported pagination, use `*ApplicationsClient.NewListPager` instead. +- Operation `*ClustersClient.List` has supported pagination, use `*ClustersClient.NewListPager` instead. +- Operation `*ClustersClient.ListByResourceGroup` has supported pagination, use `*ClustersClient.NewListByResourceGroupPager` instead. +- Operation `*ServicesClient.List` has supported pagination, use `*ServicesClient.NewListPager` instead. + + ## 1.2.0 (2023-11-24) ### Features Added diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applications_client.go b/sdk/resourcemanager/servicefabric/armservicefabric/applications_client.go index 08aa35869c20..152977f45911 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applications_client.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applications_client.go @@ -279,33 +279,34 @@ func (client *ApplicationsClient) getHandleResponse(resp *http.Response) (Applic return result, nil } -// List - Gets all application resources created or in the process of being created in the Service Fabric cluster resource. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all application resources created or in the process of being created in the Service Fabric cluster +// resource. // // Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. // - clusterName - The name of the cluster resource. -// - options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. -func (client *ApplicationsClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *ApplicationsClientListOptions) (ApplicationsClientListResponse, error) { - var err error - const operationName = "ApplicationsClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) - if err != nil { - return ApplicationsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ApplicationsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ApplicationsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// - options - ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. +func (client *ApplicationsClient) NewListPager(resourceGroupName string, clusterName string, options *ApplicationsClientListOptions) *runtime.Pager[ApplicationsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ApplicationsClientListResponse]{ + More: func(page ApplicationsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApplicationsClientListResponse) (ApplicationsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplicationsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + }, nil) + if err != nil { + return ApplicationsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applications_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/applications_client_example_test.go index f29e5fa4bf5c..24ab081aac07 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applications_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applications_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationGetOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationGetOperation_example.json func ExampleApplicationsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -87,7 +87,7 @@ func ExampleApplicationsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_example_max.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_example_max.json func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithMaximumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -149,7 +149,7 @@ func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithMaximumPa } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_example_min.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_example_min.json func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithMinimumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -178,7 +178,7 @@ func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithMinimumPa } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_recreate_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPutOperation_recreate_example.json func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithRecreateOption() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -211,7 +211,7 @@ func ExampleApplicationsClient_BeginCreateOrUpdate_putAnApplicationWithRecreateO } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPatchOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationPatchOperation_example.json func ExampleApplicationsClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -246,7 +246,7 @@ func ExampleApplicationsClient_BeginUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationDeleteOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationDeleteOperation_example.json func ExampleApplicationsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -267,8 +267,8 @@ func ExampleApplicationsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationListOperation_example.json -func ExampleApplicationsClient_List() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationListOperation_example.json +func ExampleApplicationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -278,36 +278,41 @@ func ExampleApplicationsClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewApplicationsClient().List(ctx, "resRg", "myCluster", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewApplicationsClient().NewListPager("resRg", "myCluster", 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.ApplicationResourceList = armservicefabric.ApplicationResourceList{ + // Value: []*armservicefabric.ApplicationResource{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("applications"), + // Etag: to.Ptr("W/\"636462502180261858\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ApplicationResourceProperties{ + // Metrics: []*armservicefabric.ApplicationMetricDescription{ + // { + // Name: to.Ptr("metric1"), + // MaximumCapacity: to.Ptr[int64](3), + // ReservationCapacity: to.Ptr[int64](1), + // TotalApplicationCapacity: to.Ptr[int64](5), + // }}, + // RemoveApplicationCapacity: to.Ptr(false), + // TypeVersion: to.Ptr("1.0"), + // ProvisioningState: to.Ptr("Succeeded"), + // TypeName: to.Ptr("myAppType"), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ApplicationResourceList = armservicefabric.ApplicationResourceList{ - // Value: []*armservicefabric.ApplicationResource{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("applications"), - // Etag: to.Ptr("W/\"636462502180261858\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ApplicationResourceProperties{ - // Metrics: []*armservicefabric.ApplicationMetricDescription{ - // { - // Name: to.Ptr("metric1"), - // MaximumCapacity: to.Ptr[int64](3), - // ReservationCapacity: to.Ptr[int64](1), - // TotalApplicationCapacity: to.Ptr[int64](5), - // }}, - // RemoveApplicationCapacity: to.Ptr(false), - // TypeVersion: to.Ptr("1.0"), - // ProvisioningState: to.Ptr("Succeeded"), - // TypeName: to.Ptr("myAppType"), - // }, - // }}, - // } } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client.go b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client.go index bcbf2b35b9af..eba74bdf2099 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client.go @@ -268,34 +268,35 @@ func (client *ApplicationTypesClient) getHandleResponse(resp *http.Response) (Ap return result, nil } -// List - Gets all application type name resources created or in the process of being created in the Service Fabric cluster -// resource. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all application type name resources created or in the process of being created in the Service Fabric +// cluster resource. // // Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. // - clusterName - The name of the cluster resource. -// - options - ApplicationTypesClientListOptions contains the optional parameters for the ApplicationTypesClient.List method. -func (client *ApplicationTypesClient) List(ctx context.Context, resourceGroupName string, clusterName string, options *ApplicationTypesClientListOptions) (ApplicationTypesClientListResponse, error) { - var err error - const operationName = "ApplicationTypesClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, options) - if err != nil { - return ApplicationTypesClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ApplicationTypesClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ApplicationTypesClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// - options - ApplicationTypesClientListOptions contains the optional parameters for the ApplicationTypesClient.NewListPager +// method. +func (client *ApplicationTypesClient) NewListPager(resourceGroupName string, clusterName string, options *ApplicationTypesClientListOptions) *runtime.Pager[ApplicationTypesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ApplicationTypesClientListResponse]{ + More: func(page ApplicationTypesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApplicationTypesClientListResponse) (ApplicationTypesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplicationTypesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, clusterName, options) + }, nil) + if err != nil { + return ApplicationTypesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client_example_test.go index 2e9f72cd7574..410653246495 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypes_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameGetOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameGetOperation_example.json func ExampleApplicationTypesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -49,7 +49,7 @@ func ExampleApplicationTypesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNamePutOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNamePutOperation_example.json func ExampleApplicationTypesClient_CreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -83,7 +83,7 @@ func ExampleApplicationTypesClient_CreateOrUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameDeleteOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameDeleteOperation_example.json func ExampleApplicationTypesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -104,8 +104,8 @@ func ExampleApplicationTypesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameListOperation_example.json -func ExampleApplicationTypesClient_List() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeNameListOperation_example.json +func ExampleApplicationTypesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -115,26 +115,31 @@ func ExampleApplicationTypesClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewApplicationTypesClient().List(ctx, "resRg", "myCluster", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewApplicationTypesClient().NewListPager("resRg", "myCluster", 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.ApplicationTypeResourceList = armservicefabric.ApplicationTypeResourceList{ + // Value: []*armservicefabric.ApplicationTypeResource{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("applicationTypes"), + // Etag: to.Ptr("W/\"636462502174844831\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applicationTypes/myAppType"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ApplicationTypeResourceProperties{ + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ApplicationTypeResourceList = armservicefabric.ApplicationTypeResourceList{ - // Value: []*armservicefabric.ApplicationTypeResource{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("applicationTypes"), - // Etag: to.Ptr("W/\"636462502174844831\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applicationTypes/myAppType"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ApplicationTypeResourceProperties{ - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }}, - // } } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client.go b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client.go index ce4c1cd6d2a7..f5a5ce9a8833 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client.go @@ -295,36 +295,36 @@ func (client *ApplicationTypeVersionsClient) getHandleResponse(resp *http.Respon return result, nil } -// List - Gets all application type version resources created or in the process of being created in the Service Fabric application -// type name resource. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all application type version resources created or in the process of being created in the Service Fabric +// application type name resource. // // Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. // - clusterName - The name of the cluster resource. // - applicationTypeName - The name of the application type name resource. -// - options - ApplicationTypeVersionsClientListOptions contains the optional parameters for the ApplicationTypeVersionsClient.List +// - options - ApplicationTypeVersionsClientListOptions contains the optional parameters for the ApplicationTypeVersionsClient.NewListPager // method. -func (client *ApplicationTypeVersionsClient) List(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, options *ApplicationTypeVersionsClientListOptions) (ApplicationTypeVersionsClientListResponse, error) { - var err error - const operationName = "ApplicationTypeVersionsClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, applicationTypeName, options) - if err != nil { - return ApplicationTypeVersionsClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ApplicationTypeVersionsClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ApplicationTypeVersionsClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +func (client *ApplicationTypeVersionsClient) NewListPager(resourceGroupName string, clusterName string, applicationTypeName string, options *ApplicationTypeVersionsClientListOptions) *runtime.Pager[ApplicationTypeVersionsClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ApplicationTypeVersionsClientListResponse]{ + More: func(page ApplicationTypeVersionsClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ApplicationTypeVersionsClientListResponse) (ApplicationTypeVersionsClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ApplicationTypeVersionsClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, clusterName, applicationTypeName, options) + }, nil) + if err != nil { + return ApplicationTypeVersionsClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client_example_test.go index 2245793cff54..58a4fea3eb63 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/applicationtypeversions_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionGetOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionGetOperation_example.json func ExampleApplicationTypeVersionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -53,7 +53,7 @@ func ExampleApplicationTypeVersionsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionPutOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionPutOperation_example.json func ExampleApplicationTypeVersionsClient_BeginCreateOrUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -79,7 +79,7 @@ func ExampleApplicationTypeVersionsClient_BeginCreateOrUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionDeleteOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionDeleteOperation_example.json func ExampleApplicationTypeVersionsClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -100,8 +100,8 @@ func ExampleApplicationTypeVersionsClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionListOperation_example.json -func ExampleApplicationTypeVersionsClient_List() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ApplicationTypeVersionListOperation_example.json +func ExampleApplicationTypeVersionsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -111,29 +111,34 @@ func ExampleApplicationTypeVersionsClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewApplicationTypeVersionsClient().List(ctx, "resRg", "myCluster", "myAppType", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewApplicationTypeVersionsClient().NewListPager("resRg", "myCluster", "myAppType", 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.ApplicationTypeVersionResourceList = armservicefabric.ApplicationTypeVersionResourceList{ + // Value: []*armservicefabric.ApplicationTypeVersionResource{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("versions"), + // Etag: to.Ptr("W/\"636462502176040417\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applicationTypes/myAppType/versions/1.0"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ApplicationTypeVersionResourceProperties{ + // AppPackageURL: to.Ptr("http://fakelink.test.com/MyAppType"), + // DefaultParameterList: map[string]*string{ + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ApplicationTypeVersionResourceList = armservicefabric.ApplicationTypeVersionResourceList{ - // Value: []*armservicefabric.ApplicationTypeVersionResource{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("versions"), - // Etag: to.Ptr("W/\"636462502176040417\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applicationTypes/myAppType/versions/1.0"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ApplicationTypeVersionResourceProperties{ - // AppPackageURL: to.Ptr("http://fakelink.test.com/MyAppType"), - // DefaultParameterList: map[string]*string{ - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // }, - // }}, - // } } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/autorest.md b/sdk/resourcemanager/servicefabric/armservicefabric/autorest.md index d7c3e0ac0877..858882c72a03 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/autorest.md +++ b/sdk/resourcemanager/servicefabric/armservicefabric/autorest.md @@ -5,8 +5,9 @@ ``` yaml azure-arm: true require: -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/readme.md -- https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/readme.go.md +- https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/readme.md +- https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/readme.go.md license-header: MICROSOFT_MIT_NO_VERSION -module-version: 1.2.0 +module-version: 2.0.0 +tag: package-2021-06 ``` \ No newline at end of file diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client.go b/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client.go index 560329b3421e..59d5948fd9ab 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client.go @@ -241,31 +241,31 @@ func (client *ClustersClient) getHandleResponse(resp *http.Response) (ClustersCl return result, nil } -// List - Gets all Service Fabric cluster resources created or in the process of being created in the subscription. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all Service Fabric cluster resources created or in the process of being created in the subscription. // // Generated from API version 2021-06-01 -// - options - ClustersClientListOptions contains the optional parameters for the ClustersClient.List method. -func (client *ClustersClient) List(ctx context.Context, options *ClustersClientListOptions) (ClustersClientListResponse, error) { - var err error - const operationName = "ClustersClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, options) - if err != nil { - return ClustersClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ClustersClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ClustersClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// - options - ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. +func (client *ClustersClient) NewListPager(options *ClustersClientListOptions) *runtime.Pager[ClustersClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ClustersClientListResponse]{ + More: func(page ClustersClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClustersClientListResponse) (ClustersClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, options) + }, nil) + if err != nil { + return ClustersClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. @@ -295,34 +295,34 @@ func (client *ClustersClient) listHandleResponse(resp *http.Response) (ClustersC return result, nil } -// ListByResourceGroup - Gets all Service Fabric cluster resources created or in the process of being created in the resource -// group. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListByResourceGroupPager - Gets all Service Fabric cluster resources created or in the process of being created in the +// resource group. // // Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. -// - options - ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.ListByResourceGroup +// - options - ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager // method. -func (client *ClustersClient) ListByResourceGroup(ctx context.Context, resourceGroupName string, options *ClustersClientListByResourceGroupOptions) (ClustersClientListByResourceGroupResponse, error) { - var err error - const operationName = "ClustersClient.ListByResourceGroup" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) - if err != nil { - return ClustersClientListByResourceGroupResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ClustersClientListByResourceGroupResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ClustersClientListByResourceGroupResponse{}, err - } - resp, err := client.listByResourceGroupHandleResponse(httpResp) - return resp, err +func (client *ClustersClient) NewListByResourceGroupPager(resourceGroupName string, options *ClustersClientListByResourceGroupOptions) *runtime.Pager[ClustersClientListByResourceGroupResponse] { + return runtime.NewPager(runtime.PagingHandler[ClustersClientListByResourceGroupResponse]{ + More: func(page ClustersClientListByResourceGroupResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ClustersClientListByResourceGroupResponse) (ClustersClientListByResourceGroupResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ClustersClient.NewListByResourceGroupPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listByResourceGroupCreateRequest(ctx, resourceGroupName, options) + }, nil) + if err != nil { + return ClustersClientListByResourceGroupResponse{}, err + } + return client.listByResourceGroupHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listByResourceGroupCreateRequest creates the ListByResourceGroup request. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client_example_test.go index 3fa7ee2f25bb..03c630eda56b 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/clusters_client_example_test.go @@ -17,10 +17,10 @@ import ( "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/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterGetOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterGetOperation_example.json func ExampleClustersClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -178,7 +178,7 @@ func ExampleClustersClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPutOperation_example_max.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPutOperation_example_max.json func ExampleClustersClient_BeginCreateOrUpdate_putAClusterWithMaximumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -560,7 +560,7 @@ func ExampleClustersClient_BeginCreateOrUpdate_putAClusterWithMaximumParameters( // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPutOperation_example_min.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPutOperation_example_min.json func ExampleClustersClient_BeginCreateOrUpdate_putAClusterWithMinimumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -705,7 +705,7 @@ func ExampleClustersClient_BeginCreateOrUpdate_putAClusterWithMinimumParameters( // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPatchOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterPatchOperation_example.json func ExampleClustersClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -920,7 +920,7 @@ func ExampleClustersClient_BeginUpdate() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterDeleteOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterDeleteOperation_example.json func ExampleClustersClient_Delete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -937,8 +937,8 @@ func ExampleClustersClient_Delete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListByResourceGroupOperation_example.json -func ExampleClustersClient_ListByResourceGroup() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListByResourceGroupOperation_example.json +func ExampleClustersClient_NewListByResourceGroupPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -948,241 +948,246 @@ func ExampleClustersClient_ListByResourceGroup() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClustersClient().ListByResourceGroup(ctx, "resRg", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewClustersClient().NewListByResourceGroupPager("resRg", 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.ClusterListResult = armservicefabric.ClusterListResult{ + // Value: []*armservicefabric.Cluster{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), + // Etag: to.Ptr("W/\"636462502169240745\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ClusterProperties{ + // AddOnFeatures: []*armservicefabric.AddOnFeatures{ + // to.Ptr(armservicefabric.AddOnFeaturesRepairManager), + // to.Ptr(armservicefabric.AddOnFeaturesDNSService), + // to.Ptr(armservicefabric.AddOnFeaturesBackupRestoreService), + // to.Ptr(armservicefabric.AddOnFeaturesResourceMonitorService)}, + // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ + // { + // CodeVersion: to.Ptr("6.1.480.9494"), + // Environment: to.Ptr(armservicefabric.ClusterEnvironmentWindows), + // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), + // }}, + // AzureActiveDirectory: &armservicefabric.AzureActiveDirectory{ + // ClientApplication: to.Ptr("d151ad89-4bce-4ae8-b3d1-1dc79679fa75"), + // ClusterApplication: to.Ptr("5886372e-7bf4-4878-a497-8098aba608ae"), + // TenantID: to.Ptr("6abcc6a0-8666-43f1-87b8-172cf86a9f9c"), + // }, + // CertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ + // CommonNames: []*armservicefabric.ServerCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), + // }}, + // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), + // }, + // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), + // IsAdmin: to.Ptr(true), + // }}, + // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ + // { + // CertificateThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), + // IsAdmin: to.Ptr(false), + // }}, + // ClusterCodeVersion: to.Ptr("6.1.480.9494"), + // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), + // ClusterID: to.Ptr("92584666-9889-4ae8-8d02-91902923d37f"), + // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), + // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ + // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), + // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), + // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), + // StorageAccountName: to.Ptr("diag"), + // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), + // }, + // FabricSettings: []*armservicefabric.SettingsSectionDescription{ + // { + // Name: to.Ptr("UpgradeService"), + // Parameters: []*armservicefabric.SettingsParameterDescription{ + // { + // Name: to.Ptr("AppPollIntervalInSeconds"), + // Value: to.Ptr("60"), + // }}, + // }}, + // ManagementEndpoint: to.Ptr("https://myCluster.eastus.cloudapp.azure.com:19080"), + // NodeTypes: []*armservicefabric.NodeTypeDescription{ + // { + // Name: to.Ptr("nt1vm"), + // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](30000), + // StartPort: to.Ptr[int32](20000), + // }, + // ClientConnectionEndpointPort: to.Ptr[int32](19000), + // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), + // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](64000), + // StartPort: to.Ptr[int32](49000), + // }, + // HTTPGatewayEndpointPort: to.Ptr[int32](19007), + // IsPrimary: to.Ptr(true), + // VMInstanceCount: to.Ptr[int32](5), + // }}, + // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), + // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), + // ReverseProxyCertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ + // CommonNames: []*armservicefabric.ServerCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), + // }}, + // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), + // }, + // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ + // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ + // ApplicationDeltaHealthPolicies: map[string]*armservicefabric.ApplicationDeltaHealthPolicy{ + // "fabric:/myApp1": &armservicefabric.ApplicationDeltaHealthPolicy{ + // DefaultServiceTypeDeltaHealthPolicy: &armservicefabric.ServiceTypeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), + // }, + // ServiceTypeDeltaHealthPolicies: map[string]*armservicefabric.ServiceTypeDeltaHealthPolicy{ + // "myServiceType1": &armservicefabric.ServiceTypeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), + // }, + // }, + // }, + // }, + // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), + // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), + // }, + // ForceRestart: to.Ptr(false), + // HealthCheckRetryTimeout: to.Ptr("00:05:00"), + // HealthCheckStableDuration: to.Ptr("00:00:30"), + // HealthCheckWaitDuration: to.Ptr("00:00:30"), + // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ + // ApplicationHealthPolicies: map[string]*armservicefabric.ApplicationHealthPolicy{ + // "fabric:/myApp1": &armservicefabric.ApplicationHealthPolicy{ + // DefaultServiceTypeHealthPolicy: &armservicefabric.ServiceTypeHealthPolicy{ + // MaxPercentUnhealthyServices: to.Ptr[int32](0), + // }, + // ServiceTypeHealthPolicies: map[string]*armservicefabric.ServiceTypeHealthPolicy{ + // "myServiceType1": &armservicefabric.ServiceTypeHealthPolicy{ + // MaxPercentUnhealthyServices: to.Ptr[int32](100), + // }, + // }, + // }, + // }, + // MaxPercentUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentUnhealthyNodes: to.Ptr[int32](0), + // }, + // UpgradeDomainTimeout: to.Ptr("00:15:00"), + // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), + // UpgradeTimeout: to.Ptr("01:00:00"), + // }, + // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), + // VMImage: to.Ptr("Windows"), + // }, + // }, + // { + // Name: to.Ptr("myCluster2"), + // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), + // Etag: to.Ptr("W/\"636462502164040075\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ClusterProperties{ + // AddOnFeatures: []*armservicefabric.AddOnFeatures{ + // to.Ptr(armservicefabric.AddOnFeaturesRepairManager)}, + // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ + // { + // CodeVersion: to.Ptr("6.1.187.1"), + // Environment: to.Ptr(armservicefabric.ClusterEnvironmentLinux), + // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), + // }}, + // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ + // }, + // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ + // }, + // ClusterCodeVersion: to.Ptr("6.1.187.1"), + // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), + // ClusterID: to.Ptr("2747e469-b24e-4039-8a0a-46151419523f"), + // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), + // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ + // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), + // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), + // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), + // StorageAccountName: to.Ptr("diag"), + // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), + // }, + // FabricSettings: []*armservicefabric.SettingsSectionDescription{ + // { + // Name: to.Ptr("UpgradeService"), + // Parameters: []*armservicefabric.SettingsParameterDescription{ + // { + // Name: to.Ptr("AppPollIntervalInSeconds"), + // Value: to.Ptr("60"), + // }}, + // }}, + // ManagementEndpoint: to.Ptr("http://myCluster2.eastus.cloudapp.azure.com:19080"), + // NodeTypes: []*armservicefabric.NodeTypeDescription{ + // { + // Name: to.Ptr("nt1vm"), + // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](30000), + // StartPort: to.Ptr[int32](20000), + // }, + // ClientConnectionEndpointPort: to.Ptr[int32](19000), + // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), + // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](64000), + // StartPort: to.Ptr[int32](49000), + // }, + // HTTPGatewayEndpointPort: to.Ptr[int32](19007), + // IsPrimary: to.Ptr(true), + // VMInstanceCount: to.Ptr[int32](5), + // }}, + // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), + // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), + // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ + // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), + // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), + // }, + // ForceRestart: to.Ptr(false), + // HealthCheckRetryTimeout: to.Ptr("00:05:00"), + // HealthCheckStableDuration: to.Ptr("00:00:30"), + // HealthCheckWaitDuration: to.Ptr("00:00:30"), + // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ + // MaxPercentUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentUnhealthyNodes: to.Ptr[int32](0), + // }, + // UpgradeDomainTimeout: to.Ptr("00:15:00"), + // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), + // UpgradeTimeout: to.Ptr("01:00:00"), + // }, + // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), + // VMImage: to.Ptr("Ubuntu"), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ClusterListResult = armservicefabric.ClusterListResult{ - // Value: []*armservicefabric.Cluster{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), - // Etag: to.Ptr("W/\"636462502169240745\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ClusterProperties{ - // AddOnFeatures: []*armservicefabric.AddOnFeatures{ - // to.Ptr(armservicefabric.AddOnFeaturesRepairManager), - // to.Ptr(armservicefabric.AddOnFeaturesDNSService), - // to.Ptr(armservicefabric.AddOnFeaturesBackupRestoreService), - // to.Ptr(armservicefabric.AddOnFeaturesResourceMonitorService)}, - // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ - // { - // CodeVersion: to.Ptr("6.1.480.9494"), - // Environment: to.Ptr(armservicefabric.ClusterEnvironmentWindows), - // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), - // }}, - // AzureActiveDirectory: &armservicefabric.AzureActiveDirectory{ - // ClientApplication: to.Ptr("d151ad89-4bce-4ae8-b3d1-1dc79679fa75"), - // ClusterApplication: to.Ptr("5886372e-7bf4-4878-a497-8098aba608ae"), - // TenantID: to.Ptr("6abcc6a0-8666-43f1-87b8-172cf86a9f9c"), - // }, - // CertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ - // CommonNames: []*armservicefabric.ServerCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), - // }}, - // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), - // }, - // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), - // IsAdmin: to.Ptr(true), - // }}, - // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ - // { - // CertificateThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), - // IsAdmin: to.Ptr(false), - // }}, - // ClusterCodeVersion: to.Ptr("6.1.480.9494"), - // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), - // ClusterID: to.Ptr("92584666-9889-4ae8-8d02-91902923d37f"), - // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), - // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ - // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), - // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), - // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), - // StorageAccountName: to.Ptr("diag"), - // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), - // }, - // FabricSettings: []*armservicefabric.SettingsSectionDescription{ - // { - // Name: to.Ptr("UpgradeService"), - // Parameters: []*armservicefabric.SettingsParameterDescription{ - // { - // Name: to.Ptr("AppPollIntervalInSeconds"), - // Value: to.Ptr("60"), - // }}, - // }}, - // ManagementEndpoint: to.Ptr("https://myCluster.eastus.cloudapp.azure.com:19080"), - // NodeTypes: []*armservicefabric.NodeTypeDescription{ - // { - // Name: to.Ptr("nt1vm"), - // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](30000), - // StartPort: to.Ptr[int32](20000), - // }, - // ClientConnectionEndpointPort: to.Ptr[int32](19000), - // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), - // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](64000), - // StartPort: to.Ptr[int32](49000), - // }, - // HTTPGatewayEndpointPort: to.Ptr[int32](19007), - // IsPrimary: to.Ptr(true), - // VMInstanceCount: to.Ptr[int32](5), - // }}, - // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), - // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), - // ReverseProxyCertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ - // CommonNames: []*armservicefabric.ServerCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), - // }}, - // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), - // }, - // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ - // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ - // ApplicationDeltaHealthPolicies: map[string]*armservicefabric.ApplicationDeltaHealthPolicy{ - // "fabric:/myApp1": &armservicefabric.ApplicationDeltaHealthPolicy{ - // DefaultServiceTypeDeltaHealthPolicy: &armservicefabric.ServiceTypeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), - // }, - // ServiceTypeDeltaHealthPolicies: map[string]*armservicefabric.ServiceTypeDeltaHealthPolicy{ - // "myServiceType1": &armservicefabric.ServiceTypeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), - // }, - // }, - // }, - // }, - // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), - // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), - // }, - // ForceRestart: to.Ptr(false), - // HealthCheckRetryTimeout: to.Ptr("00:05:00"), - // HealthCheckStableDuration: to.Ptr("00:00:30"), - // HealthCheckWaitDuration: to.Ptr("00:00:30"), - // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ - // ApplicationHealthPolicies: map[string]*armservicefabric.ApplicationHealthPolicy{ - // "fabric:/myApp1": &armservicefabric.ApplicationHealthPolicy{ - // DefaultServiceTypeHealthPolicy: &armservicefabric.ServiceTypeHealthPolicy{ - // MaxPercentUnhealthyServices: to.Ptr[int32](0), - // }, - // ServiceTypeHealthPolicies: map[string]*armservicefabric.ServiceTypeHealthPolicy{ - // "myServiceType1": &armservicefabric.ServiceTypeHealthPolicy{ - // MaxPercentUnhealthyServices: to.Ptr[int32](100), - // }, - // }, - // }, - // }, - // MaxPercentUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentUnhealthyNodes: to.Ptr[int32](0), - // }, - // UpgradeDomainTimeout: to.Ptr("00:15:00"), - // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), - // UpgradeTimeout: to.Ptr("01:00:00"), - // }, - // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), - // VMImage: to.Ptr("Windows"), - // }, - // }, - // { - // Name: to.Ptr("myCluster2"), - // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), - // Etag: to.Ptr("W/\"636462502164040075\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster2"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ClusterProperties{ - // AddOnFeatures: []*armservicefabric.AddOnFeatures{ - // to.Ptr(armservicefabric.AddOnFeaturesRepairManager)}, - // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ - // { - // CodeVersion: to.Ptr("6.1.187.1"), - // Environment: to.Ptr(armservicefabric.ClusterEnvironmentLinux), - // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), - // }}, - // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ - // }, - // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ - // }, - // ClusterCodeVersion: to.Ptr("6.1.187.1"), - // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), - // ClusterID: to.Ptr("2747e469-b24e-4039-8a0a-46151419523f"), - // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), - // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ - // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), - // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), - // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), - // StorageAccountName: to.Ptr("diag"), - // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), - // }, - // FabricSettings: []*armservicefabric.SettingsSectionDescription{ - // { - // Name: to.Ptr("UpgradeService"), - // Parameters: []*armservicefabric.SettingsParameterDescription{ - // { - // Name: to.Ptr("AppPollIntervalInSeconds"), - // Value: to.Ptr("60"), - // }}, - // }}, - // ManagementEndpoint: to.Ptr("http://myCluster2.eastus.cloudapp.azure.com:19080"), - // NodeTypes: []*armservicefabric.NodeTypeDescription{ - // { - // Name: to.Ptr("nt1vm"), - // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](30000), - // StartPort: to.Ptr[int32](20000), - // }, - // ClientConnectionEndpointPort: to.Ptr[int32](19000), - // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), - // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](64000), - // StartPort: to.Ptr[int32](49000), - // }, - // HTTPGatewayEndpointPort: to.Ptr[int32](19007), - // IsPrimary: to.Ptr(true), - // VMInstanceCount: to.Ptr[int32](5), - // }}, - // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), - // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), - // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ - // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), - // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), - // }, - // ForceRestart: to.Ptr(false), - // HealthCheckRetryTimeout: to.Ptr("00:05:00"), - // HealthCheckStableDuration: to.Ptr("00:00:30"), - // HealthCheckWaitDuration: to.Ptr("00:00:30"), - // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ - // MaxPercentUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentUnhealthyNodes: to.Ptr[int32](0), - // }, - // UpgradeDomainTimeout: to.Ptr("00:15:00"), - // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), - // UpgradeTimeout: to.Ptr("01:00:00"), - // }, - // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), - // VMImage: to.Ptr("Ubuntu"), - // }, - // }}, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListOperation_example.json -func ExampleClustersClient_List() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterListOperation_example.json +func ExampleClustersClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -1192,240 +1197,245 @@ func ExampleClustersClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewClustersClient().List(ctx, nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewClustersClient().NewListPager(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.ClusterListResult = armservicefabric.ClusterListResult{ + // Value: []*armservicefabric.Cluster{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), + // Etag: to.Ptr("W/\"636462502169240745\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ClusterProperties{ + // AddOnFeatures: []*armservicefabric.AddOnFeatures{ + // to.Ptr(armservicefabric.AddOnFeaturesRepairManager), + // to.Ptr(armservicefabric.AddOnFeaturesDNSService), + // to.Ptr(armservicefabric.AddOnFeaturesBackupRestoreService), + // to.Ptr(armservicefabric.AddOnFeaturesResourceMonitorService)}, + // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ + // { + // CodeVersion: to.Ptr("6.1.480.9494"), + // Environment: to.Ptr(armservicefabric.ClusterEnvironmentWindows), + // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), + // }}, + // AzureActiveDirectory: &armservicefabric.AzureActiveDirectory{ + // ClientApplication: to.Ptr("d151ad89-4bce-4ae8-b3d1-1dc79679fa75"), + // ClusterApplication: to.Ptr("5886372e-7bf4-4878-a497-8098aba608ae"), + // TenantID: to.Ptr("6abcc6a0-8666-43f1-87b8-172cf86a9f9c"), + // }, + // CertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ + // CommonNames: []*armservicefabric.ServerCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), + // }}, + // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), + // }, + // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), + // IsAdmin: to.Ptr(true), + // }}, + // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ + // { + // CertificateThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), + // IsAdmin: to.Ptr(false), + // }}, + // ClusterCodeVersion: to.Ptr("6.1.480.9494"), + // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), + // ClusterID: to.Ptr("92584666-9889-4ae8-8d02-91902923d37f"), + // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), + // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ + // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), + // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), + // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), + // StorageAccountName: to.Ptr("diag"), + // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), + // }, + // FabricSettings: []*armservicefabric.SettingsSectionDescription{ + // { + // Name: to.Ptr("UpgradeService"), + // Parameters: []*armservicefabric.SettingsParameterDescription{ + // { + // Name: to.Ptr("AppPollIntervalInSeconds"), + // Value: to.Ptr("60"), + // }}, + // }}, + // ManagementEndpoint: to.Ptr("https://myCluster.eastus.cloudapp.azure.com:19080"), + // NodeTypes: []*armservicefabric.NodeTypeDescription{ + // { + // Name: to.Ptr("nt1vm"), + // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](30000), + // StartPort: to.Ptr[int32](20000), + // }, + // ClientConnectionEndpointPort: to.Ptr[int32](19000), + // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), + // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](64000), + // StartPort: to.Ptr[int32](49000), + // }, + // HTTPGatewayEndpointPort: to.Ptr[int32](19007), + // IsPrimary: to.Ptr(true), + // VMInstanceCount: to.Ptr[int32](5), + // }}, + // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), + // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), + // ReverseProxyCertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ + // CommonNames: []*armservicefabric.ServerCertificateCommonName{ + // { + // CertificateCommonName: to.Ptr("abc.com"), + // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), + // }}, + // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), + // }, + // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ + // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ + // ApplicationDeltaHealthPolicies: map[string]*armservicefabric.ApplicationDeltaHealthPolicy{ + // "fabric:/myApp1": &armservicefabric.ApplicationDeltaHealthPolicy{ + // DefaultServiceTypeDeltaHealthPolicy: &armservicefabric.ServiceTypeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), + // }, + // ServiceTypeDeltaHealthPolicies: map[string]*armservicefabric.ServiceTypeDeltaHealthPolicy{ + // "myServiceType1": &armservicefabric.ServiceTypeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), + // }, + // }, + // }, + // }, + // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), + // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), + // }, + // ForceRestart: to.Ptr(false), + // HealthCheckRetryTimeout: to.Ptr("00:05:00"), + // HealthCheckStableDuration: to.Ptr("00:00:30"), + // HealthCheckWaitDuration: to.Ptr("00:00:30"), + // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ + // ApplicationHealthPolicies: map[string]*armservicefabric.ApplicationHealthPolicy{ + // "fabric:/myApp1": &armservicefabric.ApplicationHealthPolicy{ + // DefaultServiceTypeHealthPolicy: &armservicefabric.ServiceTypeHealthPolicy{ + // MaxPercentUnhealthyServices: to.Ptr[int32](0), + // }, + // ServiceTypeHealthPolicies: map[string]*armservicefabric.ServiceTypeHealthPolicy{ + // "myServiceType1": &armservicefabric.ServiceTypeHealthPolicy{ + // MaxPercentUnhealthyServices: to.Ptr[int32](100), + // }, + // }, + // }, + // }, + // MaxPercentUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentUnhealthyNodes: to.Ptr[int32](0), + // }, + // UpgradeDomainTimeout: to.Ptr("00:15:00"), + // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), + // UpgradeTimeout: to.Ptr("01:00:00"), + // }, + // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), + // VMImage: to.Ptr("Windows"), + // }, + // }, + // { + // Name: to.Ptr("myCluster2"), + // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), + // Etag: to.Ptr("W/\"636462502164040075\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster2"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.ClusterProperties{ + // AddOnFeatures: []*armservicefabric.AddOnFeatures{ + // to.Ptr(armservicefabric.AddOnFeaturesRepairManager)}, + // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ + // { + // CodeVersion: to.Ptr("6.1.187.1"), + // Environment: to.Ptr(armservicefabric.ClusterEnvironmentLinux), + // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), + // }}, + // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ + // }, + // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ + // }, + // ClusterCodeVersion: to.Ptr("6.1.187.1"), + // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), + // ClusterID: to.Ptr("2747e469-b24e-4039-8a0a-46151419523f"), + // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), + // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ + // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), + // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), + // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), + // StorageAccountName: to.Ptr("diag"), + // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), + // }, + // FabricSettings: []*armservicefabric.SettingsSectionDescription{ + // { + // Name: to.Ptr("UpgradeService"), + // Parameters: []*armservicefabric.SettingsParameterDescription{ + // { + // Name: to.Ptr("AppPollIntervalInSeconds"), + // Value: to.Ptr("60"), + // }}, + // }}, + // ManagementEndpoint: to.Ptr("http://myCluster2.eastus.cloudapp.azure.com:19080"), + // NodeTypes: []*armservicefabric.NodeTypeDescription{ + // { + // Name: to.Ptr("nt1vm"), + // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](30000), + // StartPort: to.Ptr[int32](20000), + // }, + // ClientConnectionEndpointPort: to.Ptr[int32](19000), + // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), + // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ + // EndPort: to.Ptr[int32](64000), + // StartPort: to.Ptr[int32](49000), + // }, + // HTTPGatewayEndpointPort: to.Ptr[int32](19007), + // IsPrimary: to.Ptr(true), + // VMInstanceCount: to.Ptr[int32](5), + // }}, + // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), + // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), + // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ + // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ + // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), + // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), + // }, + // ForceRestart: to.Ptr(false), + // HealthCheckRetryTimeout: to.Ptr("00:05:00"), + // HealthCheckStableDuration: to.Ptr("00:00:30"), + // HealthCheckWaitDuration: to.Ptr("00:00:30"), + // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ + // MaxPercentUnhealthyApplications: to.Ptr[int32](0), + // MaxPercentUnhealthyNodes: to.Ptr[int32](0), + // }, + // UpgradeDomainTimeout: to.Ptr("00:15:00"), + // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), + // UpgradeTimeout: to.Ptr("01:00:00"), + // }, + // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), + // VMImage: to.Ptr("Ubuntu"), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ClusterListResult = armservicefabric.ClusterListResult{ - // Value: []*armservicefabric.Cluster{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), - // Etag: to.Ptr("W/\"636462502169240745\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ClusterProperties{ - // AddOnFeatures: []*armservicefabric.AddOnFeatures{ - // to.Ptr(armservicefabric.AddOnFeaturesRepairManager), - // to.Ptr(armservicefabric.AddOnFeaturesDNSService), - // to.Ptr(armservicefabric.AddOnFeaturesBackupRestoreService), - // to.Ptr(armservicefabric.AddOnFeaturesResourceMonitorService)}, - // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ - // { - // CodeVersion: to.Ptr("6.1.480.9494"), - // Environment: to.Ptr(armservicefabric.ClusterEnvironmentWindows), - // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), - // }}, - // AzureActiveDirectory: &armservicefabric.AzureActiveDirectory{ - // ClientApplication: to.Ptr("d151ad89-4bce-4ae8-b3d1-1dc79679fa75"), - // ClusterApplication: to.Ptr("5886372e-7bf4-4878-a497-8098aba608ae"), - // TenantID: to.Ptr("6abcc6a0-8666-43f1-87b8-172cf86a9f9c"), - // }, - // CertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ - // CommonNames: []*armservicefabric.ServerCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), - // }}, - // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), - // }, - // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), - // IsAdmin: to.Ptr(true), - // }}, - // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ - // { - // CertificateThumbprint: to.Ptr("5F3660C715EBBDA31DB1FFDCF508302348DE8E7A"), - // IsAdmin: to.Ptr(false), - // }}, - // ClusterCodeVersion: to.Ptr("6.1.480.9494"), - // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), - // ClusterID: to.Ptr("92584666-9889-4ae8-8d02-91902923d37f"), - // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), - // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ - // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), - // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), - // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), - // StorageAccountName: to.Ptr("diag"), - // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), - // }, - // FabricSettings: []*armservicefabric.SettingsSectionDescription{ - // { - // Name: to.Ptr("UpgradeService"), - // Parameters: []*armservicefabric.SettingsParameterDescription{ - // { - // Name: to.Ptr("AppPollIntervalInSeconds"), - // Value: to.Ptr("60"), - // }}, - // }}, - // ManagementEndpoint: to.Ptr("https://myCluster.eastus.cloudapp.azure.com:19080"), - // NodeTypes: []*armservicefabric.NodeTypeDescription{ - // { - // Name: to.Ptr("nt1vm"), - // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](30000), - // StartPort: to.Ptr[int32](20000), - // }, - // ClientConnectionEndpointPort: to.Ptr[int32](19000), - // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), - // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](64000), - // StartPort: to.Ptr[int32](49000), - // }, - // HTTPGatewayEndpointPort: to.Ptr[int32](19007), - // IsPrimary: to.Ptr(true), - // VMInstanceCount: to.Ptr[int32](5), - // }}, - // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), - // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), - // ReverseProxyCertificateCommonNames: &armservicefabric.ServerCertificateCommonNames{ - // CommonNames: []*armservicefabric.ServerCertificateCommonName{ - // { - // CertificateCommonName: to.Ptr("abc.com"), - // CertificateIssuerThumbprint: to.Ptr("12599211F8F14C90AFA9532AD79A6F2CA1C00622"), - // }}, - // X509StoreName: to.Ptr(armservicefabric.StoreNameMy), - // }, - // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ - // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ - // ApplicationDeltaHealthPolicies: map[string]*armservicefabric.ApplicationDeltaHealthPolicy{ - // "fabric:/myApp1": &armservicefabric.ApplicationDeltaHealthPolicy{ - // DefaultServiceTypeDeltaHealthPolicy: &armservicefabric.ServiceTypeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), - // }, - // ServiceTypeDeltaHealthPolicies: map[string]*armservicefabric.ServiceTypeDeltaHealthPolicy{ - // "myServiceType1": &armservicefabric.ServiceTypeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyServices: to.Ptr[int32](0), - // }, - // }, - // }, - // }, - // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), - // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), - // }, - // ForceRestart: to.Ptr(false), - // HealthCheckRetryTimeout: to.Ptr("00:05:00"), - // HealthCheckStableDuration: to.Ptr("00:00:30"), - // HealthCheckWaitDuration: to.Ptr("00:00:30"), - // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ - // ApplicationHealthPolicies: map[string]*armservicefabric.ApplicationHealthPolicy{ - // "fabric:/myApp1": &armservicefabric.ApplicationHealthPolicy{ - // DefaultServiceTypeHealthPolicy: &armservicefabric.ServiceTypeHealthPolicy{ - // MaxPercentUnhealthyServices: to.Ptr[int32](0), - // }, - // ServiceTypeHealthPolicies: map[string]*armservicefabric.ServiceTypeHealthPolicy{ - // "myServiceType1": &armservicefabric.ServiceTypeHealthPolicy{ - // MaxPercentUnhealthyServices: to.Ptr[int32](100), - // }, - // }, - // }, - // }, - // MaxPercentUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentUnhealthyNodes: to.Ptr[int32](0), - // }, - // UpgradeDomainTimeout: to.Ptr("00:15:00"), - // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), - // UpgradeTimeout: to.Ptr("01:00:00"), - // }, - // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), - // VMImage: to.Ptr("Windows"), - // }, - // }, - // { - // Name: to.Ptr("myCluster2"), - // Type: to.Ptr("Microsoft.ServiceFabric/clusters"), - // Etag: to.Ptr("W/\"636462502164040075\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster2"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.ClusterProperties{ - // AddOnFeatures: []*armservicefabric.AddOnFeatures{ - // to.Ptr(armservicefabric.AddOnFeaturesRepairManager)}, - // AvailableClusterVersions: []*armservicefabric.ClusterVersionDetails{ - // { - // CodeVersion: to.Ptr("6.1.187.1"), - // Environment: to.Ptr(armservicefabric.ClusterEnvironmentLinux), - // SupportExpiryUTC: to.Ptr("2018-06-15T23:59:59.9999999"), - // }}, - // ClientCertificateCommonNames: []*armservicefabric.ClientCertificateCommonName{ - // }, - // ClientCertificateThumbprints: []*armservicefabric.ClientCertificateThumbprint{ - // }, - // ClusterCodeVersion: to.Ptr("6.1.187.1"), - // ClusterEndpoint: to.Ptr("https://eastus.servicefabric.azure.com"), - // ClusterID: to.Ptr("2747e469-b24e-4039-8a0a-46151419523f"), - // ClusterState: to.Ptr(armservicefabric.ClusterStateWaitingForNodes), - // DiagnosticsStorageAccountConfig: &armservicefabric.DiagnosticsStorageAccountConfig{ - // BlobEndpoint: to.Ptr("https://diag.blob.core.windows.net/"), - // ProtectedAccountKeyName: to.Ptr("StorageAccountKey1"), - // QueueEndpoint: to.Ptr("https://diag.queue.core.windows.net/"), - // StorageAccountName: to.Ptr("diag"), - // TableEndpoint: to.Ptr("https://diag.table.core.windows.net/"), - // }, - // FabricSettings: []*armservicefabric.SettingsSectionDescription{ - // { - // Name: to.Ptr("UpgradeService"), - // Parameters: []*armservicefabric.SettingsParameterDescription{ - // { - // Name: to.Ptr("AppPollIntervalInSeconds"), - // Value: to.Ptr("60"), - // }}, - // }}, - // ManagementEndpoint: to.Ptr("http://myCluster2.eastus.cloudapp.azure.com:19080"), - // NodeTypes: []*armservicefabric.NodeTypeDescription{ - // { - // Name: to.Ptr("nt1vm"), - // ApplicationPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](30000), - // StartPort: to.Ptr[int32](20000), - // }, - // ClientConnectionEndpointPort: to.Ptr[int32](19000), - // DurabilityLevel: to.Ptr(armservicefabric.DurabilityLevelBronze), - // EphemeralPorts: &armservicefabric.EndpointRangeDescription{ - // EndPort: to.Ptr[int32](64000), - // StartPort: to.Ptr[int32](49000), - // }, - // HTTPGatewayEndpointPort: to.Ptr[int32](19007), - // IsPrimary: to.Ptr(true), - // VMInstanceCount: to.Ptr[int32](5), - // }}, - // ProvisioningState: to.Ptr(armservicefabric.ProvisioningStateSucceeded), - // ReliabilityLevel: to.Ptr(armservicefabric.ReliabilityLevelSilver), - // UpgradeDescription: &armservicefabric.ClusterUpgradePolicy{ - // DeltaHealthPolicy: &armservicefabric.ClusterUpgradeDeltaHealthPolicy{ - // MaxPercentDeltaUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentDeltaUnhealthyNodes: to.Ptr[int32](0), - // MaxPercentUpgradeDomainDeltaUnhealthyNodes: to.Ptr[int32](0), - // }, - // ForceRestart: to.Ptr(false), - // HealthCheckRetryTimeout: to.Ptr("00:05:00"), - // HealthCheckStableDuration: to.Ptr("00:00:30"), - // HealthCheckWaitDuration: to.Ptr("00:00:30"), - // HealthPolicy: &armservicefabric.ClusterHealthPolicy{ - // MaxPercentUnhealthyApplications: to.Ptr[int32](0), - // MaxPercentUnhealthyNodes: to.Ptr[int32](0), - // }, - // UpgradeDomainTimeout: to.Ptr("00:15:00"), - // UpgradeReplicaSetCheckTimeout: to.Ptr("00:10:00"), - // UpgradeTimeout: to.Ptr("01:00:00"), - // }, - // UpgradeMode: to.Ptr(armservicefabric.UpgradeModeManual), - // VMImage: to.Ptr("Ubuntu"), - // }, - // }}, - // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListUpgradableVersionsMinMax_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListUpgradableVersionsMinMax_example.json func ExampleClustersClient_ListUpgradableVersions_getMinimumAndMaximumCodeVersions() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -1450,7 +1460,7 @@ func ExampleClustersClient_ListUpgradableVersions_getMinimumAndMaximumCodeVersio // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListUpgradableVersionsPath_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListUpgradableVersionsPath_example.json func ExampleClustersClient_ListUpgradableVersions_getUpgradePath() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/clusterversions_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/clusterversions_client_example_test.go index f89ed44d34f1..7493febb6480 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/clusterversions_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/clusterversions_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsGet_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsGet_example.json func ExampleClusterVersionsClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -50,7 +50,7 @@ func ExampleClusterVersionsClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsGetByEnvironment_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsGetByEnvironment_example.json func ExampleClusterVersionsClient_GetByEnvironment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -83,7 +83,7 @@ func ExampleClusterVersionsClient_GetByEnvironment() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsList_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsList_example.json func ExampleClusterVersionsClient_List() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -126,7 +126,7 @@ func ExampleClusterVersionsClient_List() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsListByEnvironment.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ClusterVersionsListByEnvironment.json func ExampleClusterVersionsClient_ListByEnvironment() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/constants.go b/sdk/resourcemanager/servicefabric/armservicefabric/constants.go index c192ec5d09c6..7381d330329d 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/constants.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/constants.go @@ -10,7 +10,7 @@ package armservicefabric const ( moduleName = "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" - moduleVersion = "v1.2.0" + moduleVersion = "v2.0.0" ) // AddOnFeatures - Available cluster add-on features diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applications_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applications_server.go index 1da1cadbda97..ad4efb4a5c16 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applications_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applications_server.go @@ -15,7 +15,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "regexp" @@ -35,9 +36,9 @@ type ApplicationsServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, options *armservicefabric.ApplicationsClientGetOptions) (resp azfake.Responder[armservicefabric.ApplicationsClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method ApplicationsClient.List + // NewListPager is the fake for method ApplicationsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, resourceGroupName string, clusterName string, options *armservicefabric.ApplicationsClientListOptions) (resp azfake.Responder[armservicefabric.ApplicationsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(resourceGroupName string, clusterName string, options *armservicefabric.ApplicationsClientListOptions) (resp azfake.PagerResponder[armservicefabric.ApplicationsClientListResponse]) // BeginUpdate is the fake for method ApplicationsClient.BeginUpdate // HTTP status codes to indicate success: http.StatusAccepted @@ -52,6 +53,7 @@ func NewApplicationsServerTransport(srv *ApplicationsServer) *ApplicationsServer srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicefabric.ApplicationsClientCreateOrUpdateResponse]](), beginDelete: newTracker[azfake.PollerResponder[armservicefabric.ApplicationsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armservicefabric.ApplicationsClientListResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armservicefabric.ApplicationsClientUpdateResponse]](), } } @@ -62,6 +64,7 @@ type ApplicationsServerTransport struct { srv *ApplicationsServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicefabric.ApplicationsClientCreateOrUpdateResponse]] beginDelete *tracker[azfake.PollerResponder[armservicefabric.ApplicationsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armservicefabric.ApplicationsClientListResponse]] beginUpdate *tracker[azfake.PollerResponder[armservicefabric.ApplicationsClientUpdateResponse]] } @@ -83,8 +86,8 @@ func (a *ApplicationsServerTransport) Do(req *http.Request) (*http.Response, err resp, err = a.dispatchBeginDelete(req) case "ApplicationsClient.Get": resp, err = a.dispatchGet(req) - case "ApplicationsClient.List": - resp, err = a.dispatchList(req) + case "ApplicationsClient.NewListPager": + resp, err = a.dispatchNewListPager(req) case "ApplicationsClient.BeginUpdate": resp, err = a.dispatchBeginUpdate(req) default: @@ -235,35 +238,43 @@ func (a *ApplicationsServerTransport) dispatchGet(req *http.Request) (*http.Resp return resp, nil } -func (a *ApplicationsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if a.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} +func (a *ApplicationsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armservicefabric.ApplicationsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := a.srv.List(req.Context(), resourceGroupNameParam, clusterNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationResourceList, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypes_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypes_server.go index 48836f7ede26..921e3bed8f61 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypes_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypes_server.go @@ -15,7 +15,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "regexp" @@ -35,9 +36,9 @@ type ApplicationTypesServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, options *armservicefabric.ApplicationTypesClientGetOptions) (resp azfake.Responder[armservicefabric.ApplicationTypesClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method ApplicationTypesClient.List + // NewListPager is the fake for method ApplicationTypesClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, resourceGroupName string, clusterName string, options *armservicefabric.ApplicationTypesClientListOptions) (resp azfake.Responder[armservicefabric.ApplicationTypesClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(resourceGroupName string, clusterName string, options *armservicefabric.ApplicationTypesClientListOptions) (resp azfake.PagerResponder[armservicefabric.ApplicationTypesClientListResponse]) } // NewApplicationTypesServerTransport creates a new instance of ApplicationTypesServerTransport with the provided implementation. @@ -45,16 +46,18 @@ type ApplicationTypesServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewApplicationTypesServerTransport(srv *ApplicationTypesServer) *ApplicationTypesServerTransport { return &ApplicationTypesServerTransport{ - srv: srv, - beginDelete: newTracker[azfake.PollerResponder[armservicefabric.ApplicationTypesClientDeleteResponse]](), + srv: srv, + beginDelete: newTracker[azfake.PollerResponder[armservicefabric.ApplicationTypesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armservicefabric.ApplicationTypesClientListResponse]](), } } // ApplicationTypesServerTransport connects instances of armservicefabric.ApplicationTypesClient to instances of ApplicationTypesServer. // Don't use this type directly, use NewApplicationTypesServerTransport instead. type ApplicationTypesServerTransport struct { - srv *ApplicationTypesServer - beginDelete *tracker[azfake.PollerResponder[armservicefabric.ApplicationTypesClientDeleteResponse]] + srv *ApplicationTypesServer + beginDelete *tracker[azfake.PollerResponder[armservicefabric.ApplicationTypesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armservicefabric.ApplicationTypesClientListResponse]] } // Do implements the policy.Transporter interface for ApplicationTypesServerTransport. @@ -75,8 +78,8 @@ func (a *ApplicationTypesServerTransport) Do(req *http.Request) (*http.Response, resp, err = a.dispatchBeginDelete(req) case "ApplicationTypesClient.Get": resp, err = a.dispatchGet(req) - case "ApplicationTypesClient.List": - resp, err = a.dispatchList(req) + case "ApplicationTypesClient.NewListPager": + resp, err = a.dispatchNewListPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -214,35 +217,43 @@ func (a *ApplicationTypesServerTransport) dispatchGet(req *http.Request) (*http. return resp, nil } -func (a *ApplicationTypesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if a.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} +func (a *ApplicationTypesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applicationTypes` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 3 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applicationTypes` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 3 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(resourceGroupNameParam, clusterNameParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armservicefabric.ApplicationTypesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := a.srv.List(req.Context(), resourceGroupNameParam, clusterNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationTypeResourceList, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypeversions_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypeversions_server.go index e2f4871faba8..edfee93117e2 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypeversions_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/applicationtypeversions_server.go @@ -15,7 +15,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "regexp" @@ -35,9 +36,9 @@ type ApplicationTypeVersionsServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, version string, options *armservicefabric.ApplicationTypeVersionsClientGetOptions) (resp azfake.Responder[armservicefabric.ApplicationTypeVersionsClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method ApplicationTypeVersionsClient.List + // NewListPager is the fake for method ApplicationTypeVersionsClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, resourceGroupName string, clusterName string, applicationTypeName string, options *armservicefabric.ApplicationTypeVersionsClientListOptions) (resp azfake.Responder[armservicefabric.ApplicationTypeVersionsClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(resourceGroupName string, clusterName string, applicationTypeName string, options *armservicefabric.ApplicationTypeVersionsClientListOptions) (resp azfake.PagerResponder[armservicefabric.ApplicationTypeVersionsClientListResponse]) } // NewApplicationTypeVersionsServerTransport creates a new instance of ApplicationTypeVersionsServerTransport with the provided implementation. @@ -48,6 +49,7 @@ func NewApplicationTypeVersionsServerTransport(srv *ApplicationTypeVersionsServe srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicefabric.ApplicationTypeVersionsClientCreateOrUpdateResponse]](), beginDelete: newTracker[azfake.PollerResponder[armservicefabric.ApplicationTypeVersionsClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armservicefabric.ApplicationTypeVersionsClientListResponse]](), } } @@ -57,6 +59,7 @@ type ApplicationTypeVersionsServerTransport struct { srv *ApplicationTypeVersionsServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicefabric.ApplicationTypeVersionsClientCreateOrUpdateResponse]] beginDelete *tracker[azfake.PollerResponder[armservicefabric.ApplicationTypeVersionsClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armservicefabric.ApplicationTypeVersionsClientListResponse]] } // Do implements the policy.Transporter interface for ApplicationTypeVersionsServerTransport. @@ -77,8 +80,8 @@ func (a *ApplicationTypeVersionsServerTransport) Do(req *http.Request) (*http.Re resp, err = a.dispatchBeginDelete(req) case "ApplicationTypeVersionsClient.Get": resp, err = a.dispatchGet(req) - case "ApplicationTypeVersionsClient.List": - resp, err = a.dispatchList(req) + case "ApplicationTypeVersionsClient.NewListPager": + resp, err = a.dispatchNewListPager(req) default: err = fmt.Errorf("unhandled API %s", method) } @@ -239,39 +242,47 @@ func (a *ApplicationTypeVersionsServerTransport) dispatchGet(req *http.Request) return resp, nil } -func (a *ApplicationTypeVersionsServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if a.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} +func (a *ApplicationTypeVersionsServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if a.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applicationTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) - if err != nil { - return nil, err + newListPager := a.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applicationTypes/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/versions` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + applicationTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationTypeName")]) + if err != nil { + return nil, err + } + resp := a.srv.NewListPager(resourceGroupNameParam, clusterNameParam, applicationTypeNameParam, nil) + newListPager = &resp + a.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armservicefabric.ApplicationTypeVersionsClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) } - applicationTypeNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationTypeName")]) + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := a.srv.List(req.Context(), resourceGroupNameParam, clusterNameParam, applicationTypeNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !contains([]int{http.StatusOK}, resp.StatusCode) { + a.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ApplicationTypeVersionResourceList, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + a.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusters_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusters_server.go index 07869b4d1930..7a1a6d47b281 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusters_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusters_server.go @@ -15,7 +15,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "reflect" @@ -36,13 +37,13 @@ type ClustersServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, clusterName string, options *armservicefabric.ClustersClientGetOptions) (resp azfake.Responder[armservicefabric.ClustersClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method ClustersClient.List + // NewListPager is the fake for method ClustersClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, options *armservicefabric.ClustersClientListOptions) (resp azfake.Responder[armservicefabric.ClustersClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(options *armservicefabric.ClustersClientListOptions) (resp azfake.PagerResponder[armservicefabric.ClustersClientListResponse]) - // ListByResourceGroup is the fake for method ClustersClient.ListByResourceGroup + // NewListByResourceGroupPager is the fake for method ClustersClient.NewListByResourceGroupPager // HTTP status codes to indicate success: http.StatusOK - ListByResourceGroup func(ctx context.Context, resourceGroupName string, options *armservicefabric.ClustersClientListByResourceGroupOptions) (resp azfake.Responder[armservicefabric.ClustersClientListByResourceGroupResponse], errResp azfake.ErrorResponder) + NewListByResourceGroupPager func(resourceGroupName string, options *armservicefabric.ClustersClientListByResourceGroupOptions) (resp azfake.PagerResponder[armservicefabric.ClustersClientListByResourceGroupResponse]) // ListUpgradableVersions is the fake for method ClustersClient.ListUpgradableVersions // HTTP status codes to indicate success: http.StatusOK @@ -58,18 +59,22 @@ type ClustersServer struct { // azcore.ClientOptions.Transporter field in the client's constructor parameters. func NewClustersServerTransport(srv *ClustersServer) *ClustersServerTransport { return &ClustersServerTransport{ - srv: srv, - beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicefabric.ClustersClientCreateOrUpdateResponse]](), - beginUpdate: newTracker[azfake.PollerResponder[armservicefabric.ClustersClientUpdateResponse]](), + srv: srv, + beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicefabric.ClustersClientCreateOrUpdateResponse]](), + newListPager: newTracker[azfake.PagerResponder[armservicefabric.ClustersClientListResponse]](), + newListByResourceGroupPager: newTracker[azfake.PagerResponder[armservicefabric.ClustersClientListByResourceGroupResponse]](), + beginUpdate: newTracker[azfake.PollerResponder[armservicefabric.ClustersClientUpdateResponse]](), } } // ClustersServerTransport connects instances of armservicefabric.ClustersClient to instances of ClustersServer. // Don't use this type directly, use NewClustersServerTransport instead. type ClustersServerTransport struct { - srv *ClustersServer - beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicefabric.ClustersClientCreateOrUpdateResponse]] - beginUpdate *tracker[azfake.PollerResponder[armservicefabric.ClustersClientUpdateResponse]] + srv *ClustersServer + beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicefabric.ClustersClientCreateOrUpdateResponse]] + newListPager *tracker[azfake.PagerResponder[armservicefabric.ClustersClientListResponse]] + newListByResourceGroupPager *tracker[azfake.PagerResponder[armservicefabric.ClustersClientListByResourceGroupResponse]] + beginUpdate *tracker[azfake.PollerResponder[armservicefabric.ClustersClientUpdateResponse]] } // Do implements the policy.Transporter interface for ClustersServerTransport. @@ -90,10 +95,10 @@ func (c *ClustersServerTransport) Do(req *http.Request) (*http.Response, error) resp, err = c.dispatchDelete(req) case "ClustersClient.Get": resp, err = c.dispatchGet(req) - case "ClustersClient.List": - resp, err = c.dispatchList(req) - case "ClustersClient.ListByResourceGroup": - resp, err = c.dispatchListByResourceGroup(req) + case "ClustersClient.NewListPager": + resp, err = c.dispatchNewListPager(req) + case "ClustersClient.NewListByResourceGroupPager": + resp, err = c.dispatchNewListByResourceGroupPager(req) case "ClustersClient.ListUpgradableVersions": resp, err = c.dispatchListUpgradableVersions(req) case "ClustersClient.BeginUpdate": @@ -223,56 +228,72 @@ func (c *ClustersServerTransport) dispatchGet(req *http.Request) (*http.Response return resp, nil } -func (c *ClustersServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if c.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} +func (c *ClustersServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 1 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - respr, errRespr := c.srv.List(req.Context(), nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr - } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ClusterListResult, req) + newListPager := c.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 1 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resp := c.srv.NewListPager(nil) + newListPager = &resp + c.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armservicefabric.ClustersClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} + } + if !server.PagerResponderMore(newListPager) { + c.newListPager.remove(req) + } return resp, nil } -func (c *ClustersServerTransport) dispatchListByResourceGroup(req *http.Request) (*http.Response, error) { - if c.srv.ListByResourceGroup == nil { - return nil, &nonRetriableError{errors.New("fake for method ListByResourceGroup not implemented")} - } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 2 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) +func (c *ClustersServerTransport) dispatchNewListByResourceGroupPager(req *http.Request) (*http.Response, error) { + if c.srv.NewListByResourceGroupPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListByResourceGroupPager not implemented")} } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + newListByResourceGroupPager := c.newListByResourceGroupPager.get(req) + if newListByResourceGroupPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourcegroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 2 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + resp := c.srv.NewListByResourceGroupPager(resourceGroupNameParam, nil) + newListByResourceGroupPager = &resp + c.newListByResourceGroupPager.add(req, newListByResourceGroupPager) + server.PagerResponderInjectNextLinks(newListByResourceGroupPager, req, func(page *armservicefabric.ClustersClientListByResourceGroupResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListByResourceGroupPager, req) if err != nil { return nil, err } - respr, errRespr := c.srv.ListByResourceGroup(req.Context(), resourceGroupNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !contains([]int{http.StatusOK}, resp.StatusCode) { + c.newListByResourceGroupPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ClusterListResult, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListByResourceGroupPager) { + c.newListByResourceGroupPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusterversions_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusterversions_server.go index 8360e133e10d..4946b3818158 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusterversions_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/clusterversions_server.go @@ -15,7 +15,7 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "regexp" diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/operations_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/operations_server.go index 17005d098af1..1a1cb9bac34b 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/operations_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/operations_server.go @@ -15,7 +15,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" ) diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/fake/services_server.go b/sdk/resourcemanager/servicefabric/armservicefabric/fake/services_server.go index 96e44edf1174..14b02cf5d243 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/fake/services_server.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/fake/services_server.go @@ -15,7 +15,8 @@ import ( azfake "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake" "github.com/Azure/azure-sdk-for-go/sdk/azcore/fake/server" "github.com/Azure/azure-sdk-for-go/sdk/azcore/runtime" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "net/http" "net/url" "regexp" @@ -35,9 +36,9 @@ type ServicesServer struct { // HTTP status codes to indicate success: http.StatusOK Get func(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, serviceName string, options *armservicefabric.ServicesClientGetOptions) (resp azfake.Responder[armservicefabric.ServicesClientGetResponse], errResp azfake.ErrorResponder) - // List is the fake for method ServicesClient.List + // NewListPager is the fake for method ServicesClient.NewListPager // HTTP status codes to indicate success: http.StatusOK - List func(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, options *armservicefabric.ServicesClientListOptions) (resp azfake.Responder[armservicefabric.ServicesClientListResponse], errResp azfake.ErrorResponder) + NewListPager func(resourceGroupName string, clusterName string, applicationName string, options *armservicefabric.ServicesClientListOptions) (resp azfake.PagerResponder[armservicefabric.ServicesClientListResponse]) // BeginUpdate is the fake for method ServicesClient.BeginUpdate // HTTP status codes to indicate success: http.StatusAccepted @@ -52,6 +53,7 @@ func NewServicesServerTransport(srv *ServicesServer) *ServicesServerTransport { srv: srv, beginCreateOrUpdate: newTracker[azfake.PollerResponder[armservicefabric.ServicesClientCreateOrUpdateResponse]](), beginDelete: newTracker[azfake.PollerResponder[armservicefabric.ServicesClientDeleteResponse]](), + newListPager: newTracker[azfake.PagerResponder[armservicefabric.ServicesClientListResponse]](), beginUpdate: newTracker[azfake.PollerResponder[armservicefabric.ServicesClientUpdateResponse]](), } } @@ -62,6 +64,7 @@ type ServicesServerTransport struct { srv *ServicesServer beginCreateOrUpdate *tracker[azfake.PollerResponder[armservicefabric.ServicesClientCreateOrUpdateResponse]] beginDelete *tracker[azfake.PollerResponder[armservicefabric.ServicesClientDeleteResponse]] + newListPager *tracker[azfake.PagerResponder[armservicefabric.ServicesClientListResponse]] beginUpdate *tracker[azfake.PollerResponder[armservicefabric.ServicesClientUpdateResponse]] } @@ -83,8 +86,8 @@ func (s *ServicesServerTransport) Do(req *http.Request) (*http.Response, error) resp, err = s.dispatchBeginDelete(req) case "ServicesClient.Get": resp, err = s.dispatchGet(req) - case "ServicesClient.List": - resp, err = s.dispatchList(req) + case "ServicesClient.NewListPager": + resp, err = s.dispatchNewListPager(req) case "ServicesClient.BeginUpdate": resp, err = s.dispatchBeginUpdate(req) default: @@ -247,39 +250,47 @@ func (s *ServicesServerTransport) dispatchGet(req *http.Request) (*http.Response return resp, nil } -func (s *ServicesServerTransport) dispatchList(req *http.Request) (*http.Response, error) { - if s.srv.List == nil { - return nil, &nonRetriableError{errors.New("fake for method List not implemented")} +func (s *ServicesServerTransport) dispatchNewListPager(req *http.Request) (*http.Response, error) { + if s.srv.NewListPager == nil { + return nil, &nonRetriableError{errors.New("fake for method NewListPager not implemented")} } - const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/services` - regex := regexp.MustCompile(regexStr) - matches := regex.FindStringSubmatch(req.URL.EscapedPath()) - if matches == nil || len(matches) < 4 { - return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) - } - resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) - if err != nil { - return nil, err - } - clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) - if err != nil { - return nil, err - } - applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + newListPager := s.newListPager.get(req) + if newListPager == nil { + const regexStr = `/subscriptions/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/resourceGroups/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/providers/Microsoft\.ServiceFabric/clusters/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/applications/(?P[!#&$-;=?-\[\]_a-zA-Z0-9~%@]+)/services` + regex := regexp.MustCompile(regexStr) + matches := regex.FindStringSubmatch(req.URL.EscapedPath()) + if matches == nil || len(matches) < 4 { + return nil, fmt.Errorf("failed to parse path %s", req.URL.Path) + } + resourceGroupNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("resourceGroupName")]) + if err != nil { + return nil, err + } + clusterNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("clusterName")]) + if err != nil { + return nil, err + } + applicationNameParam, err := url.PathUnescape(matches[regex.SubexpIndex("applicationName")]) + if err != nil { + return nil, err + } + resp := s.srv.NewListPager(resourceGroupNameParam, clusterNameParam, applicationNameParam, nil) + newListPager = &resp + s.newListPager.add(req, newListPager) + server.PagerResponderInjectNextLinks(newListPager, req, func(page *armservicefabric.ServicesClientListResponse, createLink func() string) { + page.NextLink = to.Ptr(createLink()) + }) + } + resp, err := server.PagerResponderNext(newListPager, req) if err != nil { return nil, err } - respr, errRespr := s.srv.List(req.Context(), resourceGroupNameParam, clusterNameParam, applicationNameParam, nil) - if respErr := server.GetError(errRespr, req); respErr != nil { - return nil, respErr + if !contains([]int{http.StatusOK}, resp.StatusCode) { + s.newListPager.remove(req) + return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", resp.StatusCode)} } - respContent := server.GetResponseContent(respr) - if !contains([]int{http.StatusOK}, respContent.HTTPStatus) { - return nil, &nonRetriableError{fmt.Errorf("unexpected status code %d. acceptable values are http.StatusOK", respContent.HTTPStatus)} - } - resp, err := server.MarshalResponseAsJSON(respContent, server.GetResponse(respr).ServiceResourceList, req) - if err != nil { - return nil, err + if !server.PagerResponderMore(newListPager) { + s.newListPager.remove(req) } return resp, nil } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/go.mod b/sdk/resourcemanager/servicefabric/armservicefabric/go.mod index 07222a7e297a..a8d264d20d44 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/go.mod +++ b/sdk/resourcemanager/servicefabric/armservicefabric/go.mod @@ -1,4 +1,4 @@ -module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric +module github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2 go 1.18 diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/models.go b/sdk/resourcemanager/servicefabric/armservicefabric/models.go index af8fc4440eda..52c342cd2f8d 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/models.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/models.go @@ -566,7 +566,8 @@ type ClusterProperties struct { // The Service Fabric runtime version of the cluster. This property can only by set the user when upgradeMode is set to 'Manual'. // To get list of available Service Fabric versions for new clusters use - // ClusterVersion API [./ClusterVersion.md]. To get the list of available version for existing clusters use availableClusterVersions. + // ClusterVersion API [https://learn.microsoft.com/rest/api/servicefabric/cluster-versions/list]. To get the list of available + // version for existing clusters use availableClusterVersions. ClusterCodeVersion *string // The storage account information for storing Service Fabric diagnostic logs. @@ -688,7 +689,8 @@ type ClusterPropertiesUpdateParameters struct { // The Service Fabric runtime version of the cluster. This property can only by set the user when upgradeMode is set to 'Manual'. // To get list of available Service Fabric versions for new clusters use - // ClusterVersion API [./ClusterVersion.md]. To get the list of available version for existing clusters use availableClusterVersions. + // ClusterVersion API [https://learn.microsoft.com/rest/api/servicefabric/cluster-versions/list]. To get the list of available + // version for existing clusters use availableClusterVersions. ClusterCodeVersion *string // Indicates if the event store service is enabled. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/operations_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/operations_client_example_test.go index 55195b90b435..e9e31900089d 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/operations_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/operations_client_example_test.go @@ -14,10 +14,10 @@ import ( "log" "github.com/Azure/azure-sdk-for-go/sdk/azidentity" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListOperations.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ListOperations.json func ExampleOperationsClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/options.go b/sdk/resourcemanager/servicefabric/armservicefabric/options.go index e323db00bc54..8a37c8f05d82 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/options.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/options.go @@ -27,7 +27,8 @@ type ApplicationTypeVersionsClientGetOptions struct { // placeholder for future optional parameters } -// ApplicationTypeVersionsClientListOptions contains the optional parameters for the ApplicationTypeVersionsClient.List method. +// ApplicationTypeVersionsClientListOptions contains the optional parameters for the ApplicationTypeVersionsClient.NewListPager +// method. type ApplicationTypeVersionsClientListOptions struct { // placeholder for future optional parameters } @@ -49,7 +50,7 @@ type ApplicationTypesClientGetOptions struct { // placeholder for future optional parameters } -// ApplicationTypesClientListOptions contains the optional parameters for the ApplicationTypesClient.List method. +// ApplicationTypesClientListOptions contains the optional parameters for the ApplicationTypesClient.NewListPager method. type ApplicationTypesClientListOptions struct { // placeholder for future optional parameters } @@ -78,7 +79,7 @@ type ApplicationsClientGetOptions struct { // placeholder for future optional parameters } -// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.List method. +// ApplicationsClientListOptions contains the optional parameters for the ApplicationsClient.NewListPager method. type ApplicationsClientListOptions struct { // placeholder for future optional parameters } @@ -127,12 +128,13 @@ type ClustersClientGetOptions struct { // placeholder for future optional parameters } -// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.ListByResourceGroup method. +// ClustersClientListByResourceGroupOptions contains the optional parameters for the ClustersClient.NewListByResourceGroupPager +// method. type ClustersClientListByResourceGroupOptions struct { // placeholder for future optional parameters } -// ClustersClientListOptions contains the optional parameters for the ClustersClient.List method. +// ClustersClientListOptions contains the optional parameters for the ClustersClient.NewListPager method. type ClustersClientListOptions struct { // placeholder for future optional parameters } @@ -172,7 +174,7 @@ type ServicesClientGetOptions struct { // placeholder for future optional parameters } -// ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. +// ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. type ServicesClientListOptions struct { // placeholder for future optional parameters } diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/response_types.go b/sdk/resourcemanager/servicefabric/armservicefabric/response_types.go index 03745c31cb72..5a5cfd430ded 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/response_types.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/response_types.go @@ -25,7 +25,7 @@ type ApplicationTypeVersionsClientGetResponse struct { ApplicationTypeVersionResource } -// ApplicationTypeVersionsClientListResponse contains the response from method ApplicationTypeVersionsClient.List. +// ApplicationTypeVersionsClientListResponse contains the response from method ApplicationTypeVersionsClient.NewListPager. type ApplicationTypeVersionsClientListResponse struct { // The list of application type version resources for the specified application type name resource. ApplicationTypeVersionResourceList @@ -48,7 +48,7 @@ type ApplicationTypesClientGetResponse struct { ApplicationTypeResource } -// ApplicationTypesClientListResponse contains the response from method ApplicationTypesClient.List. +// ApplicationTypesClientListResponse contains the response from method ApplicationTypesClient.NewListPager. type ApplicationTypesClientListResponse struct { // The list of application type names. ApplicationTypeResourceList @@ -71,7 +71,7 @@ type ApplicationsClientGetResponse struct { ApplicationResource } -// ApplicationsClientListResponse contains the response from method ApplicationsClient.List. +// ApplicationsClientListResponse contains the response from method ApplicationsClient.NewListPager. type ApplicationsClientListResponse struct { // The list of application resources. ApplicationResourceList @@ -124,13 +124,13 @@ type ClustersClientGetResponse struct { Cluster } -// ClustersClientListByResourceGroupResponse contains the response from method ClustersClient.ListByResourceGroup. +// ClustersClientListByResourceGroupResponse contains the response from method ClustersClient.NewListByResourceGroupPager. type ClustersClientListByResourceGroupResponse struct { // Cluster list results ClusterListResult } -// ClustersClientListResponse contains the response from method ClustersClient.List. +// ClustersClientListResponse contains the response from method ClustersClient.NewListPager. type ClustersClientListResponse struct { // Cluster list results ClusterListResult @@ -172,7 +172,7 @@ type ServicesClientGetResponse struct { ServiceResource } -// ServicesClientListResponse contains the response from method ServicesClient.List. +// ServicesClientListResponse contains the response from method ServicesClient.NewListPager. type ServicesClientListResponse struct { // The list of service resources. ServiceResourceList diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/servicefabric_live_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/servicefabric_live_test.go index 9d900e512d81..c51a2ddea546 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/servicefabric_live_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/servicefabric_live_test.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/sdk/azcore/to" "github.com/Azure/azure-sdk-for-go/sdk/internal/recording" "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/internal/v2/testutil" - "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" "github.com/stretchr/testify/suite" ) @@ -120,13 +120,21 @@ func (testsuite *ServicefabricTestSuite) TestClusters() { fmt.Println("Call operation: Clusters_List") clustersClient, err := armservicefabric.NewClustersClient(testsuite.subscriptionId, testsuite.cred, testsuite.options) testsuite.Require().NoError(err) - _, err = clustersClient.List(testsuite.ctx, nil) - testsuite.Require().NoError(err) + clustersClientNewListPager := clustersClient.NewListPager(nil) + for clustersClientNewListPager.More() { + _, err := clustersClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } // From step Clusters_ListByResourceGroup fmt.Println("Call operation: Clusters_ListByResourceGroup") - _, err = clustersClient.ListByResourceGroup(testsuite.ctx, testsuite.resourceGroupName, nil) - testsuite.Require().NoError(err) + clustersClientNewListByResourceGroupPager := clustersClient.NewListByResourceGroupPager(testsuite.resourceGroupName, nil) + for clustersClientNewListByResourceGroupPager.More() { + _, err := clustersClientNewListByResourceGroupPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } // From step Clusters_Get fmt.Println("Call operation: Clusters_Get") @@ -193,8 +201,12 @@ func (testsuite *ServicefabricTestSuite) TestApplicationTypes() { // From step ApplicationTypes_List fmt.Println("Call operation: ApplicationTypes_List") - _, err = applicationTypesClient.List(testsuite.ctx, testsuite.resourceGroupName, testsuite.clusterName, nil) - testsuite.Require().NoError(err) + applicationTypesClientNewListPager := applicationTypesClient.NewListPager(testsuite.resourceGroupName, testsuite.clusterName, nil) + for applicationTypesClientNewListPager.More() { + _, err := applicationTypesClientNewListPager.NextPage(testsuite.ctx) + testsuite.Require().NoError(err) + break + } // From step ApplicationTypes_Get fmt.Println("Call operation: ApplicationTypes_Get") diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/services_client.go b/sdk/resourcemanager/servicefabric/armservicefabric/services_client.go index 7b957f358593..f6eb796be7c1 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/services_client.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/services_client.go @@ -293,34 +293,35 @@ func (client *ServicesClient) getHandleResponse(resp *http.Response) (ServicesCl return result, nil } -// List - Gets all service resources created or in the process of being created in the Service Fabric application resource. -// If the operation fails it returns an *azcore.ResponseError type. +// NewListPager - Gets all service resources created or in the process of being created in the Service Fabric application +// resource. // // Generated from API version 2021-06-01 // - resourceGroupName - The name of the resource group. // - clusterName - The name of the cluster resource. // - applicationName - The name of the application resource. -// - options - ServicesClientListOptions contains the optional parameters for the ServicesClient.List method. -func (client *ServicesClient) List(ctx context.Context, resourceGroupName string, clusterName string, applicationName string, options *ServicesClientListOptions) (ServicesClientListResponse, error) { - var err error - const operationName = "ServicesClient.List" - ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, operationName) - ctx, endSpan := runtime.StartSpan(ctx, operationName, client.internal.Tracer(), nil) - defer func() { endSpan(err) }() - req, err := client.listCreateRequest(ctx, resourceGroupName, clusterName, applicationName, options) - if err != nil { - return ServicesClientListResponse{}, err - } - httpResp, err := client.internal.Pipeline().Do(req) - if err != nil { - return ServicesClientListResponse{}, err - } - if !runtime.HasStatusCode(httpResp, http.StatusOK) { - err = runtime.NewResponseError(httpResp) - return ServicesClientListResponse{}, err - } - resp, err := client.listHandleResponse(httpResp) - return resp, err +// - options - ServicesClientListOptions contains the optional parameters for the ServicesClient.NewListPager method. +func (client *ServicesClient) NewListPager(resourceGroupName string, clusterName string, applicationName string, options *ServicesClientListOptions) *runtime.Pager[ServicesClientListResponse] { + return runtime.NewPager(runtime.PagingHandler[ServicesClientListResponse]{ + More: func(page ServicesClientListResponse) bool { + return page.NextLink != nil && len(*page.NextLink) > 0 + }, + Fetcher: func(ctx context.Context, page *ServicesClientListResponse) (ServicesClientListResponse, error) { + ctx = context.WithValue(ctx, runtime.CtxAPINameKey{}, "ServicesClient.NewListPager") + nextLink := "" + if page != nil { + nextLink = *page.NextLink + } + resp, err := runtime.FetcherForNextLink(ctx, client.internal.Pipeline(), nextLink, func(ctx context.Context) (*policy.Request, error) { + return client.listCreateRequest(ctx, resourceGroupName, clusterName, applicationName, options) + }, nil) + if err != nil { + return ServicesClientListResponse{}, err + } + return client.listHandleResponse(resp) + }, + Tracer: client.internal.Tracer(), + }) } // listCreateRequest creates the List request. diff --git a/sdk/resourcemanager/servicefabric/armservicefabric/services_client_example_test.go b/sdk/resourcemanager/servicefabric/armservicefabric/services_client_example_test.go index 765bb7c54cbb..458deccc3052 100644 --- a/sdk/resourcemanager/servicefabric/armservicefabric/services_client_example_test.go +++ b/sdk/resourcemanager/servicefabric/armservicefabric/services_client_example_test.go @@ -15,10 +15,10 @@ import ( "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/servicefabric/armservicefabric" + "github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/servicefabric/armservicefabric/v2" ) -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceGetOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceGetOperation_example.json func ExampleServicesClient_Get() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -66,7 +66,7 @@ func ExampleServicesClient_Get() { // } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePutOperation_example_max.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePutOperation_example_max.json func ExampleServicesClient_BeginCreateOrUpdate_putAServiceWithMaximumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -112,7 +112,7 @@ func ExampleServicesClient_BeginCreateOrUpdate_putAServiceWithMaximumParameters( } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePutOperation_example_min.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePutOperation_example_min.json func ExampleServicesClient_BeginCreateOrUpdate_putAServiceWithMinimumParameters() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -143,7 +143,7 @@ func ExampleServicesClient_BeginCreateOrUpdate_putAServiceWithMinimumParameters( } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePatchOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServicePatchOperation_example.json func ExampleServicesClient_BeginUpdate() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -174,7 +174,7 @@ func ExampleServicesClient_BeginUpdate() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceDeleteOperation_example.json +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceDeleteOperation_example.json func ExampleServicesClient_BeginDelete() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { @@ -195,8 +195,8 @@ func ExampleServicesClient_BeginDelete() { } } -// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/d55b8005f05b040b852c15e74a0f3e36494a15e1/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceListOperation_example.json -func ExampleServicesClient_List() { +// Generated from example definition: https://github.com/Azure/azure-rest-api-specs/blob/b8c74fd80b415fa1ebb6fa787d454694c39e0fd5/specification/servicefabric/resource-manager/Microsoft.ServiceFabric/stable/2021-06-01/examples/ServiceListOperation_example.json +func ExampleServicesClient_NewListPager() { cred, err := azidentity.NewDefaultAzureCredential(nil) if err != nil { log.Fatalf("failed to obtain a credential: %v", err) @@ -206,38 +206,43 @@ func ExampleServicesClient_List() { if err != nil { log.Fatalf("failed to create client: %v", err) } - res, err := clientFactory.NewServicesClient().List(ctx, "resRg", "myCluster", "myApp", nil) - if err != nil { - log.Fatalf("failed to finish the request: %v", err) + pager := clientFactory.NewServicesClient().NewListPager("resRg", "myCluster", "myApp", 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.ServiceResourceList = armservicefabric.ServiceResourceList{ + // Value: []*armservicefabric.ServiceResource{ + // { + // Name: to.Ptr("myCluster"), + // Type: to.Ptr("services"), + // Etag: to.Ptr("W/\"636462502183671257\""), + // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp/services/myService"), + // Location: to.Ptr("eastus"), + // Tags: map[string]*string{ + // }, + // Properties: &armservicefabric.StatelessServiceProperties{ + // ServiceLoadMetrics: []*armservicefabric.ServiceLoadMetricDescription{ + // { + // Name: to.Ptr("metric1"), + // Weight: to.Ptr(armservicefabric.ServiceLoadMetricWeightLow), + // }}, + // PartitionDescription: &armservicefabric.SingletonPartitionSchemeDescription{ + // PartitionScheme: to.Ptr(armservicefabric.PartitionSchemeSingleton), + // }, + // ProvisioningState: to.Ptr("Succeeded"), + // ServiceKind: to.Ptr(armservicefabric.ServiceKindStateless), + // ServicePackageActivationMode: to.Ptr(armservicefabric.ArmServicePackageActivationModeSharedProcess), + // ServiceTypeName: to.Ptr("myServiceType"), + // InstanceCount: to.Ptr[int32](1), + // }, + // }}, + // } } - // You could use response here. We use blank identifier for just demo purposes. - _ = res - // If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes. - // res.ServiceResourceList = armservicefabric.ServiceResourceList{ - // Value: []*armservicefabric.ServiceResource{ - // { - // Name: to.Ptr("myCluster"), - // Type: to.Ptr("services"), - // Etag: to.Ptr("W/\"636462502183671257\""), - // ID: to.Ptr("/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/resRg/providers/Microsoft.ServiceFabric/clusters/myCluster/applications/myApp/services/myService"), - // Location: to.Ptr("eastus"), - // Tags: map[string]*string{ - // }, - // Properties: &armservicefabric.StatelessServiceProperties{ - // ServiceLoadMetrics: []*armservicefabric.ServiceLoadMetricDescription{ - // { - // Name: to.Ptr("metric1"), - // Weight: to.Ptr(armservicefabric.ServiceLoadMetricWeightLow), - // }}, - // PartitionDescription: &armservicefabric.SingletonPartitionSchemeDescription{ - // PartitionScheme: to.Ptr(armservicefabric.PartitionSchemeSingleton), - // }, - // ProvisioningState: to.Ptr("Succeeded"), - // ServiceKind: to.Ptr(armservicefabric.ServiceKindStateless), - // ServicePackageActivationMode: to.Ptr(armservicefabric.ArmServicePackageActivationModeSharedProcess), - // ServiceTypeName: to.Ptr("myServiceType"), - // InstanceCount: to.Ptr[int32](1), - // }, - // }}, - // } }