Skip to content

Add Cmdlets for Tenant Access #2207

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

Merged
merged 3 commits into from
May 5, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1739,5 +1739,27 @@ public PsApiManagementTenantConfigurationSyncState GetTenantConfigurationSyncSta
}

#endregion

#region TenantAccessInformation
public PsApiManagementAccessInformation GetTenantAccessInformation(PsApiManagementContext context)
{
var response = Client.TenantAccess.Get(
context.ResourceGroupName,
context.ServiceName);

return Mapper.Map<PsApiManagementAccessInformation>(response.Value);
}

public void TenantAccessSet(
PsApiManagementContext context,
bool enabledTenantAccess)
{
var accessInformationParams = new AccessInformationUpdateParameters
{
Enabled = enabledTenantAccess
};
Client.TenantAccess.Update(context.ResourceGroupName, context.ServiceName, accessInformationParams, "*");
}
#endregion
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<Compile Include="Commands\GetAzureApiManagementTenantSyncState.cs" />
<Compile Include="Commands\GetAzureApiManagementUser.cs" />
<Compile Include="Commands\GetAzureApiManagementUserSsoUrl.cs" />
<Compile Include="Commands\GetAzureRmApiManagementTenantAccess.cs" />
<Compile Include="Commands\GetAzureRmApiManagementTenantGitAccess.cs" />
<Compile Include="Commands\ImportAzureApiManagementApi.cs" />
<Compile Include="Commands\NewAzureApiManagementApi.cs" />
Expand Down Expand Up @@ -203,6 +204,7 @@
<Compile Include="Commands\SetAzureApiManagementProperty.cs" />
<Compile Include="Commands\SetAzureApiManagementSubscription.cs" />
<Compile Include="Commands\SetAzureApiManagementUser.cs" />
<Compile Include="Commands\SetAzureRmApiManagementTenantAccess.cs" />
<Compile Include="Commands\SetAzureRmApiManagementTenantGitAccess.cs" />
<Compile Include="Constants.cs" />
<Compile Include="Models\ErrorBody.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
//
// 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.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;

[Cmdlet(VerbsCommon.Get, Constants.ApiManagementTenantAccess)]
[OutputType(typeof(PsApiManagementAccessInformation))]
public class GetAzureRmApiManagementTenantAccess : AzureApiManagementCmdletBase
{
[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
[ValidateNotNullOrEmpty]
public PsApiManagementContext Context { get; set; }

public override void ExecuteApiManagementCmdlet()
{
WriteObject(Client.GetTenantAccessInformation(Context));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// 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.Management.Automation;
using Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models;

[Cmdlet(VerbsCommon.Set, Constants.ApiManagementTenantAccess)]
[OutputType(typeof(PsApiManagementAccessInformation))]
public class SetAzureRmApiManagementTenantAccess : AzureApiManagementCmdletBase
{
[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = true,
HelpMessage = "Instance of PsApiManagementContext. This parameter is required.")]
[ValidateNotNullOrEmpty]
public PsApiManagementContext Context { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = false,
Mandatory = true,
HelpMessage = "Enable Tenant access. Set to true for enabling and false for disabling. This parameter is required.")]
[ValidateNotNullOrEmpty]
public bool Enabled { get; set; }

[Parameter(
ValueFromPipelineByPropertyName = true,
Mandatory = false,
HelpMessage = "If specified then instance of " +
"Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation type is returned.")]
public SwitchParameter PassThru { get; set; }

public override void ExecuteApiManagementCmdlet()
{
Client.TenantAccessSet(
Context,
Enabled);

if (PassThru.IsPresent)
{
var tenantAccess = Client.GetTenantAccessInformation(Context);
WriteObject(tenantAccess);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,5 +59,7 @@ public class Constants
public const string ApiManagementTenantGitConfiguration = "AzureRmApiManagementTenantGitConfiguration";

public const string ApiManagementTenantSyncState = "AzureRmApiManagementTenantSyncState";

public const string ApiManagementTenantAccess = "AzureRmApiManagementTenantAccess";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7320,5 +7320,160 @@ OpenId Connect Provider.</Description>
<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" />
<Publish>false</Publish>
</CmdletObject>
<CmdletObject verb="Get" noun="AzureRmApiManagementTenantAccess">
<Name>Get-AzureRmApiManagementTenantAccess</Name>
<GeneralHelp>
<Synopsis>Gets the access configuration for the Tenant.</Synopsis>
<Description>Gets the access configuration for the Tenant.</Description>
<Notes />
<InputType />
<InputUrl />
<InputTypeDescription />
<ReturnType>Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation</ReturnType>
<ReturnUrl />
<ReturnTypeDescription />
</GeneralHelp>
<ParamSets>
<CommandParameterSetInfo2 Name="__AllParameterSets" Params="Context Verbose Debug ErrorAction WarningAction InformationAction ErrorVariable WarningVariable InformationVariable OutVariable OutBuffer PipelineVariable" />
</ParamSets>
<Syntax>
<string>Get-AzureRmApiManagementTenantAccess -Context &lt;PsApiManagementContext&gt; [-InformationAction &lt;ActionPreference&gt;] [-InformationVariable &lt;String&gt;]</string>
</Syntax>
<Parameters>
<ParameterDescription type="PsApiManagementContext" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
<Name>Context</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
</Attributes>
<Aliases />
<Description>Instance of PsApiManagementContext. This parameter is required.</Description>
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="ActionPreference" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
<Name>InformationAction</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.AliasAttribute</string>
</Attributes>
<Aliases>
<string>infa</string>
</Aliases>
<Description />
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="String" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
<Name>InformationVariable</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.AliasAttribute</string>
<string>System.Management.Automation.Internal.CommonParameters+ValidateVariableName</string>
</Attributes>
<Aliases>
<string>iv</string>
</Aliases>
<Description />
<DefaultValue />
</ParameterDescription>
</Parameters>
<Examples>
<Example>
<Name>Example 1</Name>
<Cmd>Get-AzureRmApiManagementTenantAccess -Context $apimContext</Cmd>
<Description>Gets the Tenant Access configuration.</Description>
<Output />
</Example>
</Examples>
<RelatedLinks />
<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" />
<Publish>false</Publish>
</CmdletObject>
<CmdletObject verb="Set" noun="AzureRmApiManagementTenantAccess">
<Name>Set-AzureRmApiManagementTenantAccess</Name>
<GeneralHelp>
<Synopsis>Sets the access configuration of the Tenant.</Synopsis>
<Description>Sets the access configuration of the Tenant.</Description>
<Notes />
<InputType />
<InputUrl />
<InputTypeDescription />
<ReturnType>Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation</ReturnType>
<ReturnUrl />
<ReturnTypeDescription />
</GeneralHelp>
<ParamSets>
<CommandParameterSetInfo2 Name="__AllParameterSets" Params="Context Enabled PassThru Verbose Debug ErrorAction WarningAction InformationAction ErrorVariable WarningVariable InformationVariable OutVariable OutBuffer PipelineVariable" />
</ParamSets>
<Syntax>
<string>Set-AzureRmApiManagementTenantAccess -Context &lt;PsApiManagementContext&gt; -Enabled &lt;Boolean&gt; [-PassThru] [-InformationAction &lt;ActionPreference&gt;] [-InformationVariable &lt;String&gt;]</string>
</Syntax>
<Parameters>
<ParameterDescription type="PsApiManagementContext" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
<Name>Context</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
</Attributes>
<Aliases />
<Description>Instance of PsApiManagementContext. This parameter is required.</Description>
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="Boolean" varLen="false" required="true" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
<Name>Enabled</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.ValidateNotNullOrEmptyAttribute</string>
</Attributes>
<Aliases />
<Description>Enable Tenant access. Set to true for enabling and false for disabling. This parameter is required.</Description>
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="SwitchParameter" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="true" isPos="false" pos="named" globbing="false">
<Name>PassThru</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
</Attributes>
<Aliases />
<Description>If specified then instance of Microsoft.Azure.Commands.ApiManagement.ServiceManagement.Models.PsApiManagementAccessInformation type is returned.</Description>
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="ActionPreference" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
<Name>InformationAction</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.AliasAttribute</string>
</Attributes>
<Aliases>
<string>infa</string>
</Aliases>
<Description />
<DefaultValue />
</ParameterDescription>
<ParameterDescription type="String" varLen="false" required="false" dynamic="false" pipeRemaining="false" pipe="false" pipeProp="false" isPos="false" pos="named" globbing="false">
<Name>InformationVariable</Name>
<Attributes>
<string>System.Management.Automation.ParameterAttribute</string>
<string>System.Management.Automation.AliasAttribute</string>
<string>System.Management.Automation.Internal.CommonParameters+ValidateVariableName</string>
</Attributes>
<Aliases>
<string>iv</string>
</Aliases>
<Description />
<DefaultValue />
</ParameterDescription>
</Parameters>
<Examples>
<Example>
<Name>Example 1</Name>
<Cmd>Set-AzureRmApiManagementTenantAccess -Context $apimContext -Enabled $true</Cmd>
<Description>Sets the Tenant Access using REST API to True.</Description>
<Output />
</Example>
</Examples>
<RelatedLinks />
<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" />
<Publish>false</Publish>
</CmdletObject>
</Cmdlets>
</ModuleObject>
Loading