-
Notifications
You must be signed in to change notification settings - Fork 4k
added cmdlets for logger, properties, git and openIdConnect #2155
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
Changes from all commits
4d26435
6285407
a3a7818
945fefe
a47109a
a0307a7
f4959f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,17 +13,20 @@ | |
// limitations under the License. | ||
// | ||
|
||
|
||
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands | ||
{ | ||
using System; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement; | ||
using ResourceManager.Common; | ||
using Microsoft.WindowsAzure.Commands.Utilities.Common; | ||
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models; | ||
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Properties; | ||
|
||
abstract public class AzureApiManagementCmdletBase : AzureRMCmdlet | ||
{ | ||
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromMinutes(1); | ||
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromSeconds(30); | ||
|
||
private ApiManagementClient _client; | ||
|
||
|
@@ -65,5 +68,75 @@ protected virtual void HandleException(Exception ex) | |
{ | ||
WriteExceptionError(ex); | ||
} | ||
|
||
protected void WriteProgress(TenantConfigurationLongRunningOperation operation) | ||
{ | ||
WriteProgress(new ProgressRecord(0, operation.OperationName, operation.Status.ToString())); | ||
} | ||
|
||
/// <summary> | ||
/// TODO: Revert to standard long running operation once /operationResults endpoint start returning | ||
/// 202 Code for not Completed Operation. | ||
/// </summary> | ||
/// <see cref="https://msdn.microsoft.com/en-us/library/azure/dn781420.aspx#GetOperation"/> | ||
protected TenantConfigurationLongRunningOperation WaitForOperationToComplete(TenantConfigurationLongRunningOperation longRunningOperation) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WHy is this not using the standard long running operation code? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a bug and it will take 2 weeks to go out, found out during powershell testing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please provide a link to the bug. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Its a service side Code bug, I will add a TODO to revert to standard long running operation code |
||
{ | ||
do | ||
{ | ||
var retryAfter = longRunningOperation.RetryAfter == null || longRunningOperation.RetryAfter.Value < LongRunningOperationDefaultTimeout ? | ||
LongRunningOperationDefaultTimeout : longRunningOperation.RetryAfter.Value; | ||
|
||
WriteProgress(longRunningOperation); | ||
|
||
TestMockSupport.Delay(retryAfter); | ||
|
||
// the operation link is present in the first call to Operation. | ||
// The next calls to /operationResults do not return Location header, hence preserving this value across calls | ||
// this is the service side bug. | ||
var operationStatusLink = longRunningOperation.OperationLink; | ||
|
||
longRunningOperation = Client.GetLongRunningOperationStatus(longRunningOperation); | ||
longRunningOperation.OperationLink = operationStatusLink; | ||
|
||
WriteVerboseWithTimestamp(Resources.VerboseGetOperationStateTimeoutMessage, | ||
longRunningOperation.OperationResult.State); | ||
} while (longRunningOperation.OperationResult.State == TenantConfigurationState.InProgress); | ||
|
||
return longRunningOperation; | ||
} | ||
|
||
protected void ExecuteTenantConfigurationLongRunningCmdletWrap( | ||
Func<TenantConfigurationLongRunningOperation> func, | ||
bool passThru = false, | ||
object passThruValue = null) | ||
{ | ||
try | ||
{ | ||
var longRunningOperation = func(); | ||
|
||
longRunningOperation = WaitForOperationToComplete(longRunningOperation); | ||
if (longRunningOperation.OperationResult.State != TenantConfigurationState.Succeeded) | ||
{ | ||
var errorMessage = longRunningOperation.OperationResult.Error != null ? | ||
longRunningOperation.OperationResult.Error.Message | ||
: longRunningOperation.OperationName; | ||
|
||
WriteErrorWithTimestamp(errorMessage); | ||
WriteObject(passThruValue ?? longRunningOperation.OperationResult); | ||
} | ||
else if (passThru) | ||
{ | ||
WriteObject(passThruValue ?? longRunningOperation.OperationResult); | ||
} | ||
} | ||
catch (ArgumentException ex) | ||
{ | ||
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.InvalidArgument, null)); | ||
} | ||
catch (Exception ex) | ||
{ | ||
WriteExceptionError(ex); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this change