Skip to content

Commit d26a43c

Browse files
authored
Merge pull request #705 from microsoftgraph/dev
Release 3.0.10
2 parents a44c93c + b15d8fb commit d26a43c

File tree

12 files changed

+306
-1108
lines changed

12 files changed

+306
-1108
lines changed

.github/fabricbot.json

Lines changed: 0 additions & 1071 deletions
This file was deleted.
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
id:
2+
name: GitOps.PullRequestIssueManagement
3+
description: GitOps.PullRequestIssueManagement primitive
4+
owner:
5+
resource: repository
6+
disabled: false
7+
where:
8+
configuration:
9+
resourceManagementConfiguration:
10+
scheduledSearches:
11+
- description:
12+
frequencies:
13+
- hourly:
14+
hour: 1
15+
filters:
16+
- isIssue
17+
- isOpen
18+
- hasLabel:
19+
label: 'Needs: Author Feedback'
20+
- hasLabel:
21+
label: no-recent-activity
22+
- noActivitySince:
23+
days: 3
24+
- isNotLabeledWith:
25+
label: service bug
26+
actions:
27+
- closeIssue
28+
- description:
29+
frequencies:
30+
- hourly:
31+
hour: 1
32+
filters:
33+
- isIssue
34+
- isOpen
35+
- hasLabel:
36+
label: 'Needs: Author Feedback'
37+
- noActivitySince:
38+
days: 4
39+
- isNotLabeledWith:
40+
label: no-recent-activity
41+
actions:
42+
- addLabel:
43+
label: no-recent-activity
44+
- addReply:
45+
reply: This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for **4 days**. It will be closed if no further activity occurs **within 3 days of this comment**.
46+
- description:
47+
frequencies:
48+
- hourly:
49+
hour: 1
50+
filters:
51+
- isIssue
52+
- isOpen
53+
- hasLabel:
54+
label: duplicate
55+
- noActivitySince:
56+
days: 1
57+
actions:
58+
- addReply:
59+
reply: This issue has been marked as duplicate and has not had any activity for **1 day**. It will be closed for housekeeping purposes.
60+
- closeIssue
61+
eventResponderTasks:
62+
- if:
63+
- payloadType: Issue_Comment
64+
- isAction:
65+
action: Created
66+
- isActivitySender:
67+
issueAuthor: True
68+
- hasLabel:
69+
label: 'Needs: Author Feedback'
70+
then:
71+
- addLabel:
72+
label: 'Needs: Attention :wave:'
73+
- removeLabel:
74+
label: 'Needs: Author Feedback'
75+
description:
76+
- if:
77+
- payloadType: Issues
78+
- not:
79+
isAction:
80+
action: Closed
81+
- hasLabel:
82+
label: no-recent-activity
83+
then:
84+
- removeLabel:
85+
label: no-recent-activity
86+
description:
87+
- if:
88+
- payloadType: Issues
89+
- labelAdded:
90+
label: service bug
91+
then: []
92+
description:
93+
- if:
94+
- payloadType: Issue_Comment
95+
- activitySenderHasAssociation:
96+
association: Contributor
97+
- bodyContains:
98+
pattern: '?'
99+
isRegex: False
100+
- bodyContains:
101+
pattern: '@'
102+
isRegex: False
103+
then:
104+
- addLabel:
105+
label: 'Needs: Author Feedback'
106+
description:
107+
- if:
108+
- payloadType: Pull_Request
109+
- isAction:
110+
action: Opened
111+
then:
112+
- addCodeFlowLink
113+
description:
114+
onFailure:
115+
onSuccess:

.github/workflows/validatePullRequest.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
uses: actions/setup-java@v3
2727
with:
2828
distribution: 'microsoft'
29-
java-version: '11'
29+
java-version: '17'
3030

3131
- name: Initialize CodeQL
3232
uses: github/codeql-action/init@v2

src/Microsoft.Graph.Core/Microsoft.Graph.Core.csproj

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
<DelaySign>false</DelaySign>
2222
<AssemblyOriginatorKeyFile>35MSSharedLib1024.snk</AssemblyOriginatorKeyFile>
2323
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
24-
<VersionPrefix>3.0.9</VersionPrefix>
24+
<VersionPrefix>3.0.10</VersionPrefix>
2525
<VersionSuffix></VersionSuffix>
2626
<PackageReleaseNotes>
27-
- Fixes regression in url building when the httpClient base addresss is used.
27+
- Fixes a bug where BatchRequestContentCollection.NewBatchWithFailedRequests would fail when more than 20 requests had been sent.
2828
</PackageReleaseNotes>
2929
<PublishRepositoryUrl>true</PublishRepositoryUrl>
3030
<EmbedUntrackedSources>true</EmbedUntrackedSources>
@@ -56,14 +56,15 @@
5656
</ItemGroup>
5757
<ItemGroup>
5858
<PackageReference Include="System.Security.Claims" Version="4.3.0" />
59-
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.31.0" />
59+
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="6.32.1" />
6060
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
61-
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.1.4" />
61+
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.3.1" />
6262
<PackageReference Include="Microsoft.Kiota.Authentication.Azure" Version="1.0.3" />
63-
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.6" />
64-
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.0.1" />
63+
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.8" />
64+
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.0.3" />
6565
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.0.1" />
66-
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.0.5" />
66+
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.0.6" />
67+
<PackageReference Include="Microsoft.Kiota.Serialization.Multipart" Version="1.0.0" />
6768
</ItemGroup>
6869
<ItemGroup Condition=" '$(TargetFramework)' != 'netstandard2.0' ">
6970
<PackageReference Include="NETStandard.Library" Version="2.0.3" />

src/Microsoft.Graph.Core/Requests/Content/BatchRequestContent.cs

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ namespace Microsoft.Graph
99
using System.Collections.Generic;
1010
using System.IO;
1111
using System.Linq;
12+
using System.ComponentModel;
1213
using System.Net;
1314
using System.Net.Http;
1415
using System.Net.Http.Headers;
@@ -19,6 +20,7 @@ namespace Microsoft.Graph
1920
/// <summary>
2021
/// A <see cref="HttpContent"/> implementation to handle json batch requests.
2122
/// </summary>
23+
[EditorBrowsable(EditorBrowsableState.Never)]
2224
public class BatchRequestContent: HttpContent
2325
{
2426
/// <summary>
@@ -35,6 +37,7 @@ public class BatchRequestContent: HttpContent
3537
/// Constructs a new <see cref="BatchRequestContent"/>.
3638
/// </summary>
3739
/// <param name="baseClient">The <see cref="IBaseClient"/> for making requests</param>
40+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
3841
public BatchRequestContent(IBaseClient baseClient)
3942
:this(baseClient, new BatchRequestStep[] { })
4043
{
@@ -45,6 +48,7 @@ public BatchRequestContent(IBaseClient baseClient)
4548
/// </summary>
4649
/// <param name="baseClient">The <see cref="IBaseClient"/> for making requests</param>
4750
/// <param name="batchRequestSteps">A list of <see cref="BatchRequestStep"/> to add to the batch request content.</param>
51+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
4852
public BatchRequestContent(IBaseClient baseClient, params BatchRequestStep[] batchRequestSteps): this(baseClient?.RequestAdapter ?? throw new ArgumentNullException(nameof(baseClient)), batchRequestSteps)
4953
{
5054
}
@@ -54,6 +58,7 @@ public BatchRequestContent(IBaseClient baseClient)
5458
/// </summary>
5559
/// <param name="requestAdapter">The <see cref="IRequestAdapter"/> for making requests</param>
5660
/// <param name="batchRequestSteps">A list of <see cref="BatchRequestStep"/> to add to the batch request content.</param>
61+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
5762
public BatchRequestContent(IRequestAdapter requestAdapter, params BatchRequestStep[] batchRequestSteps)
5863
{
5964
if (batchRequestSteps == null)
@@ -83,6 +88,8 @@ public BatchRequestContent(IRequestAdapter requestAdapter, params BatchRequestSt
8388
/// </summary>
8489
/// <param name="batchRequestStep">A <see cref="BatchRequestStep"/> to add.</param>
8590
/// <returns>True or false based on addition or not addition of the provided <see cref="BatchRequestStep"/>. </returns>
91+
/// <exception cref="ArgumentException"> When the the request step contains a depends on to a request id that is not present.</exception>
92+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
8693
public bool AddBatchRequestStep(BatchRequestStep batchRequestStep)
8794
{
8895
if (batchRequestStep == null
@@ -92,7 +99,11 @@ public bool AddBatchRequestStep(BatchRequestStep batchRequestStep)
9299
{
93100
return false;
94101
}
95-
102+
// validate the depends on exists before adding it
103+
if(batchRequestStep.DependsOn != null && !ContainsCorrespondingRequestId(batchRequestStep.DependsOn))
104+
{
105+
throw new ArgumentException(ErrorConstants.Messages.InvalidDependsOnRequestId);
106+
}
96107
(BatchRequestSteps as IDictionary<string, BatchRequestStep>).Add(batchRequestStep.RequestId, batchRequestStep);
97108
return true;
98109
}
@@ -102,6 +113,7 @@ public bool AddBatchRequestStep(BatchRequestStep batchRequestStep)
102113
/// </summary>
103114
/// <param name="httpRequestMessage">A <see cref="HttpRequestMessage"/> to use to build a <see cref="BatchRequestStep"/> to add.</param>
104115
/// <returns>The requestId of the newly created <see cref="BatchRequestStep"/></returns>
116+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
105117
public string AddBatchRequestStep(HttpRequestMessage httpRequestMessage)
106118
{
107119
if (BatchRequestSteps.Count >= CoreConstants.BatchRequest.MaxNumberOfRequests)
@@ -118,6 +130,7 @@ public string AddBatchRequestStep(HttpRequestMessage httpRequestMessage)
118130
/// </summary>
119131
/// <param name="requestInformation">A <see cref="RequestInformation"/> to use to build a <see cref="BatchRequestStep"/> to add.</param>
120132
/// <returns>The requestId of the newly created <see cref="BatchRequestStep"/></returns>
133+
[Obsolete("Please use the BatchRequestContentCollection for making batch requests as it supports handling more than 20 requests and provides a similar API experience.")]
121134
public async Task<string> AddBatchRequestStepAsync(RequestInformation requestInformation)
122135
{
123136
if (BatchRequestSteps.Count >= CoreConstants.BatchRequest.MaxNumberOfRequests)
@@ -159,11 +172,15 @@ public bool RemoveBatchRequestStepWithId(string requestId)
159172
/// <returns>new <see cref="BatchRequestContent"/> with all failed requests.</returns>
160173
public BatchRequestContent NewBatchWithFailedRequests(Dictionary<string, HttpStatusCode> responseStatusCodes)
161174
{
175+
#pragma warning disable CS0618
162176
var request = new BatchRequestContent(this.RequestAdapter);
177+
#pragma warning restore CS0618
163178
foreach(var response in responseStatusCodes)
164179
{
165180
if (BatchRequestSteps.ContainsKey(response.Key) && !BatchResponseContent.IsSuccessStatusCode(response.Value)) {
181+
#pragma warning disable CS0618
166182
request.AddBatchRequestStep(BatchRequestSteps[response.Key]);
183+
#pragma warning restore CS0618
167184
}
168185
}
169186
return request;
@@ -256,13 +273,20 @@ private async Task WriteBatchRequestStepAsync(BatchRequestStep batchRequestStep,
256273
}
257274

258275
// write the content of the step if it has any
259-
if (batchRequestStep.Request != null && batchRequestStep.Request.Content != null)
276+
if (batchRequestStep.Request?.Content != null)
260277
{
261278
writer.WritePropertyName(CoreConstants.BatchRequest.Body);
262-
using (JsonDocument content = await GetRequestContentAsync(batchRequestStep.Request).ConfigureAwait(false))
279+
// allow for non json content by checking the header value
280+
var vendorSpecificContentType = batchRequestStep.Request.Content?.Headers?.ContentType?.MediaType?.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
281+
if (string.IsNullOrEmpty(vendorSpecificContentType) || vendorSpecificContentType.Equals(CoreConstants.MimeTypeNames.Application.Json, StringComparison.OrdinalIgnoreCase))
263282
{
283+
using JsonDocument content = await GetRequestContentAsync(batchRequestStep.Request).ConfigureAwait(false);
264284
content.WriteTo(writer);
265285
}
286+
else
287+
{
288+
writer.WriteStringValue(Convert.ToBase64String(await batchRequestStep.Request.Content.ReadAsByteArrayAsync()));
289+
}
266290
}
267291
writer.WriteEndObject();//close root object.
268292
}
@@ -285,7 +309,7 @@ private async Task<JsonDocument> GetRequestContentAsync(HttpRequestMessage reque
285309

286310
private string GetHeaderValuesAsString(IEnumerable<string> headerValues)
287311
{
288-
if (headerValues == null || headerValues.Count() == 0)
312+
if (headerValues == null || !headerValues.Any())
289313
return string.Empty;
290314

291315
StringBuilder builder = new StringBuilder();

src/Microsoft.Graph.Core/Requests/Content/BatchRequestContentCollection.cs

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
namespace Microsoft.Graph
1+
// ------------------------------------------------------------------------------
2+
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
3+
// ------------------------------------------------------------------------------
4+
5+
namespace Microsoft.Graph
26
{
37
using Microsoft.Kiota.Abstractions;
48
using System;
@@ -14,7 +18,7 @@
1418
public class BatchRequestContentCollection
1519
{
1620
private readonly IBaseClient baseClient;
17-
private readonly List<BatchRequestContent> batchRequests;
21+
private readonly HashSet<BatchRequestContent> batchRequests;
1822
private readonly int batchRequestLimit;
1923
private BatchRequestContent currentRequest;
2024
private bool readOnly = false;
@@ -35,18 +39,16 @@ public BatchRequestContentCollection(IBaseClient baseClient) : this (baseClient,
3539
/// <param name="batchRequestLimit">Number of requests that may be placed in a single batch</param>
3640
public BatchRequestContentCollection(IBaseClient baseClient, int batchRequestLimit)
3741
{
38-
if(baseClient == null)
39-
{
40-
throw new ArgumentNullException(nameof(baseClient));
41-
}
4242
if (batchRequestLimit < 2 || batchRequestLimit > CoreConstants.BatchRequest.MaxNumberOfRequests)
4343
{
4444
throw new ArgumentOutOfRangeException(nameof(batchRequestLimit));
4545
}
46-
this.baseClient = baseClient;
46+
this.baseClient = baseClient ?? throw new ArgumentNullException(nameof(baseClient));
4747
this.batchRequestLimit = batchRequestLimit;
48-
batchRequests = new List<BatchRequestContent>();
48+
batchRequests = new HashSet<BatchRequestContent>();
49+
#pragma warning disable CS0618
4950
currentRequest = new BatchRequestContent(baseClient);
51+
#pragma warning restore CS0618
5052
}
5153

5254
private void ValidateReadOnly()
@@ -63,10 +65,25 @@ private void SetupCurrentRequest()
6365
if (currentRequest.BatchRequestSteps.Count >= batchRequestLimit)
6466
{
6567
batchRequests.Add(currentRequest);
68+
#pragma warning disable CS0618
6669
currentRequest = new BatchRequestContent(baseClient);
70+
#pragma warning restore CS0618
6771
}
6872
}
6973

74+
/// <summary>
75+
/// Adds a <see cref="BatchRequestStep"/> to batch request content.
76+
/// </summary>
77+
/// <param name="batchRequestStep">A <see cref="BatchRequestStep"/> to add.</param>
78+
/// <returns>True or false based on addition or not addition of the provided <see cref="BatchRequestStep"/>. </returns>
79+
public bool AddBatchRequestStep(BatchRequestStep batchRequestStep)
80+
{
81+
SetupCurrentRequest();
82+
#pragma warning disable CS0618
83+
return currentRequest.AddBatchRequestStep(batchRequestStep);
84+
#pragma warning restore CS0618
85+
}
86+
7087
/// <summary>
7188
/// Adds a <see cref="HttpRequestMessage"/> to batch request content.
7289
/// </summary>
@@ -75,7 +92,9 @@ private void SetupCurrentRequest()
7592
public string AddBatchRequestStep(HttpRequestMessage httpRequestMessage)
7693
{
7794
SetupCurrentRequest();
95+
#pragma warning disable CS0618
7896
return currentRequest.AddBatchRequestStep(httpRequestMessage);
97+
#pragma warning restore CS0618
7998
}
8099

81100
/// <summary>
@@ -86,7 +105,9 @@ public string AddBatchRequestStep(HttpRequestMessage httpRequestMessage)
86105
public Task<string> AddBatchRequestStepAsync(RequestInformation requestInformation)
87106
{
88107
SetupCurrentRequest();
108+
#pragma warning disable CS0618
89109
return currentRequest.AddBatchRequestStepAsync(requestInformation);
110+
#pragma warning restore CS0618
90111
}
91112

92113
/// <summary>
@@ -100,9 +121,9 @@ public bool RemoveBatchRequestStepWithId(string requestId)
100121
var removed = currentRequest.RemoveBatchRequestStepWithId(requestId);
101122
if (!removed && batchRequests.Count > 0)
102123
{
103-
for (int i = 0; i < batchRequests.Count; i++)
124+
foreach (var batchRequest in batchRequests)
104125
{
105-
removed = batchRequests[i].RemoveBatchRequestStepWithId(requestId);
126+
removed = batchRequest.RemoveBatchRequestStepWithId(requestId);
106127
if (removed)
107128
{
108129
return true;
@@ -130,7 +151,10 @@ public IReadOnlyDictionary<string, BatchRequestStep> BatchRequestSteps { get
130151
{
131152
if (batchRequests.Count > 0)
132153
{
133-
IEnumerable<KeyValuePair<string, BatchRequestStep>> result = currentRequest.BatchRequestSteps;
154+
IEnumerable<KeyValuePair<string, BatchRequestStep>> result = batchRequests.Contains(currentRequest) ?
155+
new List<KeyValuePair<string, BatchRequestStep>>()
156+
: currentRequest.BatchRequestSteps;
157+
134158
foreach ( var request in batchRequests)
135159
{
136160
result = result.Concat(request.BatchRequestSteps);

0 commit comments

Comments
 (0)