| | 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.Collections.Generic; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | | using Azure; |
| | 13 | | using Azure.Analytics.Synapse.AccessControl.Models; |
| | 14 | | using Azure.Core; |
| | 15 | | using Azure.Core.Pipeline; |
| 0 | 16 | |
|
| | 17 | | namespace Azure.Analytics.Synapse.AccessControl |
| 0 | 18 | | { |
| | 19 | | /// <summary> The AccessControl service client. </summary> |
| | 20 | | public partial class AccessControlClient |
| | 21 | | { |
| | 22 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 23 | | private readonly HttpPipeline _pipeline; |
| 108 | 24 | | internal AccessControlRestClient RestClient { get; } |
| 8 | 25 | | /// <summary> Initializes a new instance of AccessControlClient for mocking. </summary> |
| 24 | 26 | | protected AccessControlClient() |
| 8 | 27 | | { |
| 16 | 28 | | } |
| 8 | 29 | | /// <summary> Initializes a new instance of AccessControlClient. </summary> |
| | 30 | | /// <param name="clientDiagnostics"> The handler for diagnostic messaging in the client. </param> |
| | 31 | | /// <param name="pipeline"> The HTTP pipeline for sending and receiving REST requests and responses. </param> |
| | 32 | | /// <param name="endpoint"> The workspace development endpoint, for example https://myworkspace.dev.azuresynapse |
| | 33 | | /// <param name="apiVersion"> Api Version. </param> |
| 16 | 34 | | internal AccessControlClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string endpoint, string |
| | 35 | | { |
| 16 | 36 | | RestClient = new AccessControlRestClient(clientDiagnostics, pipeline, endpoint, apiVersion); |
| 16 | 37 | | _clientDiagnostics = clientDiagnostics; |
| 16 | 38 | | _pipeline = pipeline; |
| 16 | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> Create role assignment. </summary> |
| | 42 | | /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param> |
| | 43 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 44 | | public virtual async Task<Response<RoleAssignmentDetails>> CreateRoleAssignmentAsync(RoleAssignmentOptions creat |
| | 45 | | { |
| 2 | 46 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.CreateRoleAssignment"); |
| 2 | 47 | | scope.Start(); |
| | 48 | | try |
| | 49 | | { |
| 2 | 50 | | return await RestClient.CreateRoleAssignmentAsync(createRoleAssignmentOptions, cancellationToken).Config |
| | 51 | | } |
| 0 | 52 | | catch (Exception e) |
| | 53 | | { |
| 0 | 54 | | scope.Failed(e); |
| 0 | 55 | | throw; |
| | 56 | | } |
| 2 | 57 | | } |
| | 58 | |
|
| | 59 | | /// <summary> Create role assignment. </summary> |
| | 60 | | /// <param name="createRoleAssignmentOptions"> Details of role id and object id. </param> |
| | 61 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 62 | | public virtual Response<RoleAssignmentDetails> CreateRoleAssignment(RoleAssignmentOptions createRoleAssignmentOp |
| | 63 | | { |
| 2 | 64 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.CreateRoleAssignment"); |
| 2 | 65 | | scope.Start(); |
| | 66 | | try |
| | 67 | | { |
| 2 | 68 | | return RestClient.CreateRoleAssignment(createRoleAssignmentOptions, cancellationToken); |
| | 69 | | } |
| 0 | 70 | | catch (Exception e) |
| | 71 | | { |
| 0 | 72 | | scope.Failed(e); |
| 0 | 73 | | throw; |
| | 74 | | } |
| 2 | 75 | | } |
| | 76 | |
|
| | 77 | | /// <summary> List role assignments. </summary> |
| | 78 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 79 | | /// <param name="principalId"> Object ID of the AAD principal or security-group. </param> |
| | 80 | | /// <param name="continuationToken"> Continuation token. </param> |
| | 81 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 82 | | public virtual async Task<Response<IReadOnlyList<RoleAssignmentDetails>>> GetRoleAssignmentsAsync(string roleId |
| | 83 | | { |
| 4 | 84 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignments"); |
| 4 | 85 | | scope.Start(); |
| | 86 | | try |
| | 87 | | { |
| 4 | 88 | | return await RestClient.GetRoleAssignmentsAsync(roleId, principalId, continuationToken, cancellationToke |
| | 89 | | } |
| 0 | 90 | | catch (Exception e) |
| | 91 | | { |
| 0 | 92 | | scope.Failed(e); |
| 0 | 93 | | throw; |
| | 94 | | } |
| 4 | 95 | | } |
| | 96 | |
|
| | 97 | | /// <summary> List role assignments. </summary> |
| | 98 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 99 | | /// <param name="principalId"> Object ID of the AAD principal or security-group. </param> |
| | 100 | | /// <param name="continuationToken"> Continuation token. </param> |
| | 101 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 102 | | public virtual Response<IReadOnlyList<RoleAssignmentDetails>> GetRoleAssignments(string roleId = null, string pr |
| | 103 | | { |
| 4 | 104 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignments"); |
| 4 | 105 | | scope.Start(); |
| | 106 | | try |
| | 107 | | { |
| 4 | 108 | | return RestClient.GetRoleAssignments(roleId, principalId, continuationToken, cancellationToken); |
| | 109 | | } |
| 0 | 110 | | catch (Exception e) |
| | 111 | | { |
| 0 | 112 | | scope.Failed(e); |
| 0 | 113 | | throw; |
| | 114 | | } |
| 4 | 115 | | } |
| | 116 | |
|
| | 117 | | /// <summary> Get role assignment by role assignment Id. </summary> |
| | 118 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 119 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 120 | | public virtual async Task<Response<RoleAssignmentDetails>> GetRoleAssignmentByIdAsync(string roleAssignmentId, C |
| | 121 | | { |
| 30 | 122 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignmentById"); |
| 30 | 123 | | scope.Start(); |
| | 124 | | try |
| | 125 | | { |
| 30 | 126 | | return await RestClient.GetRoleAssignmentByIdAsync(roleAssignmentId, cancellationToken).ConfigureAwait(f |
| | 127 | | } |
| 0 | 128 | | catch (Exception e) |
| | 129 | | { |
| 0 | 130 | | scope.Failed(e); |
| 0 | 131 | | throw; |
| | 132 | | } |
| 30 | 133 | | } |
| | 134 | |
|
| | 135 | | /// <summary> Get role assignment by role assignment Id. </summary> |
| | 136 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 137 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 138 | | public virtual Response<RoleAssignmentDetails> GetRoleAssignmentById(string roleAssignmentId, CancellationToken |
| | 139 | | { |
| 30 | 140 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleAssignmentById"); |
| 30 | 141 | | scope.Start(); |
| | 142 | | try |
| | 143 | | { |
| 30 | 144 | | return RestClient.GetRoleAssignmentById(roleAssignmentId, cancellationToken); |
| | 145 | | } |
| 0 | 146 | | catch (Exception e) |
| | 147 | | { |
| 0 | 148 | | scope.Failed(e); |
| 0 | 149 | | throw; |
| | 150 | | } |
| 30 | 151 | | } |
| | 152 | |
|
| | 153 | | /// <summary> Delete role assignment by role assignment Id. </summary> |
| | 154 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 155 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 156 | | public virtual async Task<Response> DeleteRoleAssignmentByIdAsync(string roleAssignmentId, CancellationToken can |
| | 157 | | { |
| 2 | 158 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.DeleteRoleAssignmentById"); |
| 2 | 159 | | scope.Start(); |
| | 160 | | try |
| | 161 | | { |
| 2 | 162 | | return await RestClient.DeleteRoleAssignmentByIdAsync(roleAssignmentId, cancellationToken).ConfigureAwai |
| | 163 | | } |
| 0 | 164 | | catch (Exception e) |
| | 165 | | { |
| 0 | 166 | | scope.Failed(e); |
| 0 | 167 | | throw; |
| | 168 | | } |
| 2 | 169 | | } |
| | 170 | |
|
| | 171 | | /// <summary> Delete role assignment by role assignment Id. </summary> |
| | 172 | | /// <param name="roleAssignmentId"> The ID of the role assignment. </param> |
| | 173 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 174 | | public virtual Response DeleteRoleAssignmentById(string roleAssignmentId, CancellationToken cancellationToken = |
| | 175 | | { |
| 2 | 176 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.DeleteRoleAssignmentById"); |
| 2 | 177 | | scope.Start(); |
| | 178 | | try |
| | 179 | | { |
| 2 | 180 | | return RestClient.DeleteRoleAssignmentById(roleAssignmentId, cancellationToken); |
| | 181 | | } |
| 0 | 182 | | catch (Exception e) |
| | 183 | | { |
| 0 | 184 | | scope.Failed(e); |
| 0 | 185 | | throw; |
| | 186 | | } |
| 2 | 187 | | } |
| | 188 | |
|
| | 189 | | /// <summary> List role assignments of the caller. </summary> |
| | 190 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 191 | | public virtual async Task<Response<IReadOnlyList<string>>> GetCallerRoleAssignmentsAsync(CancellationToken cance |
| | 192 | | { |
| 2 | 193 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetCallerRoleAssignments"); |
| 2 | 194 | | scope.Start(); |
| | 195 | | try |
| | 196 | | { |
| 2 | 197 | | return await RestClient.GetCallerRoleAssignmentsAsync(cancellationToken).ConfigureAwait(false); |
| | 198 | | } |
| 0 | 199 | | catch (Exception e) |
| | 200 | | { |
| 0 | 201 | | scope.Failed(e); |
| 0 | 202 | | throw; |
| | 203 | | } |
| 2 | 204 | | } |
| | 205 | |
|
| | 206 | | /// <summary> List role assignments of the caller. </summary> |
| | 207 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 208 | | public virtual Response<IReadOnlyList<string>> GetCallerRoleAssignments(CancellationToken cancellationToken = de |
| | 209 | | { |
| 2 | 210 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetCallerRoleAssignments"); |
| 2 | 211 | | scope.Start(); |
| | 212 | | try |
| | 213 | | { |
| 2 | 214 | | return RestClient.GetCallerRoleAssignments(cancellationToken); |
| | 215 | | } |
| 0 | 216 | | catch (Exception e) |
| | 217 | | { |
| 0 | 218 | | scope.Failed(e); |
| 0 | 219 | | throw; |
| | 220 | | } |
| 2 | 221 | | } |
| | 222 | |
|
| | 223 | | /// <summary> Get role by role Id. </summary> |
| | 224 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 225 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 226 | | public virtual async Task<Response<SynapseRole>> GetRoleDefinitionByIdAsync(string roleId, CancellationToken can |
| | 227 | | { |
| 6 | 228 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitionById"); |
| 6 | 229 | | scope.Start(); |
| | 230 | | try |
| | 231 | | { |
| 6 | 232 | | return await RestClient.GetRoleDefinitionByIdAsync(roleId, cancellationToken).ConfigureAwait(false); |
| | 233 | | } |
| 0 | 234 | | catch (Exception e) |
| | 235 | | { |
| 0 | 236 | | scope.Failed(e); |
| 0 | 237 | | throw; |
| | 238 | | } |
| 6 | 239 | | } |
| | 240 | |
|
| | 241 | | /// <summary> Get role by role Id. </summary> |
| | 242 | | /// <param name="roleId"> Synapse Built-In Role Id. </param> |
| | 243 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 244 | | public virtual Response<SynapseRole> GetRoleDefinitionById(string roleId, CancellationToken cancellationToken = |
| | 245 | | { |
| 6 | 246 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitionById"); |
| 6 | 247 | | scope.Start(); |
| | 248 | | try |
| | 249 | | { |
| 6 | 250 | | return RestClient.GetRoleDefinitionById(roleId, cancellationToken); |
| | 251 | | } |
| 0 | 252 | | catch (Exception e) |
| | 253 | | { |
| 0 | 254 | | scope.Failed(e); |
| 0 | 255 | | throw; |
| | 256 | | } |
| 6 | 257 | | } |
| | 258 | |
|
| | 259 | | /// <summary> List roles. </summary> |
| | 260 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 261 | | public virtual AsyncPageable<SynapseRole> GetRoleDefinitionsAsync(CancellationToken cancellationToken = default) |
| | 262 | | { |
| | 263 | | async Task<Page<SynapseRole>> FirstPageFunc(int? pageSizeHint) |
| | 264 | | { |
| 4 | 265 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions"); |
| 4 | 266 | | scope.Start(); |
| | 267 | | try |
| | 268 | | { |
| 4 | 269 | | var response = await RestClient.GetRoleDefinitionsAsync(cancellationToken).ConfigureAwait(false); |
| 4 | 270 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 271 | | } |
| 0 | 272 | | catch (Exception e) |
| | 273 | | { |
| 0 | 274 | | scope.Failed(e); |
| 0 | 275 | | throw; |
| | 276 | | } |
| 4 | 277 | | } |
| | 278 | | async Task<Page<SynapseRole>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 279 | | { |
| 0 | 280 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions"); |
| 0 | 281 | | scope.Start(); |
| | 282 | | try |
| | 283 | | { |
| 0 | 284 | | var response = await RestClient.GetRoleDefinitionsNextPageAsync(nextLink, cancellationToken).Configu |
| 0 | 285 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 286 | | } |
| 0 | 287 | | catch (Exception e) |
| | 288 | | { |
| 0 | 289 | | scope.Failed(e); |
| 0 | 290 | | throw; |
| | 291 | | } |
| 0 | 292 | | } |
| 4 | 293 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 294 | | } |
| | 295 | |
|
| | 296 | | /// <summary> List roles. </summary> |
| | 297 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 298 | | public virtual Pageable<SynapseRole> GetRoleDefinitions(CancellationToken cancellationToken = default) |
| | 299 | | { |
| | 300 | | Page<SynapseRole> FirstPageFunc(int? pageSizeHint) |
| | 301 | | { |
| 4 | 302 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions"); |
| 4 | 303 | | scope.Start(); |
| | 304 | | try |
| | 305 | | { |
| 4 | 306 | | var response = RestClient.GetRoleDefinitions(cancellationToken); |
| 4 | 307 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 308 | | } |
| 0 | 309 | | catch (Exception e) |
| | 310 | | { |
| 0 | 311 | | scope.Failed(e); |
| 0 | 312 | | throw; |
| | 313 | | } |
| 4 | 314 | | } |
| | 315 | | Page<SynapseRole> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 316 | | { |
| 0 | 317 | | using var scope = _clientDiagnostics.CreateScope("AccessControlClient.GetRoleDefinitions"); |
| 0 | 318 | | scope.Start(); |
| | 319 | | try |
| | 320 | | { |
| 0 | 321 | | var response = RestClient.GetRoleDefinitionsNextPage(nextLink, cancellationToken); |
| 0 | 322 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 323 | | } |
| 0 | 324 | | catch (Exception e) |
| | 325 | | { |
| 0 | 326 | | scope.Failed(e); |
| 0 | 327 | | throw; |
| | 328 | | } |
| 0 | 329 | | } |
| 4 | 330 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 331 | | } |
| | 332 | | } |
| | 333 | | } |