|
| 1 | +using Microsoft.Graph.Models.ODataErrors; |
| 2 | +using Microsoft.Kiota.Abstractions; |
| 3 | +using Microsoft.Kiota.Abstractions.Serialization; |
| 4 | +using System; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.IO; |
| 7 | +using System.Linq; |
| 8 | +using System.Threading; |
| 9 | +using System.Threading.Tasks; |
| 10 | +namespace Microsoft.Graph.Contracts.Delta { |
| 11 | + /// <summary> |
| 12 | + /// Provides operations to call the delta method. |
| 13 | + /// </summary> |
| 14 | + public class DeltaRequestBuilder { |
| 15 | + /// <summary>Path parameters for the request</summary> |
| 16 | + private Dictionary<string, object> PathParameters { get; set; } |
| 17 | + /// <summary>The request adapter to use to execute the requests.</summary> |
| 18 | + private IRequestAdapter RequestAdapter { get; set; } |
| 19 | + /// <summary>Url template to use to build the URL for the current request builder</summary> |
| 20 | + private string UrlTemplate { get; set; } |
| 21 | + /// <summary> |
| 22 | + /// Instantiates a new DeltaRequestBuilder and sets the default values. |
| 23 | + /// </summary> |
| 24 | + /// <param name="pathParameters">Path parameters for the request</param> |
| 25 | + /// <param name="requestAdapter">The request adapter to use to execute the requests.</param> |
| 26 | + public DeltaRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) { |
| 27 | + _ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters)); |
| 28 | + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); |
| 29 | + UrlTemplate = "{+baseurl}/contracts/delta(){?%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}"; |
| 30 | + var urlTplParams = new Dictionary<string, object>(pathParameters); |
| 31 | + PathParameters = urlTplParams; |
| 32 | + RequestAdapter = requestAdapter; |
| 33 | + } |
| 34 | + /// <summary> |
| 35 | + /// Instantiates a new DeltaRequestBuilder and sets the default values. |
| 36 | + /// </summary> |
| 37 | + /// <param name="rawUrl">The raw URL to use for the request builder.</param> |
| 38 | + /// <param name="requestAdapter">The request adapter to use to execute the requests.</param> |
| 39 | + public DeltaRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) { |
| 40 | + if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl)); |
| 41 | + _ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter)); |
| 42 | + UrlTemplate = "{+baseurl}/contracts/delta(){?%24top,%24skip,%24search,%24filter,%24count,%24select,%24orderby}"; |
| 43 | + var urlTplParams = new Dictionary<string, object>(); |
| 44 | + if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl); |
| 45 | + PathParameters = urlTplParams; |
| 46 | + RequestAdapter = requestAdapter; |
| 47 | + } |
| 48 | + /// <summary> |
| 49 | + /// Invoke function delta |
| 50 | + /// </summary> |
| 51 | + /// <param name="cancellationToken">Cancellation token to use when cancelling requests</param> |
| 52 | + /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> |
| 53 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 54 | +#nullable enable |
| 55 | + public async Task<DeltaResponse?> GetAsync(Action<DeltaRequestBuilderGetRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) { |
| 56 | +#nullable restore |
| 57 | +#else |
| 58 | + public async Task<DeltaResponse> GetAsync(Action<DeltaRequestBuilderGetRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) { |
| 59 | +#endif |
| 60 | + var requestInfo = ToGetRequestInformation(requestConfiguration); |
| 61 | + var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> { |
| 62 | + {"4XX", ODataError.CreateFromDiscriminatorValue}, |
| 63 | + {"5XX", ODataError.CreateFromDiscriminatorValue}, |
| 64 | + }; |
| 65 | + return await RequestAdapter.SendAsync<DeltaResponse>(requestInfo, DeltaResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken); |
| 66 | + } |
| 67 | + /// <summary> |
| 68 | + /// Invoke function delta |
| 69 | + /// </summary> |
| 70 | + /// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param> |
| 71 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 72 | +#nullable enable |
| 73 | + public RequestInformation ToGetRequestInformation(Action<DeltaRequestBuilderGetRequestConfiguration>? requestConfiguration = default) { |
| 74 | +#nullable restore |
| 75 | +#else |
| 76 | + public RequestInformation ToGetRequestInformation(Action<DeltaRequestBuilderGetRequestConfiguration> requestConfiguration = default) { |
| 77 | +#endif |
| 78 | + var requestInfo = new RequestInformation { |
| 79 | + HttpMethod = Method.GET, |
| 80 | + UrlTemplate = UrlTemplate, |
| 81 | + PathParameters = PathParameters, |
| 82 | + }; |
| 83 | + requestInfo.Headers.Add("Accept", "application/json"); |
| 84 | + if (requestConfiguration != null) { |
| 85 | + var requestConfig = new DeltaRequestBuilderGetRequestConfiguration(); |
| 86 | + requestConfiguration.Invoke(requestConfig); |
| 87 | + requestInfo.AddQueryParameters(requestConfig.QueryParameters); |
| 88 | + requestInfo.AddRequestOptions(requestConfig.Options); |
| 89 | + requestInfo.AddHeaders(requestConfig.Headers); |
| 90 | + } |
| 91 | + return requestInfo; |
| 92 | + } |
| 93 | + /// <summary> |
| 94 | + /// Invoke function delta |
| 95 | + /// </summary> |
| 96 | + public class DeltaRequestBuilderGetQueryParameters { |
| 97 | + /// <summary>Include count of items</summary> |
| 98 | + [QueryParameter("%24count")] |
| 99 | + public bool? Count { get; set; } |
| 100 | + /// <summary>Filter items by property values</summary> |
| 101 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 102 | +#nullable enable |
| 103 | + [QueryParameter("%24filter")] |
| 104 | + public string? Filter { get; set; } |
| 105 | +#nullable restore |
| 106 | +#else |
| 107 | + [QueryParameter("%24filter")] |
| 108 | + public string Filter { get; set; } |
| 109 | +#endif |
| 110 | + /// <summary>Order items by property values</summary> |
| 111 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 112 | +#nullable enable |
| 113 | + [QueryParameter("%24orderby")] |
| 114 | + public string[]? Orderby { get; set; } |
| 115 | +#nullable restore |
| 116 | +#else |
| 117 | + [QueryParameter("%24orderby")] |
| 118 | + public string[] Orderby { get; set; } |
| 119 | +#endif |
| 120 | + /// <summary>Search items by search phrases</summary> |
| 121 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 122 | +#nullable enable |
| 123 | + [QueryParameter("%24search")] |
| 124 | + public string? Search { get; set; } |
| 125 | +#nullable restore |
| 126 | +#else |
| 127 | + [QueryParameter("%24search")] |
| 128 | + public string Search { get; set; } |
| 129 | +#endif |
| 130 | + /// <summary>Select properties to be returned</summary> |
| 131 | +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER |
| 132 | +#nullable enable |
| 133 | + [QueryParameter("%24select")] |
| 134 | + public string[]? Select { get; set; } |
| 135 | +#nullable restore |
| 136 | +#else |
| 137 | + [QueryParameter("%24select")] |
| 138 | + public string[] Select { get; set; } |
| 139 | +#endif |
| 140 | + /// <summary>Skip the first n items</summary> |
| 141 | + [QueryParameter("%24skip")] |
| 142 | + public int? Skip { get; set; } |
| 143 | + /// <summary>Show only the first n items</summary> |
| 144 | + [QueryParameter("%24top")] |
| 145 | + public int? Top { get; set; } |
| 146 | + } |
| 147 | + /// <summary> |
| 148 | + /// Configuration for the request such as headers, query parameters, and middleware options. |
| 149 | + /// </summary> |
| 150 | + public class DeltaRequestBuilderGetRequestConfiguration { |
| 151 | + /// <summary>Request headers</summary> |
| 152 | + public RequestHeaders Headers { get; set; } |
| 153 | + /// <summary>Request options</summary> |
| 154 | + public IList<IRequestOption> Options { get; set; } |
| 155 | + /// <summary>Request query parameters</summary> |
| 156 | + public DeltaRequestBuilderGetQueryParameters QueryParameters { get; set; } = new DeltaRequestBuilderGetQueryParameters(); |
| 157 | + /// <summary> |
| 158 | + /// Instantiates a new deltaRequestBuilderGetRequestConfiguration and sets the default values. |
| 159 | + /// </summary> |
| 160 | + public DeltaRequestBuilderGetRequestConfiguration() { |
| 161 | + Options = new List<IRequestOption>(); |
| 162 | + Headers = new RequestHeaders(); |
| 163 | + } |
| 164 | + } |
| 165 | + } |
| 166 | +} |
0 commit comments