/// <summary> /// Gets a collection of items describing the models trained on this Cognitive Services Account /// and their training status. /// </summary> /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param> /// <returns>A collection of <see cref="CustomFormModelInfo"/> items.</returns> public virtual Pageable <CustomFormModelInfo> GetCustomModels(CancellationToken cancellationToken = default) { Page <CustomFormModelInfo> FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormTrainingClient)}.{nameof(GetCustomModels)}"); scope.Start(); try { Response <Models.Models> response = ServiceClient.ListCustomModels(cancellationToken); return(Page.FromValues(response.Value.ModelList, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } Page <CustomFormModelInfo> NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = Diagnostics.CreateScope($"{nameof(FormTrainingClient)}.{nameof(GetCustomModels)}"); scope.Start(); try { Response <Models.Models> response = ServiceClient.ListCustomModelsNextPage(nextLink, cancellationToken); return(Page.FromValues(response.Value.ModelList, response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc)); }