Skip to content

Commit fea4bb8

Browse files
committed
Merge pull request Azure#2155 from solankisamir/sasolank_updatepowershell
added cmdlets for logger, properties, git and openIdConnect
2 parents 5abe25e + f4959f0 commit fea4bb8

File tree

115 files changed

+26576
-15719
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

115 files changed

+26576
-15719
lines changed

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/ApiManagementClient.cs

Lines changed: 450 additions & 2 deletions
Large diffs are not rendered by default.

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands.ApiManagement.ServiceManagement.csproj

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
</Reference>
6969
<Reference Include="Microsoft.Azure.Management.ApiManagement, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7070
<SpecificVersion>False</SpecificVersion>
71-
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ApiManagement.2.0.1-preview\lib\net40\Microsoft.Azure.Management.ApiManagement.dll</HintPath>
71+
<HintPath>..\..\..\packages\Microsoft.Azure.Management.ApiManagement.2.0.2-preview\lib\net40\Microsoft.Azure.Management.ApiManagement.dll</HintPath>
7272
</Reference>
7373
<Reference Include="Microsoft.Azure.ResourceManager, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
7474
<SpecificVersion>False</SpecificVersion>
@@ -150,49 +150,76 @@
150150
<Compile Include="Commands\GetAzureApiManagementAuthorizationServer.cs" />
151151
<Compile Include="Commands\GetAzureApiManagementCertificate.cs" />
152152
<Compile Include="Commands\GetAzureApiManagementGroup.cs" />
153+
<Compile Include="Commands\GetAzureApiManagementLogger.cs" />
154+
<Compile Include="Commands\GetAzureApiManagementOpenIdConnectProvider.cs" />
153155
<Compile Include="Commands\GetAzureApiManagementOperation.cs" />
154156
<Compile Include="Commands\GetAzureApiManagementPolicy.cs" />
155157
<Compile Include="Commands\GetAzureApiManagementProduct.cs" />
158+
<Compile Include="Commands\GetAzureApiManagementProperty.cs" />
156159
<Compile Include="Commands\GetAzureApiManagementSubscription.cs" />
160+
<Compile Include="Commands\GetAzureApiManagementTenantSyncState.cs" />
157161
<Compile Include="Commands\GetAzureApiManagementUser.cs" />
158162
<Compile Include="Commands\GetAzureApiManagementUserSsoUrl.cs" />
163+
<Compile Include="Commands\GetAzureRmApiManagementTenantGitAccess.cs" />
159164
<Compile Include="Commands\ImportAzureApiManagementApi.cs" />
160165
<Compile Include="Commands\NewAzureApiManagementApi.cs" />
161166
<Compile Include="Commands\NewAzureApiManagementAuthorizationServer.cs" />
162167
<Compile Include="Commands\NewAzureApiManagementCertificate.cs" />
163168
<Compile Include="Commands\NewAzureApiManagementContext.cs" />
164169
<Compile Include="Commands\NewAzureApiManagementGroup.cs" />
170+
<Compile Include="Commands\NewAzureApiManagementLogger.cs" />
171+
<Compile Include="Commands\NewAzureApiManagementOpenIdConnectProvider.cs" />
165172
<Compile Include="Commands\NewAzureApiManagementOperation.cs" />
166173
<Compile Include="Commands\NewAzureApiManagementProduct.cs" />
167174
<Compile Include="Commands\NewAzureApiManagementSubscription.cs" />
168175
<Compile Include="Commands\NewAzureApiManagementUser.cs" />
176+
<Compile Include="Commands\NewAzureApiManagmentProperty.cs" />
177+
<Compile Include="Commands\PublishAzureApiManagementTenantConfiguration.cs" />
169178
<Compile Include="Commands\RemoveAzureApiManagementApi.cs" />
170179
<Compile Include="Commands\RemoveAzureApiManagementApiFromProduct.cs" />
171180
<Compile Include="Commands\RemoveAzureApiManagementAuthorizationServer.cs" />
172181
<Compile Include="Commands\RemoveAzureApiManagementCertificate.cs" />
173182
<Compile Include="Commands\RemoveAzureApiManagementGroup.cs" />
183+
<Compile Include="Commands\RemoveAzureApiManagementLogger.cs" />
184+
<Compile Include="Commands\RemoveAzureApiManagementOpenIdConnectProvider.cs" />
174185
<Compile Include="Commands\RemoveAzureApiManagementOperation.cs" />
175186
<Compile Include="Commands\RemoveAzureApiManagementPolicy.cs" />
176187
<Compile Include="Commands\RemoveAzureApiManagementProduct.cs" />
177188
<Compile Include="Commands\RemoveAzureApiManagementProductFromGroup.cs" />
189+
<Compile Include="Commands\RemoveAzureApiManagementProperty.cs" />
178190
<Compile Include="Commands\RemoveAzureApiManagementSubscription.cs" />
179191
<Compile Include="Commands\RemoveAzureApiManagementUser.cs" />
180192
<Compile Include="Commands\RemoveAzureApiManagementUserFromGroup.cs" />
193+
<Compile Include="Commands\SaveAzureApiManagementTenantConfiguration.cs" />
181194
<Compile Include="Commands\SetAzureApiManagementApi.cs" />
182195
<Compile Include="Commands\SetAzureApiManagementAuthorizationServer.cs" />
183196
<Compile Include="Commands\SetAzureApiManagementCertificate.cs" />
184197
<Compile Include="Commands\SetAzureApiManagementGroup.cs" />
198+
<Compile Include="Commands\SetAzureApiManagementLogger.cs" />
199+
<Compile Include="Commands\SetAzureApiManagementOpenIdConnectProvider.cs" />
185200
<Compile Include="Commands\SetAzureApiManagementOperation.cs" />
186201
<Compile Include="Commands\SetAzureApiManagementPolicy.cs" />
187202
<Compile Include="Commands\SetAzureApiManagementProduct.cs" />
203+
<Compile Include="Commands\SetAzureApiManagementProperty.cs" />
188204
<Compile Include="Commands\SetAzureApiManagementSubscription.cs" />
189205
<Compile Include="Commands\SetAzureApiManagementUser.cs" />
190-
<Compile Include="CommonConstants.cs" />
206+
<Compile Include="Commands\SetAzureRmApiManagementTenantGitAccess.cs" />
207+
<Compile Include="Constants.cs" />
208+
<Compile Include="Models\ErrorBody.cs" />
209+
<Compile Include="Models\ErrorField.cs" />
210+
<Compile Include="Models\PsApiManagementOperationResult.cs" />
211+
<Compile Include="Models\PsApiManagementTenantConfigurationSyncState.cs" />
212+
<Compile Include="Models\TenantConfigurationState.cs" />
213+
<Compile Include="Models\PsApiManagementAccessInformation.cs" />
191214
<Compile Include="Models\PsApiManagementAccessTokenSendingMethod.cs" />
192215
<Compile Include="Models\PsApiManagementApi.cs" />
193216
<Compile Include="Models\PsApiManagementApiFormat.cs" />
194217
<Compile Include="Models\PsApiManagementAuthorizationRequestMethod.cs" />
195218
<Compile Include="Models\PsApiManagementClientAuthenticationMethod.cs" />
219+
<Compile Include="Models\PsApiManagementLogger.cs" />
220+
<Compile Include="Models\PsApiManagementLoggerType.cs" />
221+
<Compile Include="Models\PsApiManagementOpenIdConnectProvider.cs" />
222+
<Compile Include="Models\PsApiManagementProperty.cs" />
196223
<Compile Include="Models\PsApiManagementResponse.cs" />
197224
<Compile Include="Models\PsApiManagementCertificate.cs" />
198225
<Compile Include="Models\PsApiManagementContext.cs" />
@@ -209,8 +236,10 @@
209236
<Compile Include="Models\PsApiManagementSchema.cs" />
210237
<Compile Include="Models\PsApiManagementSubscription.cs" />
211238
<Compile Include="Models\PsApiManagementSubscriptionState.cs" />
239+
<Compile Include="Models\PsApiManagementTenantConfiguration.cs" />
212240
<Compile Include="Models\PsApiManagementUser.cs" />
213241
<Compile Include="Models\PsApiManagementUserState.cs" />
242+
<Compile Include="Models\TenantConfigurationLongRunningOperation.cs" />
214243
<Compile Include="Properties\AssemblyInfo.cs" />
215244
<Compile Include="Properties\Resources.Designer.cs">
216245
<AutoGen>True</AutoGen>
@@ -222,6 +251,7 @@
222251
<EmbeddedResource Include="Properties\Resources.resx">
223252
<Generator>ResXFileCodeGenerator</Generator>
224253
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
254+
<SubType>Designer</SubType>
225255
</EmbeddedResource>
226256
</ItemGroup>
227257
<ItemGroup>

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/AddAzureApiManagementApiToProduct.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
// // Copyright (c) Microsoft. All rights reserved.// // Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0// // Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands{ using System; using System.Management.Automation; using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models; [Cmdlet(VerbsCommon.Add, "AzureRmApiManagementApiToProduct")] [OutputType(typeof(bool))] public class AddAzureApiManagementApiToProduct : AzureApiManagementCmdletBase { [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")] [ValidateNotNullOrEmpty] public PsApiManagementContext Context { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing Product to add API to. This parameter is required.")] [ValidateNotNullOrEmpty] public String ProductId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing APIs to be added to the product. This parameter is required.")] [ValidateNotNullOrEmpty] public String ApiId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")] public SwitchParameter PassThru { get; set; } public override void ExecuteApiManagementCmdlet() { Client.ApiAddToProduct(Context, ProductId, ApiId); if (PassThru) { WriteObject(true); } } }}
1+
// // Copyright (c) Microsoft. All rights reserved.// // Licensed under the Apache License, Version 2.0 (the "License");// you may not use this file except in compliance with the License.// You may obtain a copy of the License at// http://www.apache.org/licenses/LICENSE-2.0// // Unless required by applicable law or agreed to in writing, software// distributed under the License is distributed on an "AS IS" BASIS,// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.// See the License for the specific language governing permissions and// limitations under the License.namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands{ using System; using System.Management.Automation; using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models; [Cmdlet(VerbsCommon.Add, Constants.ApiManagementApiToProduct)] [OutputType(typeof(bool))] public class AddAzureApiManagementApiToProduct : AzureApiManagementCmdletBase { [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")] [ValidateNotNullOrEmpty] public PsApiManagementContext Context { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing Product to add API to. This parameter is required.")] [ValidateNotNullOrEmpty] public String ProductId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = true, HelpMessage = "Identifier of existing APIs to be added to the product. This parameter is required.")] [ValidateNotNullOrEmpty] public String ApiId { get; set; } [Parameter( ValueFromPipelineByPropertyName = true, Mandatory = false, HelpMessage = "If specified will write true in case operation succeeds. This parameter is optional. Default value is false.")] public SwitchParameter PassThru { get; set; } public override void ExecuteApiManagementCmdlet() { Client.ApiAddToProduct(Context, ProductId, ApiId); if (PassThru) { WriteObject(true); } } }}

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/AddAzureApiManagementProductToGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1818
using System.Management.Automation;
1919
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
2020

21-
[Cmdlet(VerbsCommon.Add, "AzureRmApiManagementProductToGroup")]
21+
[Cmdlet(VerbsCommon.Add, Constants.ApiManagementProductToGroup)]
2222
[OutputType(typeof(bool))]
2323
public class AddAzureApiManagementProductToGroup : AzureApiManagementCmdletBase
2424
{

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/AddAzureApiManagementUserToGroup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1818
using System.Management.Automation;
1919
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
2020

21-
[Cmdlet(VerbsCommon.Add, "AzureRmApiManagementUserToGroup")]
21+
[Cmdlet(VerbsCommon.Add, Constants.ApiManagementUserToGroup)]
2222
[OutputType(typeof(bool))]
2323
public class AddAzureApiManagementUserToGroup : AzureApiManagementCmdletBase
2424
{

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/AzureApiManagementCmdletBase.cs

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,20 @@
1313
// limitations under the License.
1414
//
1515

16+
1617
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1718
{
1819
using System;
1920
using System.Management.Automation;
2021
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement;
2122
using ResourceManager.Common;
2223
using Microsoft.WindowsAzure.Commands.Utilities.Common;
24+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
25+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Properties;
2326

2427
abstract public class AzureApiManagementCmdletBase : AzureRMCmdlet
2528
{
26-
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromMinutes(1);
29+
protected static TimeSpan LongRunningOperationDefaultTimeout = TimeSpan.FromSeconds(30);
2730

2831
private ApiManagementClient _client;
2932

@@ -65,5 +68,75 @@ protected virtual void HandleException(Exception ex)
6568
{
6669
WriteExceptionError(ex);
6770
}
71+
72+
protected void WriteProgress(TenantConfigurationLongRunningOperation operation)
73+
{
74+
WriteProgress(new ProgressRecord(0, operation.OperationName, operation.Status.ToString()));
75+
}
76+
77+
/// <summary>
78+
/// TODO: Revert to standard long running operation once /operationResults endpoint start returning
79+
/// 202 Code for not Completed Operation.
80+
/// </summary>
81+
/// <see cref="https://msdn.microsoft.com/en-us/library/azure/dn781420.aspx#GetOperation"/>
82+
protected TenantConfigurationLongRunningOperation WaitForOperationToComplete(TenantConfigurationLongRunningOperation longRunningOperation)
83+
{
84+
do
85+
{
86+
var retryAfter = longRunningOperation.RetryAfter == null || longRunningOperation.RetryAfter.Value < LongRunningOperationDefaultTimeout ?
87+
LongRunningOperationDefaultTimeout : longRunningOperation.RetryAfter.Value;
88+
89+
WriteProgress(longRunningOperation);
90+
91+
TestMockSupport.Delay(retryAfter);
92+
93+
// the operation link is present in the first call to Operation.
94+
// The next calls to /operationResults do not return Location header, hence preserving this value across calls
95+
// this is the service side bug.
96+
var operationStatusLink = longRunningOperation.OperationLink;
97+
98+
longRunningOperation = Client.GetLongRunningOperationStatus(longRunningOperation);
99+
longRunningOperation.OperationLink = operationStatusLink;
100+
101+
WriteVerboseWithTimestamp(Resources.VerboseGetOperationStateTimeoutMessage,
102+
longRunningOperation.OperationResult.State);
103+
} while (longRunningOperation.OperationResult.State == TenantConfigurationState.InProgress);
104+
105+
return longRunningOperation;
106+
}
107+
108+
protected void ExecuteTenantConfigurationLongRunningCmdletWrap(
109+
Func<TenantConfigurationLongRunningOperation> func,
110+
bool passThru = false,
111+
object passThruValue = null)
112+
{
113+
try
114+
{
115+
var longRunningOperation = func();
116+
117+
longRunningOperation = WaitForOperationToComplete(longRunningOperation);
118+
if (longRunningOperation.OperationResult.State != TenantConfigurationState.Succeeded)
119+
{
120+
var errorMessage = longRunningOperation.OperationResult.Error != null ?
121+
longRunningOperation.OperationResult.Error.Message
122+
: longRunningOperation.OperationName;
123+
124+
WriteErrorWithTimestamp(errorMessage);
125+
WriteObject(passThruValue ?? longRunningOperation.OperationResult);
126+
}
127+
else if (passThru)
128+
{
129+
WriteObject(passThruValue ?? longRunningOperation.OperationResult);
130+
}
131+
}
132+
catch (ArgumentException ex)
133+
{
134+
WriteError(new ErrorRecord(ex, string.Empty, ErrorCategory.InvalidArgument, null));
135+
}
136+
catch (Exception ex)
137+
{
138+
WriteExceptionError(ex);
139+
}
140+
}
68141
}
69142
}

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/ExportAzureApiManagementApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
2222
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
2323
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Properties;
2424

25-
[Cmdlet(VerbsData.Export, "AzureRmApiManagementApi", DefaultParameterSetName = ExportContentToPipeline)]
25+
[Cmdlet(VerbsData.Export, Constants.ApiManagementApi, DefaultParameterSetName = ExportContentToPipeline)]
2626
[OutputType(typeof(string))]
2727
public class ExportAzureApiManagementApi : AzureApiManagementCmdletBase
2828
{

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Commands/GetAzureApiManagementApi.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
1919
using System.Management.Automation;
2020
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
2121

22-
[Cmdlet(VerbsCommon.Get, "AzureRmApiManagementApi", DefaultParameterSetName = AllApis)]
23-
[OutputType(typeof(IList<PsApiManagementApi>))]
22+
[Cmdlet(VerbsCommon.Get, Constants.ApiManagementApi, DefaultParameterSetName = AllApis)]
23+
[OutputType(typeof(IList<PsApiManagementApi>), ParameterSetName = new [] { AllApis, FindByName, FindByProductId })]
24+
[OutputType(typeof(PsApiManagementApi), ParameterSetName = new[] { FindById })]
2425
public class GetAzureApiManagementApi : AzureApiManagementCmdletBase
2526
{
2627
private const string FindByProductId = "Find by product ID";

0 commit comments

Comments
 (0)