Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for response headers and status codes data in entities during update #485

Merged
merged 18 commits into from
May 30, 2019
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 16 additions & 0 deletions src/Microsoft.Graph/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,21 @@ public static class Url
/// </summary>
public const string SentItems = "SentItems";
}

/// <summary>
/// Constants used for HTTP property names
/// </summary>
public static class HttpPropertyNames
{
/// <summary>
/// The Response Headers string
/// </summary>
public const string ResponseHeaders = "responseHeaders";

/// <summary>
/// The Status Code string
/// </summary>
public const string StatusCode = "statusCode";
}
}
}
20 changes: 20 additions & 0 deletions src/Microsoft.Graph/Exceptions/GeneratedErrorConstants.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ------------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License. See License in the project root for license information.
// ------------------------------------------------------------------------------

namespace Microsoft.Graph
{
internal static class GeneratedErrorConstants
{
internal static class Codes
{
internal static string NotAllowed = "notAllowed";
}

internal static class Messages
{
internal static string ResponseObjectUsedForUpdate = "Do not use objects returned in a response for updating an object in Microsoft Graph. " +
"Create a new {0} object and only set the updated properties on it.";
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<ActivityHistoryItem> UpdateAsync(ActivityHist
/// </summary>
/// <param name="activityHistoryItemToUpdate">The ActivityHistoryItem to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated ActivityHistoryItem.</returns>
public async System.Threading.Tasks.Task<ActivityHistoryItem> UpdateAsync(ActivityHistoryItem activityHistoryItemToUpdate, CancellationToken cancellationToken)
{
if (activityHistoryItemToUpdate.AdditionalData != null)
{
if (activityHistoryItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
activityHistoryItemToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, activityHistoryItemToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<ActivityHistoryItem>(activityHistoryItemToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AdministrativeUnit> UpdateAsync(Administrativ
/// </summary>
/// <param name="administrativeUnitToUpdate">The AdministrativeUnit to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
MIchaelMainer marked this conversation as resolved.
Show resolved Hide resolved
/// <returns>The updated AdministrativeUnit.</returns>
public async System.Threading.Tasks.Task<AdministrativeUnit> UpdateAsync(AdministrativeUnit administrativeUnitToUpdate, CancellationToken cancellationToken)
{
if (administrativeUnitToUpdate.AdditionalData != null)
{
if (administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
administrativeUnitToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, administrativeUnitToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AdministrativeUnit>(administrativeUnitToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
14 changes: 14 additions & 0 deletions src/Microsoft.Graph/Requests/Generated/AlertRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<Alert> UpdateAsync(Alert alertToUpdate)
/// </summary>
/// <param name="alertToUpdate">The Alert to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated Alert.</returns>
public async System.Threading.Tasks.Task<Alert> UpdateAsync(Alert alertToUpdate, CancellationToken cancellationToken)
{
if (alertToUpdate.AdditionalData != null)
{
if (alertToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
alertToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, alertToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<Alert>(alertToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidCompliancePolicy> UpdateAsync(AndroidC
/// </summary>
/// <param name="androidCompliancePolicyToUpdate">The AndroidCompliancePolicy to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidCompliancePolicy.</returns>
public async System.Threading.Tasks.Task<AndroidCompliancePolicy> UpdateAsync(AndroidCompliancePolicy androidCompliancePolicyToUpdate, CancellationToken cancellationToken)
{
if (androidCompliancePolicyToUpdate.AdditionalData != null)
{
if (androidCompliancePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidCompliancePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidCompliancePolicyToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidCompliancePolicy>(androidCompliancePolicyToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidCustomConfiguration> UpdateAsync(Andro
/// </summary>
/// <param name="androidCustomConfigurationToUpdate">The AndroidCustomConfiguration to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidCustomConfiguration.</returns>
public async System.Threading.Tasks.Task<AndroidCustomConfiguration> UpdateAsync(AndroidCustomConfiguration androidCustomConfigurationToUpdate, CancellationToken cancellationToken)
{
if (androidCustomConfigurationToUpdate.AdditionalData != null)
{
if (androidCustomConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidCustomConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidCustomConfigurationToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidCustomConfiguration>(androidCustomConfigurationToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidGeneralDeviceConfiguration> UpdateAsyn
/// </summary>
/// <param name="androidGeneralDeviceConfigurationToUpdate">The AndroidGeneralDeviceConfiguration to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidGeneralDeviceConfiguration.</returns>
public async System.Threading.Tasks.Task<AndroidGeneralDeviceConfiguration> UpdateAsync(AndroidGeneralDeviceConfiguration androidGeneralDeviceConfigurationToUpdate, CancellationToken cancellationToken)
{
if (androidGeneralDeviceConfigurationToUpdate.AdditionalData != null)
{
if (androidGeneralDeviceConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidGeneralDeviceConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidGeneralDeviceConfigurationToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidGeneralDeviceConfiguration>(androidGeneralDeviceConfigurationToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
14 changes: 14 additions & 0 deletions src/Microsoft.Graph/Requests/Generated/AndroidLobAppRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidLobApp> UpdateAsync(AndroidLobApp andr
/// </summary>
/// <param name="androidLobAppToUpdate">The AndroidLobApp to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidLobApp.</returns>
public async System.Threading.Tasks.Task<AndroidLobApp> UpdateAsync(AndroidLobApp androidLobAppToUpdate, CancellationToken cancellationToken)
{
if (androidLobAppToUpdate.AdditionalData != null)
{
if (androidLobAppToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidLobAppToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidLobAppToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidLobApp>(androidLobAppToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidManagedAppProtection> UpdateAsync(Andr
/// </summary>
/// <param name="androidManagedAppProtectionToUpdate">The AndroidManagedAppProtection to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidManagedAppProtection.</returns>
public async System.Threading.Tasks.Task<AndroidManagedAppProtection> UpdateAsync(AndroidManagedAppProtection androidManagedAppProtectionToUpdate, CancellationToken cancellationToken)
{
if (androidManagedAppProtectionToUpdate.AdditionalData != null)
{
if (androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidManagedAppProtectionToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidManagedAppProtectionToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidManagedAppProtection>(androidManagedAppProtectionToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidManagedAppRegistration> UpdateAsync(An
/// </summary>
/// <param name="androidManagedAppRegistrationToUpdate">The AndroidManagedAppRegistration to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidManagedAppRegistration.</returns>
public async System.Threading.Tasks.Task<AndroidManagedAppRegistration> UpdateAsync(AndroidManagedAppRegistration androidManagedAppRegistrationToUpdate, CancellationToken cancellationToken)
{
if (androidManagedAppRegistrationToUpdate.AdditionalData != null)
{
if (androidManagedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidManagedAppRegistrationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidManagedAppRegistrationToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidManagedAppRegistration>(androidManagedAppRegistrationToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidStoreApp> UpdateAsync(AndroidStoreApp
/// </summary>
/// <param name="androidStoreAppToUpdate">The AndroidStoreApp to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidStoreApp.</returns>
public async System.Threading.Tasks.Task<AndroidStoreApp> UpdateAsync(AndroidStoreApp androidStoreAppToUpdate, CancellationToken cancellationToken)
{
if (androidStoreAppToUpdate.AdditionalData != null)
{
if (androidStoreAppToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidStoreAppToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidStoreAppToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidStoreApp>(androidStoreAppToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidWorkProfileCompliancePolicy> UpdateAsy
/// </summary>
/// <param name="androidWorkProfileCompliancePolicyToUpdate">The AndroidWorkProfileCompliancePolicy to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidWorkProfileCompliancePolicy.</returns>
public async System.Threading.Tasks.Task<AndroidWorkProfileCompliancePolicy> UpdateAsync(AndroidWorkProfileCompliancePolicy androidWorkProfileCompliancePolicyToUpdate, CancellationToken cancellationToken)
{
if (androidWorkProfileCompliancePolicyToUpdate.AdditionalData != null)
{
if (androidWorkProfileCompliancePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidWorkProfileCompliancePolicyToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidWorkProfileCompliancePolicyToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidWorkProfileCompliancePolicy>(androidWorkProfileCompliancePolicyToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,23 @@ public System.Threading.Tasks.Task<AndroidWorkProfileCustomConfiguration> Update
/// </summary>
/// <param name="androidWorkProfileCustomConfigurationToUpdate">The AndroidWorkProfileCustomConfiguration to update.</param>
/// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param>
/// <exception cref="ClientException">Thrown when an object returned in a response is used for updating an object in Microsoft Graph.</exception>
/// <returns>The updated AndroidWorkProfileCustomConfiguration.</returns>
public async System.Threading.Tasks.Task<AndroidWorkProfileCustomConfiguration> UpdateAsync(AndroidWorkProfileCustomConfiguration androidWorkProfileCustomConfigurationToUpdate, CancellationToken cancellationToken)
{
if (androidWorkProfileCustomConfigurationToUpdate.AdditionalData != null)
{
if (androidWorkProfileCustomConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.ResponseHeaders) ||
androidWorkProfileCustomConfigurationToUpdate.AdditionalData.ContainsKey(Constants.HttpPropertyNames.StatusCode))
{
throw new ClientException(
new Error
{
Code = GeneratedErrorConstants.Codes.NotAllowed,
Message = String.Format(GeneratedErrorConstants.Messages.ResponseObjectUsedForUpdate, androidWorkProfileCustomConfigurationToUpdate.GetType().Name)
});
}
}
this.ContentType = "application/json";
this.Method = "PATCH";
var updatedEntity = await this.SendAsync<AndroidWorkProfileCustomConfiguration>(androidWorkProfileCustomConfigurationToUpdate, cancellationToken).ConfigureAwait(false);
Expand Down
Loading