| | 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.EventHubs.Models; |
| | 15 | |
|
| | 16 | | namespace Azure.ResourceManager.EventHubs |
| | 17 | | { |
| | 18 | | /// <summary> The ConsumerGroups service client. </summary> |
| | 19 | | public partial class ConsumerGroupsOperations |
| | 20 | | { |
| | 21 | | private readonly ClientDiagnostics _clientDiagnostics; |
| | 22 | | private readonly HttpPipeline _pipeline; |
| 100 | 23 | | internal ConsumerGroupsRestOperations RestClient { get; } |
| | 24 | | /// <summary> Initializes a new instance of ConsumerGroupsOperations for mocking. </summary> |
| 48 | 25 | | protected ConsumerGroupsOperations() |
| | 26 | | { |
| 48 | 27 | | } |
| | 28 | | /// <summary> Initializes a new instance of ConsumerGroupsOperations. </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"> Subscription credentials that uniquely identify a Microsoft Azure subscription |
| | 32 | | /// <param name="endpoint"> server parameter. </param> |
| 48 | 33 | | internal ConsumerGroupsOperations(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, string subscriptio |
| | 34 | | { |
| 48 | 35 | | RestClient = new ConsumerGroupsRestOperations(clientDiagnostics, pipeline, subscriptionId, endpoint); |
| 48 | 36 | | _clientDiagnostics = clientDiagnostics; |
| 48 | 37 | | _pipeline = pipeline; |
| 48 | 38 | | } |
| | 39 | |
|
| | 40 | | /// <summary> Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. </summary |
| | 41 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 42 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 43 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 44 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 45 | | /// <param name="parameters"> Parameters supplied to create or update a consumer group resource. </param> |
| | 46 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 47 | | public virtual async Task<Response<ConsumerGroup>> CreateOrUpdateAsync(string resourceGroupName, string namespac |
| | 48 | | { |
| 28 | 49 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.CreateOrUpdate"); |
| 28 | 50 | | scope.Start(); |
| | 51 | | try |
| | 52 | | { |
| 28 | 53 | | return await RestClient.CreateOrUpdateAsync(resourceGroupName, namespaceName, eventHubName, consumerGrou |
| | 54 | | } |
| 0 | 55 | | catch (Exception e) |
| | 56 | | { |
| 0 | 57 | | scope.Failed(e); |
| 0 | 58 | | throw; |
| | 59 | | } |
| 28 | 60 | | } |
| | 61 | |
|
| | 62 | | /// <summary> Creates or updates an Event Hubs consumer group as a nested resource within a Namespace. </summary |
| | 63 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 64 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 65 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 66 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 67 | | /// <param name="parameters"> Parameters supplied to create or update a consumer group resource. </param> |
| | 68 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 69 | | public virtual Response<ConsumerGroup> CreateOrUpdate(string resourceGroupName, string namespaceName, string eve |
| | 70 | | { |
| 28 | 71 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.CreateOrUpdate"); |
| 28 | 72 | | scope.Start(); |
| | 73 | | try |
| | 74 | | { |
| 28 | 75 | | return RestClient.CreateOrUpdate(resourceGroupName, namespaceName, eventHubName, consumerGroupName, para |
| | 76 | | } |
| 0 | 77 | | catch (Exception e) |
| | 78 | | { |
| 0 | 79 | | scope.Failed(e); |
| 0 | 80 | | throw; |
| | 81 | | } |
| 28 | 82 | | } |
| | 83 | |
|
| | 84 | | /// <summary> Deletes a consumer group from the specified Event Hub and resource group. </summary> |
| | 85 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 86 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 87 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 88 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 89 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 90 | | public virtual async Task<Response> DeleteAsync(string resourceGroupName, string namespaceName, string eventHubN |
| | 91 | | { |
| 4 | 92 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Delete"); |
| 4 | 93 | | scope.Start(); |
| | 94 | | try |
| | 95 | | { |
| 4 | 96 | | return await RestClient.DeleteAsync(resourceGroupName, namespaceName, eventHubName, consumerGroupName, c |
| | 97 | | } |
| 0 | 98 | | catch (Exception e) |
| | 99 | | { |
| 0 | 100 | | scope.Failed(e); |
| 0 | 101 | | throw; |
| | 102 | | } |
| 4 | 103 | | } |
| | 104 | |
|
| | 105 | | /// <summary> Deletes a consumer group from the specified Event Hub and resource group. </summary> |
| | 106 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 107 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 108 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 109 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 110 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 111 | | public virtual Response Delete(string resourceGroupName, string namespaceName, string eventHubName, string consu |
| | 112 | | { |
| 4 | 113 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Delete"); |
| 4 | 114 | | scope.Start(); |
| | 115 | | try |
| | 116 | | { |
| 4 | 117 | | return RestClient.Delete(resourceGroupName, namespaceName, eventHubName, consumerGroupName, cancellation |
| | 118 | | } |
| 0 | 119 | | catch (Exception e) |
| | 120 | | { |
| 0 | 121 | | scope.Failed(e); |
| 0 | 122 | | throw; |
| | 123 | | } |
| 4 | 124 | | } |
| | 125 | |
|
| | 126 | | /// <summary> Gets a description for the specified consumer group. </summary> |
| | 127 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 128 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 129 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 130 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 131 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 132 | | public virtual async Task<Response<ConsumerGroup>> GetAsync(string resourceGroupName, string namespaceName, stri |
| | 133 | | { |
| 8 | 134 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Get"); |
| 8 | 135 | | scope.Start(); |
| | 136 | | try |
| | 137 | | { |
| 8 | 138 | | return await RestClient.GetAsync(resourceGroupName, namespaceName, eventHubName, consumerGroupName, canc |
| | 139 | | } |
| 0 | 140 | | catch (Exception e) |
| | 141 | | { |
| 0 | 142 | | scope.Failed(e); |
| 0 | 143 | | throw; |
| | 144 | | } |
| 8 | 145 | | } |
| | 146 | |
|
| | 147 | | /// <summary> Gets a description for the specified consumer group. </summary> |
| | 148 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 149 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 150 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 151 | | /// <param name="consumerGroupName"> The consumer group name. </param> |
| | 152 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 153 | | public virtual Response<ConsumerGroup> Get(string resourceGroupName, string namespaceName, string eventHubName, |
| | 154 | | { |
| 8 | 155 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.Get"); |
| 8 | 156 | | scope.Start(); |
| | 157 | | try |
| | 158 | | { |
| 8 | 159 | | return RestClient.Get(resourceGroupName, namespaceName, eventHubName, consumerGroupName, cancellationTok |
| | 160 | | } |
| 0 | 161 | | catch (Exception e) |
| | 162 | | { |
| 0 | 163 | | scope.Failed(e); |
| 0 | 164 | | throw; |
| | 165 | | } |
| 8 | 166 | | } |
| | 167 | |
|
| | 168 | | /// <summary> Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists |
| | 169 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 170 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 171 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 172 | | /// <param name="skip"> Skip is only used if a previous operation returned a partial result. If a previous respo |
| | 173 | | /// <param name="top"> May be used to limit the number of results to the most recent N usageDetails. </param> |
| | 174 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 175 | | public virtual AsyncPageable<ConsumerGroup> ListByEventHubAsync(string resourceGroupName, string namespaceName, |
| | 176 | | { |
| 8 | 177 | | if (resourceGroupName == null) |
| | 178 | | { |
| 0 | 179 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 180 | | } |
| 8 | 181 | | if (namespaceName == null) |
| | 182 | | { |
| 0 | 183 | | throw new ArgumentNullException(nameof(namespaceName)); |
| | 184 | | } |
| 8 | 185 | | if (eventHubName == null) |
| | 186 | | { |
| 0 | 187 | | throw new ArgumentNullException(nameof(eventHubName)); |
| | 188 | | } |
| | 189 | |
|
| | 190 | | async Task<Page<ConsumerGroup>> FirstPageFunc(int? pageSizeHint) |
| | 191 | | { |
| 8 | 192 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub"); |
| 8 | 193 | | scope.Start(); |
| | 194 | | try |
| | 195 | | { |
| 8 | 196 | | var response = await RestClient.ListByEventHubAsync(resourceGroupName, namespaceName, eventHubName, |
| 8 | 197 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 198 | | } |
| 0 | 199 | | catch (Exception e) |
| | 200 | | { |
| 0 | 201 | | scope.Failed(e); |
| 0 | 202 | | throw; |
| | 203 | | } |
| 8 | 204 | | } |
| | 205 | | async Task<Page<ConsumerGroup>> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 206 | | { |
| 2 | 207 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub"); |
| 2 | 208 | | scope.Start(); |
| | 209 | | try |
| | 210 | | { |
| 2 | 211 | | var response = await RestClient.ListByEventHubNextPageAsync(nextLink, resourceGroupName, namespaceNa |
| 2 | 212 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 213 | | } |
| 0 | 214 | | catch (Exception e) |
| | 215 | | { |
| 0 | 216 | | scope.Failed(e); |
| 0 | 217 | | throw; |
| | 218 | | } |
| 2 | 219 | | } |
| 8 | 220 | | return PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc); |
| | 221 | | } |
| | 222 | |
|
| | 223 | | /// <summary> Gets all the consumer groups in a Namespace. An empty feed is returned if no consumer group exists |
| | 224 | | /// <param name="resourceGroupName"> Name of the resource group within the azure subscription. </param> |
| | 225 | | /// <param name="namespaceName"> The Namespace name. </param> |
| | 226 | | /// <param name="eventHubName"> The Event Hub name. </param> |
| | 227 | | /// <param name="skip"> Skip is only used if a previous operation returned a partial result. If a previous respo |
| | 228 | | /// <param name="top"> May be used to limit the number of results to the most recent N usageDetails. </param> |
| | 229 | | /// <param name="cancellationToken"> The cancellation token to use. </param> |
| | 230 | | public virtual Pageable<ConsumerGroup> ListByEventHub(string resourceGroupName, string namespaceName, string eve |
| | 231 | | { |
| 8 | 232 | | if (resourceGroupName == null) |
| | 233 | | { |
| 0 | 234 | | throw new ArgumentNullException(nameof(resourceGroupName)); |
| | 235 | | } |
| 8 | 236 | | if (namespaceName == null) |
| | 237 | | { |
| 0 | 238 | | throw new ArgumentNullException(nameof(namespaceName)); |
| | 239 | | } |
| 8 | 240 | | if (eventHubName == null) |
| | 241 | | { |
| 0 | 242 | | throw new ArgumentNullException(nameof(eventHubName)); |
| | 243 | | } |
| | 244 | |
|
| | 245 | | Page<ConsumerGroup> FirstPageFunc(int? pageSizeHint) |
| | 246 | | { |
| 8 | 247 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub"); |
| 8 | 248 | | scope.Start(); |
| | 249 | | try |
| | 250 | | { |
| 8 | 251 | | var response = RestClient.ListByEventHub(resourceGroupName, namespaceName, eventHubName, skip, top, |
| 8 | 252 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 253 | | } |
| 0 | 254 | | catch (Exception e) |
| | 255 | | { |
| 0 | 256 | | scope.Failed(e); |
| 0 | 257 | | throw; |
| | 258 | | } |
| 8 | 259 | | } |
| | 260 | | Page<ConsumerGroup> NextPageFunc(string nextLink, int? pageSizeHint) |
| | 261 | | { |
| 2 | 262 | | using var scope = _clientDiagnostics.CreateScope("ConsumerGroupsOperations.ListByEventHub"); |
| 2 | 263 | | scope.Start(); |
| | 264 | | try |
| | 265 | | { |
| 2 | 266 | | var response = RestClient.ListByEventHubNextPage(nextLink, resourceGroupName, namespaceName, eventHu |
| 2 | 267 | | return Page.FromValues(response.Value.Value, response.Value.NextLink, response.GetRawResponse()); |
| | 268 | | } |
| 0 | 269 | | catch (Exception e) |
| | 270 | | { |
| 0 | 271 | | scope.Failed(e); |
| 0 | 272 | | throw; |
| | 273 | | } |
| 2 | 274 | | } |
| 8 | 275 | | return PageableHelpers.CreateEnumerable(FirstPageFunc, NextPageFunc); |
| | 276 | | } |
| | 277 | | } |
| | 278 | | } |