| | 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.Core; |
| | 13 | | using Azure.Core.Pipeline; |
| | 14 | | using Azure.ResourceManager.Storage.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.Storage |
| | 17 | | { |
| | 18 | | /// <summary> The EncryptionScopes service client. </summary> |
| | 19 | | public partial class EncryptionScopesOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 24 | 23 | | internal EncryptionScopesRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of EncryptionScopesOperations for mocking. </summary> |
| 240 | 25 | | protected EncryptionScopesOperations() |
| | 26 | | { |
| 240 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of EncryptionScopesOperations. </summary> |
| | 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="subscriptionId"> The ID of the target subscription. </param> |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| | 33 | | /// <param name="apiVersion"> Api Version. </param> |
| 240 | 34 | | internal EncryptionScopesOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscript |
| | 35 | | { |
| 240 | 36 | | RestClient = new EncryptionScopesRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint, apiVe |
| 240 | 37 | | _clientDiagnostics = clientDiagnostics; |
| 240 | 38 | | _pipeline = pipeline; |
| 240 | 39 | | } |
| | 40 | |
|
| | 41 | | /// <summary> Synchronously creates or updates an encryption scope under the specified storage account. If an en |
| | 42 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 43 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 44 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 45 | | /// <param name="encryptionScope"> Encryption scope properties to be used for the create or update. </param> |
| | 46 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 47 | | public virtual async Task<Response<EncryptionScope>> PutAsync(string resourceGroupName, string accountName, stri |
| | 48 | | { |
| 6 | 49 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Put"); |
| 6 | 50 | | scope.Start(); |
| | 51 | | try |
| | 52 | | { |
| 6 | 53 | | return await RestClient.PutAsync(resourceGroupName, accountName, encryptionScopeName, encryptionScope, c |
| | 54 | | } |
| 0 | 55 | | catch (Exception e) |
| | 56 | | { |
| 0 | 57 | | scope.Failed(e); |
| 0 | 58 | | throw; |
| | 59 | | } |
| 6 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Synchronously creates or updates an encryption scope under the specified storage account. If an en |
| | 63 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 64 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 65 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 66 | | /// <param name="encryptionScope"> Encryption scope properties to be used for the create or update. </param> |
| | 67 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 68 | | public virtual Response<EncryptionScope> Put(string resourceGroupName, string accountName, string encryptionScop |
| | 69 | | { |
| 6 | 70 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Put"); |
| 6 | 71 | | scope.Start(); |
| | 72 | | try |
| | 73 | | { |
| 6 | 74 | | return RestClient.Put(resourceGroupName, accountName, encryptionScopeName, encryptionScope, cancellation |
| | 75 | | } |
| 0 | 76 | | catch (Exception e) |
| | 77 | | { |
| 0 | 78 | | scope.Failed(e); |
| 0 | 79 | | throw; |
| | 80 | | } |
| 6 | 81 | | } |
| | 82 | |
|
| | 83 | | /// <summary> Update encryption scope properties as specified in the request body. Update fails if the specified |
| | 84 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 85 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 86 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 87 | | /// <param name="encryptionScope"> Encryption scope properties to be used for the update. </param> |
| | 88 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 89 | | public virtual async Task<Response<EncryptionScope>> PatchAsync(string resourceGroupName, string accountName, st |
| | 90 | | { |
| 2 | 91 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Patch"); |
| 2 | 92 | | scope.Start(); |
| | 93 | | try |
| | 94 | | { |
| 2 | 95 | | return await RestClient.PatchAsync(resourceGroupName, accountName, encryptionScopeName, encryptionScope, |
| | 96 | | } |
| 0 | 97 | | catch (Exception e) |
| | 98 | | { |
| 0 | 99 | | scope.Failed(e); |
| 0 | 100 | | throw; |
| | 101 | | } |
| 2 | 102 | | } |
| | 103 | |
|
| | 104 | | /// <summary> Update encryption scope properties as specified in the request body. Update fails if the specified |
| | 105 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 106 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 107 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 108 | | /// <param name="encryptionScope"> Encryption scope properties to be used for the update. </param> |
| | 109 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 110 | | public virtual Response<EncryptionScope> Patch(string resourceGroupName, string accountName, string encryptionSc |
| | 111 | | { |
| 2 | 112 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Patch"); |
| 2 | 113 | | scope.Start(); |
| | 114 | | try |
| | 115 | | { |
| 2 | 116 | | return RestClient.Patch(resourceGroupName, accountName, encryptionScopeName, encryptionScope, cancellati |
| | 117 | | } |
| 0 | 118 | | catch (Exception e) |
| | 119 | | { |
| 0 | 120 | | scope.Failed(e); |
| 0 | 121 | | throw; |
| | 122 | | } |
| 2 | 123 | | } |
| | 124 | |
|
| | 125 | | /// <summary> Returns the properties for the specified encryption scope. </summary> |
| | 126 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 127 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 128 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 129 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 130 | | public virtual async Task<Response<EncryptionScope>> GetAsync(string resourceGroupName, string accountName, stri |
| | 131 | | { |
| 2 | 132 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Get"); |
| 2 | 133 | | scope.Start(); |
| | 134 | | try |
| | 135 | | { |
| 2 | 136 | | return await RestClient.GetAsync(resourceGroupName, accountName, encryptionScopeName, cancellationToken) |
| | 137 | | } |
| 0 | 138 | | catch (Exception e) |
| | 139 | | { |
| 0 | 140 | | scope.Failed(e); |
| 0 | 141 | | throw; |
| | 142 | | } |
| 2 | 143 | | } |
| | 144 | |
|
| | 145 | | /// <summary> Returns the properties for the specified encryption scope. </summary> |
| | 146 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 147 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 148 | | /// <param name="encryptionScopeName"> The name of the encryption scope within the specified storage account. En |
| | 149 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 150 | | public virtual Response<EncryptionScope> Get(string resourceGroupName, string accountName, string encryptionScop |
| | 151 | | { |
| 2 | 152 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.Get"); |
| 2 | 153 | | scope.Start(); |
| | 154 | | try |
| | 155 | | { |
| 2 | 156 | | return RestClient.Get(resourceGroupName, accountName, encryptionScopeName, cancellationToken); |
| | 157 | | } |
| 0 | 158 | | catch (Exception e) |
| | 159 | | { |
| 0 | 160 | | scope.Failed(e); |
| 0 | 161 | | throw; |
| | 162 | | } |
| 2 | 163 | | } |
| | 164 | |
|
| | 165 | | /// <summary> Lists all the encryption scopes available under the specified storage account. </summary> |
| | 166 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 167 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 168 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 169 | | public virtual AsyncPageable<EncryptionScope> ListAsync(string resourceGroupName, string accountName, Cancellati |
| | 170 | | { |
| 2 | 171 | | if (resourceGroupName == null) |
| | 172 | | { |
| 0 | 173 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 174 | | } |
| 2 | 175 | | if (accountName == null) |
| | 176 | | { |
| 0 | 177 | | throw new ArgumentNullException(nameof(accountName)); |
| | 178 | | } |
| | 179 | |
|
| | 180 | | async Task<Page<EncryptionScope>> FirstPageFunc(int? pageSizeHint) |
| | 181 | | { |
| 2 | 182 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.List"); |
| 2 | 183 | | scope.Start(); |
| | 184 | | try |
| | 185 | | { |
| 2 | 186 | | var response = await RestClient.ListAsync(resourceGroupName, accountName, cancellationToken).Configu |
| 2 | 187 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 188 | | } |
| 0 | 189 | | catch (Exception e) |
| | 190 | | { |
| 0 | 191 | | scope.Failed(e); |
| 0 | 192 | | throw; |
| | 193 | | } |
| 2 | 194 | | } |
| | 195 | | async Task<Page<EncryptionScope>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 196 | | { |
| 0 | 197 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.List"); |
| 0 | 198 | | scope.Start(); |
| | 199 | | try |
| | 200 | | { |
| 0 | 201 | | var response = await RestClient.ListNextPageAsync(nextLink, resourceGroupName, accountName, cancella |
| 0 | 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 | | } |
| 0 | 209 | | } |
| 2 | 210 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 211 | | } |
| | 212 | |
|
| | 213 | | /// <summary> Lists all the encryption scopes available under the specified storage account. </summary> |
| | 214 | | /// <param name="resourceGroupName"> The name of the resource group within the user's subscription. The nam |
| | 215 | | /// <param name="accountName"> The name of the storage account within the specified resource group. Storage acco |
| | 216 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 217 | | public virtual Pageable<EncryptionScope> List(string resourceGroupName, string accountName, CancellationToken ca |
| | 218 | | { |
| 2 | 219 | | if (resourceGroupName == null) |
| | 220 | | { |
| 0 | 221 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 222 | | } |
| 2 | 223 | | if (accountName == null) |
| | 224 | | { |
| 0 | 225 | | throw new ArgumentNullException(nameof(accountName)); |
| | 226 | | } |
| | 227 | |
|
| | 228 | | Page<EncryptionScope> FirstPageFunc(int? pageSizeHint) |
| | 229 | | { |
| 2 | 230 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.List"); |
| 2 | 231 | | scope.Start(); |
| | 232 | | try |
| | 233 | | { |
| 2 | 234 | | var response = RestClient.List(resourceGroupName, accountName, cancellationToken); |
| 2 | 235 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 236 | | } |
| 0 | 237 | | catch (Exception e) |
| | 238 | | { |
| 0 | 239 | | scope.Failed(e); |
| 0 | 240 | | throw; |
| | 241 | | } |
| 2 | 242 | | } |
| | 243 | | Page<EncryptionScope> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 244 | | { |
| 0 | 245 | | using var scope = _clientDiagnostics.CreateScope("EncryptionScopesOperations.List"); |
| 0 | 246 | | scope.Start(); |
| | 247 | | try |
| | 248 | | { |
| 0 | 249 | | var response = RestClient.ListNextPage(nextLink, resourceGroupName, accountName, cancellationToken); |
| 0 | 250 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 251 | | } |
| 0 | 252 | | catch (Exception e) |
| | 253 | | { |
| 0 | 254 | | scope.Failed(e); |
| 0 | 255 | | throw; |
| | 256 | | } |
| 0 | 257 | | } |
| 2 | 258 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 259 | | } |
| | 260 | | } |
| | 261 | | } |