Skip to content

Commit 76b81fe

Browse files
committed
Add Cmdlets for Tenant Access for Issue Azure#2200
Get-AzureRmApiManagementTenantAccess Set-AzureRmApiManagementTenantAccess
1 parent 3e9bd76 commit 76b81fe

File tree

9 files changed

+880
-0
lines changed

9 files changed

+880
-0
lines changed

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1739,5 +1739,27 @@ public PsApiManagementTenantConfigurationSyncState GetTenantConfigurationSyncSta
17391739
}
17401740

17411741
#endregion
1742+
1743+
#region TenantAccessInformation
1744+
public PsApiManagementAccessInformation GetTenantAccessInformation(PsApiManagementContext context)
1745+
{
1746+
var response = Client.TenantAccess.Get(
1747+
context.ResourceGroupName,
1748+
context.ServiceName);
1749+
1750+
return Mapper.Map<PsApiManagementAccessInformation>(response.Value);
1751+
}
1752+
1753+
public void TenantAccessSet(
1754+
PsApiManagementContext context,
1755+
bool enabledTenantAccess)
1756+
{
1757+
var accessInformationParams = new AccessInformationUpdateParameters
1758+
{
1759+
Enabled = enabledTenantAccess
1760+
};
1761+
Client.TenantAccess.Update(context.ResourceGroupName, context.ServiceName, accessInformationParams, "*");
1762+
}
1763+
#endregion
17421764
}
17431765
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@
160160
<Compile Include="Commands\GetAzureApiManagementTenantSyncState.cs" />
161161
<Compile Include="Commands\GetAzureApiManagementUser.cs" />
162162
<Compile Include="Commands\GetAzureApiManagementUserSsoUrl.cs" />
163+
<Compile Include="Commands\GetAzureRmApiManagementTenantAccess.cs" />
163164
<Compile Include="Commands\GetAzureRmApiManagementTenantGitAccess.cs" />
164165
<Compile Include="Commands\ImportAzureApiManagementApi.cs" />
165166
<Compile Include="Commands\NewAzureApiManagementApi.cs" />
@@ -203,6 +204,7 @@
203204
<Compile Include="Commands\SetAzureApiManagementProperty.cs" />
204205
<Compile Include="Commands\SetAzureApiManagementSubscription.cs" />
205206
<Compile Include="Commands\SetAzureApiManagementUser.cs" />
207+
<Compile Include="Commands\SetAzureRmApiManagementTenantAccess.cs" />
206208
<Compile Include="Commands\SetAzureRmApiManagementTenantGitAccess.cs" />
207209
<Compile Include="Constants.cs" />
208210
<Compile Include="Models\ErrorBody.cs" />
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
16+
{
17+
using System.Management.Automation;
18+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
19+
20+
[Cmdlet(VerbsCommon.Get, Constants.ApiManagementTenantAccess)]
21+
[OutputType(typeof(PsApiManagementAccessInformation))]
22+
public class GetAzureRmApiManagementTenantAccess : AzureApiManagementCmdletBase
23+
{
24+
[Parameter(
25+
ValueFromPipelineByPropertyName = true,
26+
Mandatory = true,
27+
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
28+
[ValidateNotNullOrEmpty]
29+
public PsApiManagementContext Context { get; set; }
30+
31+
public override void ExecuteApiManagementCmdlet()
32+
{
33+
WriteObject(Client.GetTenantAccessInformation(Context));
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
//
2+
// Copyright (c) Microsoft. All rights reserved.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
namespace Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Commands
16+
{
17+
using System.Management.Automation;
18+
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;
19+
20+
[Cmdlet(VerbsCommon.Set, Constants.ApiManagementTenantAccess)]
21+
[OutputType(typeof(PsApiManagementAccessInformation))]
22+
public class SetAzureRmApiManagementTenantAccess : AzureApiManagementCmdletBase
23+
{
24+
[Parameter(
25+
ValueFromPipelineByPropertyName = true,
26+
Mandatory = true,
27+
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
28+
[ValidateNotNullOrEmpty]
29+
public PsApiManagementContext Context { get; set; }
30+
31+
[Parameter(
32+
ValueFromPipelineByPropertyName = false,
33+
Mandatory = true,
34+
HelpMessage = "Enable Tenant access. Set to true for enabling and false for disabling. This parameter is required.")]
35+
[ValidateNotNullOrEmpty]
36+
public bool Enabled { get; set; }
37+
38+
[Parameter(
39+
ValueFromPipelineByPropertyName = true,
40+
Mandatory = false,
41+
HelpMessage = "If specified then instance of " +
42+
"Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation type is returned.")]
43+
public SwitchParameter PassThru { get; set; }
44+
45+
public override void ExecuteApiManagementCmdlet()
46+
{
47+
Client.TenantAccessSet(
48+
Context,
49+
Enabled);
50+
51+
if (PassThru.IsPresent)
52+
{
53+
var tenantAccess = Client.GetTenantAccessInformation(Context);
54+
WriteObject(tenantAccess);
55+
}
56+
}
57+
}
58+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,7 @@ public class Constants
5959
public const string ApiManagementTenantGitConfiguration = "AzureRmApiManagementTenantGitConfiguration";
6060

6161
public const string ApiManagementTenantSyncState = "AzureRmApiManagementTenantSyncState";
62+
63+
public const string ApiManagementTenantAccess = "AzureRmApiManagementTenantAccess";
6264
}
6365
}

src/ResourceManager/ApiManagement/Commands.ApiManagement.ServiceManagement/Microsoft.Azure.Commands.ApiManagement.ServiceManagement.dll-help.Help.pshproj

Lines changed: 155 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7320,5 +7320,160 @@ OpenId Connect Provider.</Description>
73207320
<SupportInformation ad="false" rsat="false" ps2="false" ps3="false" ps4="false" ps5="false" wxp="false" wv="false" w7="false" w8="false" w81="false" w2k3s="false" w2k3e="false" w2k3d="false" w2k8s="false" w2k8e="false" w2k8d="false" w2k8r2s="false" w2k8r2e="false" w2k8r2d="false" w2k12s="false" w2k12d="false" w2k12r2s="false" w2k12r2d="false" />
73217321
<Publish>false</Publish>
73227322
</CmdletObject>
7323+
<CmdletObject verb="Get" noun="AzureRmApiManagementTenantAccess">
7324+
<Name>Get-AzureRmApiManagementTenantAccess</Name>
7325+
<GeneralHelp>
7326+
<Synopsis>Gets the access configuration for the Tenant.</Synopsis>
7327+
<Description>Gets the access configuration for the Tenant.</Description>
7328+
<Notes />
7329+
<InputType />
7330+
<InputUrl />
7331+
<InputTypeDescription />
7332+
<ReturnType>Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation</ReturnType>
7333+
<ReturnUrl />
7334+
<ReturnTypeDescription />
7335+
</GeneralHelp>
7336+
<ParamSets>
7337+
<CommandParameterSetInfo2 Name="__AllParameterSets" Params="Context Verbose Debug ErrorAction WarningAction InformationAction ErrorVariable WarningVariable InformationVariable OutVariable OutBuffer PipelineVariable" />
7338+
</ParamSets>
7339+
<Syntax>
7340+
<string>Get-AzureRmApiManagementTenantAccess -Context &lt;PsApiManagementContext&gt; [-InformationAction &lt;ActionPreference&gt;] [-InformationVariable &lt;String&gt;]</string>
7341+
</Syntax>
7342+
<Parameters>
7343+
<ParameterDescription type="PsApiManagementContext" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
7344+
<Name>Context</Name>
7345+
<Attributes>
7346+
<string>System.Management.Automation.ParameterAttribute</string>
7347+
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
7348+
</Attributes>
7349+
<Aliases />
7350+
<Description>Instance of PsApiManagementContext. This parameter is required.</Description>
7351+
<DefaultValue />
7352+
</ParameterDescription>
7353+
<ParameterDescription type="ActionPreference" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
7354+
<Name>InformationAction</Name>
7355+
<Attributes>
7356+
<string>System.Management.Automation.ParameterAttribute</string>
7357+
<string>System.Management.Automation.AliasAttribute</string>
7358+
</Attributes>
7359+
<Aliases>
7360+
<string>infa</string>
7361+
</Aliases>
7362+
<Description />
7363+
<DefaultValue />
7364+
</ParameterDescription>
7365+
<ParameterDescription type="String" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
7366+
<Name>InformationVariable</Name>
7367+
<Attributes>
7368+
<string>System.Management.Automation.ParameterAttribute</string>
7369+
<string>System.Management.Automation.AliasAttribute</string>
7370+
<string>System.Management.Automation.Internal.CommonParameters+ValidateVariableName</string>
7371+
</Attributes>
7372+
<Aliases>
7373+
<string>iv</string>
7374+
</Aliases>
7375+
<Description />
7376+
<DefaultValue />
7377+
</ParameterDescription>
7378+
</Parameters>
7379+
<Examples>
7380+
<Example>
7381+
<Name>Example 1</Name>
7382+
<Cmd>Get-AzureRmApiManagementTenantAccess -Context $apimContext</Cmd>
7383+
<Description>Gets the Tenant Access configuration.</Description>
7384+
<Output />
7385+
</Example>
7386+
</Examples>
7387+
<RelatedLinks />
7388+
<SupportInformation ad="false" rsat="false" ps2="false" ps3="false" ps4="false" ps5="false" wxp="false" wv="false" w7="false" w8="false" w81="false" w2k3s="false" w2k3e="false" w2k3d="false" w2k8s="false" w2k8e="false" w2k8d="false" w2k8r2s="false" w2k8r2e="false" w2k8r2d="false" w2k12s="false" w2k12d="false" w2k12r2s="false" w2k12r2d="false" />
7389+
<Publish>false</Publish>
7390+
</CmdletObject>
7391+
<CmdletObject verb="Set" noun="AzureRmApiManagementTenantAccess">
7392+
<Name>Set-AzureRmApiManagementTenantAccess</Name>
7393+
<GeneralHelp>
7394+
<Synopsis>Sets the access configuration of the Tenant.</Synopsis>
7395+
<Description>Sets the access configuration of the Tenant.</Description>
7396+
<Notes />
7397+
<InputType />
7398+
<InputUrl />
7399+
<InputTypeDescription />
7400+
<ReturnType>Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation</ReturnType>
7401+
<ReturnUrl />
7402+
<ReturnTypeDescription />
7403+
</GeneralHelp>
7404+
<ParamSets>
7405+
<CommandParameterSetInfo2 Name="__AllParameterSets" Params="Context Enabled PassThru Verbose Debug ErrorAction WarningAction InformationAction ErrorVariable WarningVariable InformationVariable OutVariable OutBuffer PipelineVariable" />
7406+
</ParamSets>
7407+
<Syntax>
7408+
<string>Set-AzureRmApiManagementTenantAccess -Context &lt;PsApiManagementContext&gt; -Enabled &lt;Boolean&gt; [-PassThru] [-InformationAction &lt;ActionPreference&gt;] [-InformationVariable &lt;String&gt;]</string>
7409+
</Syntax>
7410+
<Parameters>
7411+
<ParameterDescription type="PsApiManagementContext" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
7412+
<Name>Context</Name>
7413+
<Attributes>
7414+
<string>System.Management.Automation.ParameterAttribute</string>
7415+
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
7416+
</Attributes>
7417+
<Aliases />
7418+
<Description>Instance of PsApiManagementContext. This parameter is required.</Description>
7419+
<DefaultValue />
7420+
</ParameterDescription>
7421+
<ParameterDescription type="Boolean" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
7422+
<Name>Enabled</Name>
7423+
<Attributes>
7424+
<string>System.Management.Automation.ParameterAttribute</string>
7425+
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
7426+
</Attributes>
7427+
<Aliases />
7428+
<Description>Enable Tenant access. Set to true for enabling and false for disabling. This parameter is required.</Description>
7429+
<DefaultValue />
7430+
</ParameterDescription>
7431+
<ParameterDescription type="SwitchParameter" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
7432+
<Name>PassThru</Name>
7433+
<Attributes>
7434+
<string>System.Management.Automation.ParameterAttribute</string>
7435+
</Attributes>
7436+
<Aliases />
7437+
<Description>If specified then instance of Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation type is returned.</Description>
7438+
<DefaultValue />
7439+
</ParameterDescription>
7440+
<ParameterDescription type="ActionPreference" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
7441+
<Name>InformationAction</Name>
7442+
<Attributes>
7443+
<string>System.Management.Automation.ParameterAttribute</string>
7444+
<string>System.Management.Automation.AliasAttribute</string>
7445+
</Attributes>
7446+
<Aliases>
7447+
<string>infa</string>
7448+
</Aliases>
7449+
<Description />
7450+
<DefaultValue />
7451+
</ParameterDescription>
7452+
<ParameterDescription type="String" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
7453+
<Name>InformationVariable</Name>
7454+
<Attributes>
7455+
<string>System.Management.Automation.ParameterAttribute</string>
7456+
<string>System.Management.Automation.AliasAttribute</string>
7457+
<string>System.Management.Automation.Internal.CommonParameters+ValidateVariableName</string>
7458+
</Attributes>
7459+
<Aliases>
7460+
<string>iv</string>
7461+
</Aliases>
7462+
<Description />
7463+
<DefaultValue />
7464+
</ParameterDescription>
7465+
</Parameters>
7466+
<Examples>
7467+
<Example>
7468+
<Name>Example 1</Name>
7469+
<Cmd>Set-AzureRmApiManagementTenantAccess -Context $apimContext -Enabled $true</Cmd>
7470+
<Description>Sets the Tenant Access using REST API to True.</Description>
7471+
<Output />
7472+
</Example>
7473+
</Examples>
7474+
<RelatedLinks />
7475+
<SupportInformation ad="false" rsat="false" ps2="false" ps3="false" ps4="false" ps5="false" wxp="false" wv="false" w7="false" w8="false" w81="false" w2k3s="false" w2k3e="false" w2k3d="false" w2k8s="false" w2k8e="false" w2k8d="false" w2k8r2s="false" w2k8r2e="false" w2k8r2d="false" w2k12s="false" w2k12d="false" w2k12r2s="false" w2k12r2d="false" />
7476+
<Publish>false</Publish>
7477+
</CmdletObject>
73237478
</Cmdlets>
73247479
</ModuleObject>

0 commit comments

Comments
 (0)