| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System; |
| | 9 | | using System.Threading; |
| | 10 | | using System.Threading.Tasks; |
| | 11 | | using Azure; |
| | 12 | | using Azure.Analytics.Synapse.Artifacts.Models; |
| | 13 | | using Azure.Core; |
| | 14 | | using Azure.Core.Pipeline; |
| | 15 | |
|
| 0 | 16 | | namespace Azure.Analytics.Synapse.Artifacts |
| | 17 | | { |
| 0 | 18 | | /// <summary> The Notebook service client. </summary> |
| | 19 | | public partial class NotebookClient |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 16 | 23 | | internal NotebookRestClient RestClient { get; } |
| 4 | 24 | | /// <summary> Initializes a new instance of NotebookClient for mocking. </summary> |
| 12 | 25 | | protected NotebookClient() |
| 4 | 26 | | { |
| 12 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of NotebookClient. </summary> |
| 4 | 29 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 30 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 31 | | /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 32 | | /// <param name="apiVersion"> Api Version. </param> |
| 8 | 33 | | internal NotebookClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string apiV |
| | 34 | | { |
| 8 | 35 | | RestClient = new NotebookRestClient(clientDiagnostics, pipeline, endpoint, apiVersion); |
| 8 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 8 | 37 | | _pipeline = pipeline; |
| 8 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Creates or updates a Note Book. </summary> |
| | 41 | | /// <param name="notebookName"> The notebook name. </param> |
| | 42 | | /// <param name="notebook"> Note book resource definition. </param> |
| | 43 | | /// <param name="ifMatch"> ETag of the Note book entity. Should only be specified for update, for which it shou |
| | 44 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 45 | | public virtual async Task<Response<NotebookResource>> CreateOrUpdateNotebookAsync(string notebookName, NotebookR |
| | 46 | | { |
| 0 | 47 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.CreateOrUpdateNotebook"); |
| 0 | 48 | | scope.Start(); |
| | 49 | | try |
| | 50 | | { |
| 0 | 51 | | return await RestClient.CreateOrUpdateNotebookAsync(notebookName, notebook, ifMatch, cancellationToken). |
| | 52 | | } |
| 0 | 53 | | catch (Exception e) |
| | 54 | | { |
| 0 | 55 | | scope.Failed(e); |
| 0 | 56 | | throw; |
| | 57 | | } |
| 0 | 58 | | } |
| | 59 | |
|
| | 60 | | /// <summary> Creates or updates a Note Book. </summary> |
| | 61 | | /// <param name="notebookName"> The notebook name. </param> |
| | 62 | | /// <param name="notebook"> Note book resource definition. </param> |
| | 63 | | /// <param name="ifMatch"> ETag of the Note book entity. Should only be specified for update, for which it shou |
| | 64 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 65 | | public virtual Response<NotebookResource> CreateOrUpdateNotebook(string notebookName, NotebookResource notebook, |
| | 66 | | { |
| 0 | 67 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.CreateOrUpdateNotebook"); |
| 0 | 68 | | scope.Start(); |
| | 69 | | try |
| | 70 | | { |
| 0 | 71 | | return RestClient.CreateOrUpdateNotebook(notebookName, notebook, ifMatch, cancellationToken); |
| | 72 | | } |
| 0 | 73 | | catch (Exception e) |
| | 74 | | { |
| 0 | 75 | | scope.Failed(e); |
| 0 | 76 | | throw; |
| | 77 | | } |
| 0 | 78 | | } |
| | 79 | |
|
| | 80 | | /// <summary> Gets a Note Book. </summary> |
| | 81 | | /// <param name="notebookName"> The notebook name. </param> |
| | 82 | | /// <param name="ifNoneMatch"> ETag of the Notebook entity. Should only be specified for get. If the ETag matche |
| | 83 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 84 | | public virtual async Task<Response<NotebookResource>> GetNotebookAsync(string notebookName, string ifNoneMatch = |
| | 85 | | { |
| 6 | 86 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebook"); |
| 6 | 87 | | scope.Start(); |
| | 88 | | try |
| | 89 | | { |
| 6 | 90 | | return await RestClient.GetNotebookAsync(notebookName, ifNoneMatch, cancellationToken).ConfigureAwait(fa |
| | 91 | | } |
| 0 | 92 | | catch (Exception e) |
| | 93 | | { |
| 0 | 94 | | scope.Failed(e); |
| 0 | 95 | | throw; |
| | 96 | | } |
| 6 | 97 | | } |
| | 98 | |
|
| | 99 | | /// <summary> Gets a Note Book. </summary> |
| | 100 | | /// <param name="notebookName"> The notebook name. </param> |
| | 101 | | /// <param name="ifNoneMatch"> ETag of the Notebook entity. Should only be specified for get. If the ETag matche |
| | 102 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 103 | | public virtual Response<NotebookResource> GetNotebook(string notebookName, string ifNoneMatch = null, Cancellati |
| | 104 | | { |
| 6 | 105 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebook"); |
| 6 | 106 | | scope.Start(); |
| | 107 | | try |
| | 108 | | { |
| 6 | 109 | | return RestClient.GetNotebook(notebookName, ifNoneMatch, cancellationToken); |
| | 110 | | } |
| 0 | 111 | | catch (Exception e) |
| | 112 | | { |
| 0 | 113 | | scope.Failed(e); |
| 0 | 114 | | throw; |
| | 115 | | } |
| 6 | 116 | | } |
| | 117 | |
|
| | 118 | | /// <summary> Deletes a Note book. </summary> |
| | 119 | | /// <param name="notebookName"> The notebook name. </param> |
| | 120 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 121 | | public virtual async Task<Response> DeleteNotebookAsync(string notebookName, CancellationToken cancellationToken |
| | 122 | | { |
| 0 | 123 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.DeleteNotebook"); |
| 0 | 124 | | scope.Start(); |
| | 125 | | try |
| | 126 | | { |
| 0 | 127 | | return await RestClient.DeleteNotebookAsync(notebookName, cancellationToken).ConfigureAwait(false); |
| | 128 | | } |
| 0 | 129 | | catch (Exception e) |
| | 130 | | { |
| 0 | 131 | | scope.Failed(e); |
| 0 | 132 | | throw; |
| | 133 | | } |
| 0 | 134 | | } |
| | 135 | |
|
| | 136 | | /// <summary> Deletes a Note book. </summary> |
| | 137 | | /// <param name="notebookName"> The notebook name. </param> |
| | 138 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 139 | | public virtual Response DeleteNotebook(string notebookName, CancellationToken cancellationToken = default) |
| | 140 | | { |
| 0 | 141 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.DeleteNotebook"); |
| 0 | 142 | | scope.Start(); |
| | 143 | | try |
| | 144 | | { |
| 0 | 145 | | return RestClient.DeleteNotebook(notebookName, cancellationToken); |
| | 146 | | } |
| 0 | 147 | | catch (Exception e) |
| | 148 | | { |
| 0 | 149 | | scope.Failed(e); |
| 0 | 150 | | throw; |
| | 151 | | } |
| 0 | 152 | | } |
| | 153 | |
|
| | 154 | | /// <summary> Lists Notebooks. </summary> |
| | 155 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 156 | | public virtual AsyncPageable<NotebookResource> GetNotebooksByWorkspaceAsync(CancellationToken cancellationToken |
| | 157 | | { |
| | 158 | | async Task<Page<NotebookResource>> FirstPageFunc(int? pageSizeHint) |
| | 159 | | { |
| 2 | 160 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebooksByWorkspace"); |
| 2 | 161 | | scope.Start(); |
| | 162 | | try |
| | 163 | | { |
| 2 | 164 | | var response = await RestClient.GetNotebooksByWorkspaceAsync(cancellationToken).ConfigureAwait(false |
| 2 | 165 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 166 | | } |
| 0 | 167 | | catch (Exception e) |
| | 168 | | { |
| 0 | 169 | | scope.Failed(e); |
| 0 | 170 | | throw; |
| | 171 | | } |
| 2 | 172 | | } |
| | 173 | | async Task<Page<NotebookResource>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 174 | | { |
| 0 | 175 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebooksByWorkspace"); |
| 0 | 176 | | scope.Start(); |
| | 177 | | try |
| | 178 | | { |
| 0 | 179 | | var response = await RestClient.GetNotebooksByWorkspaceNextPageAsync(nextLink, cancellationToken).Co |
| 0 | 180 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 181 | | } |
| 0 | 182 | | catch (Exception e) |
| | 183 | | { |
| 0 | 184 | | scope.Failed(e); |
| 0 | 185 | | throw; |
| | 186 | | } |
| 0 | 187 | | } |
| 2 | 188 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 189 | | } |
| | 190 | |
|
| | 191 | | /// <summary> Lists Notebooks. </summary> |
| | 192 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 193 | | public virtual Pageable<NotebookResource> GetNotebooksByWorkspace(CancellationToken cancellationToken = default) |
| | 194 | | { |
| | 195 | | Page<NotebookResource> FirstPageFunc(int? pageSizeHint) |
| | 196 | | { |
| 2 | 197 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebooksByWorkspace"); |
| 2 | 198 | | scope.Start(); |
| | 199 | | try |
| | 200 | | { |
| 2 | 201 | | var response = RestClient.GetNotebooksByWorkspace(cancellationToken); |
| 2 | 202 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 203 | | } |
| 0 | 204 | | catch (Exception e) |
| | 205 | | { |
| 0 | 206 | | scope.Failed(e); |
| 0 | 207 | | throw; |
| | 208 | | } |
| 2 | 209 | | } |
| | 210 | | Page<NotebookResource> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 211 | | { |
| 0 | 212 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebooksByWorkspace"); |
| 0 | 213 | | scope.Start(); |
| | 214 | | try |
| | 215 | | { |
| 0 | 216 | | var response = RestClient.GetNotebooksByWorkspaceNextPage(nextLink, cancellationToken); |
| 0 | 217 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 218 | | } |
| 0 | 219 | | catch (Exception e) |
| | 220 | | { |
| 0 | 221 | | scope.Failed(e); |
| 0 | 222 | | throw; |
| | 223 | | } |
| 0 | 224 | | } |
| 2 | 225 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 226 | | } |
| | 227 | |
|
| | 228 | | /// <summary> Lists a summary of Notebooks. </summary> |
| | 229 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 230 | | public virtual AsyncPageable<NotebookResource> GetNotebookSummaryByWorkSpaceAsync(CancellationToken cancellation |
| | 231 | | { |
| | 232 | | async Task<Page<NotebookResource>> FirstPageFunc(int? pageSizeHint) |
| | 233 | | { |
| 0 | 234 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebookSummaryByWorkSpace"); |
| 0 | 235 | | scope.Start(); |
| | 236 | | try |
| | 237 | | { |
| 0 | 238 | | var response = await RestClient.GetNotebookSummaryByWorkSpaceAsync(cancellationToken).ConfigureAwait |
| 0 | 239 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 240 | | } |
| 0 | 241 | | catch (Exception e) |
| | 242 | | { |
| 0 | 243 | | scope.Failed(e); |
| 0 | 244 | | throw; |
| | 245 | | } |
| 0 | 246 | | } |
| | 247 | | async Task<Page<NotebookResource>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 248 | | { |
| 0 | 249 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebookSummaryByWorkSpace"); |
| 0 | 250 | | scope.Start(); |
| | 251 | | try |
| | 252 | | { |
| 0 | 253 | | var response = await RestClient.GetNotebookSummaryByWorkSpaceNextPageAsync(nextLink, cancellationTok |
| 0 | 254 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 255 | | } |
| 0 | 256 | | catch (Exception e) |
| | 257 | | { |
| 0 | 258 | | scope.Failed(e); |
| 0 | 259 | | throw; |
| | 260 | | } |
| 0 | 261 | | } |
| 0 | 262 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 263 | | } |
| | 264 | |
|
| | 265 | | /// <summary> Lists a summary of Notebooks. </summary> |
| | 266 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 267 | | public virtual Pageable<NotebookResource> GetNotebookSummaryByWorkSpace(CancellationToken cancellationToken = de |
| | 268 | | { |
| | 269 | | Page<NotebookResource> FirstPageFunc(int? pageSizeHint) |
| | 270 | | { |
| 0 | 271 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebookSummaryByWorkSpace"); |
| 0 | 272 | | scope.Start(); |
| | 273 | | try |
| | 274 | | { |
| 0 | 275 | | var response = RestClient.GetNotebookSummaryByWorkSpace(cancellationToken); |
| 0 | 276 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 277 | | } |
| 0 | 278 | | catch (Exception e) |
| | 279 | | { |
| 0 | 280 | | scope.Failed(e); |
| 0 | 281 | | throw; |
| | 282 | | } |
| 0 | 283 | | } |
| | 284 | | Page<NotebookResource> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 285 | | { |
| 0 | 286 | | using var scope = _clientDiagnostics.CreateScope("NotebookClient.GetNotebookSummaryByWorkSpace"); |
| 0 | 287 | | scope.Start(); |
| | 288 | | try |
| | 289 | | { |
| 0 | 290 | | var response = RestClient.GetNotebookSummaryByWorkSpaceNextPage(nextLink, cancellationToken); |
| 0 | 291 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 292 | | } |
| 0 | 293 | | catch (Exception e) |
| | 294 | | { |
| 0 | 295 | | scope.Failed(e); |
| 0 | 296 | | throw; |
| | 297 | | } |
| 0 | 298 | | } |
| 0 | 299 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 300 | | } |
| | 301 | | } |
| | 302 | | } |