-
Notifications
You must be signed in to change notification settings - Fork 4k
Powershell changes for supporting ExpressRoutePort authorization #17392
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
isra-fel
merged 11 commits into
Azure:network-2021-08-01
from
utbarn-ms:network-2021-08-01
Apr 12, 2022
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
b7a82b2
powershell changes for er ports authorization
utbarn-ms 6b06a7d
adding tests and md files
utbarn-ms a59c4b2
making changes after arm feedback
utbarn-ms dd6c6f0
updating changelog
utbarn-ms 0bb0541
resolving review comments
utbarn-ms a11b2b0
Update src/Network/Network/ExpressRoutePort/Authorization/RemoveAzure…
utbarn-ms 8de158e
Update src/Network/Network/ExpressRoutePort/Authorization/RemoveAzure…
utbarn-ms c94ee4b
fixing review comments
utbarn-ms c6e809e
adding local sdks
utbarn-ms 1a905b4
adding authkey property for circuit in network.format
utbarn-ms 1218117
Merge branch 'network-2021-08-01' into network-2021-08-01
isra-fel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2,139 changes: 2,139 additions & 0 deletions
2,139
...twork.Test.ScenarioTests.ExpressRoutePortTests/TestExpressRoutePortAuthorizationCRUD.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...rk/Network/ExpressRoutePort/Authorization/AddAzureExpressRoutePortAuthorizationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// 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. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.Network.Models; | ||
using System; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
using System.Net; | ||
using MNM = Microsoft.Azure.Management.Network.Models; | ||
|
||
namespace Microsoft.Azure.Commands.Network | ||
{ | ||
[Cmdlet("Add", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortAuthorization", SupportsShouldProcess = true), OutputType(typeof(PSExpressRoutePortAuthorization))] | ||
public class AddAzureExpressRoutePortAuthorizationCommand : NetworkBaseCmdlet | ||
{ | ||
[Parameter( | ||
Mandatory = true, | ||
HelpMessage = "The name of the Authorization")] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = true, | ||
ValueFromPipeline = true, | ||
HelpMessage = "The ExpressRoutePort Object")] | ||
public PSExpressRoutePort ExpressRoutePortObject { get; set; } | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
var present = true; | ||
|
||
try | ||
{ | ||
this.NetworkClient.NetworkManagementClient.ExpressRoutePortAuthorizations.GetWithHttpMessagesAsync(this.ExpressRoutePortObject.ResourceGroupName, this.ExpressRoutePortObject.Name, this.Name).GetAwaiter().GetResult(); | ||
} | ||
catch (Microsoft.Rest.Azure.CloudException exception) | ||
{ | ||
if (exception.Response.StatusCode == HttpStatusCode.NotFound) | ||
{ | ||
// Resource is not present | ||
present = false; | ||
} | ||
else | ||
{ | ||
throw; | ||
} | ||
} | ||
|
||
if (present) | ||
{ | ||
throw new ArgumentException("Authorization with the specified name already exists"); | ||
} | ||
|
||
var authorizationParameters = new MNM.ExpressRoutePortAuthorization(); | ||
authorizationParameters.Name = this.Name; | ||
|
||
// Execute the PUT ExpressRoutePortAuthorizations call | ||
var putExpressRoutePortAuthorization = this.NetworkClient.NetworkManagementClient.ExpressRoutePortAuthorizations.CreateOrUpdateWithHttpMessagesAsync(this.ExpressRoutePortObject.ResourceGroupName, this.ExpressRoutePortObject.Name, this.Name, authorizationParameters).GetAwaiter().GetResult().Body; | ||
var psExpressRoutePortAuthorization = NetworkResourceManagerProfile.Mapper.Map<PSExpressRoutePortAuthorization>(putExpressRoutePortAuthorization); | ||
WriteObject(psExpressRoutePortAuthorization, true); | ||
} | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...rk/Network/ExpressRoutePort/Authorization/GetAzureExpressRoutePortAuthorizationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// 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. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.Network.Models; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
namespace Microsoft.Azure.Commands.Network | ||
{ | ||
[Cmdlet("Get", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortAuthorization"), OutputType(typeof(PSExpressRoutePortAuthorization))] | ||
public class GetAzureExpressRoutePortAuthorizationCommand : NetworkBaseCmdlet | ||
{ | ||
[Parameter( | ||
Mandatory = false, | ||
HelpMessage = "The name of the Authorization")] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = true, | ||
ValueFromPipeline = true, | ||
HelpMessage = "The ExpressRoutePort Object")] | ||
public PSExpressRoutePort ExpressRoutePortObject { get; set; } | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
if (!string.IsNullOrEmpty(this.Name)) | ||
{ | ||
var getExpressRoutePortAuthorization = this.NetworkClient.NetworkManagementClient.ExpressRoutePortAuthorizations.GetWithHttpMessagesAsync(this.ExpressRoutePortObject.ResourceGroupName, this.ExpressRoutePortObject.Name, this.Name).GetAwaiter().GetResult().Body; | ||
var psExpressRoutePortAuthorization = NetworkResourceManagerProfile.Mapper.Map<PSExpressRoutePortAuthorization>(getExpressRoutePortAuthorization); | ||
WriteObject(psExpressRoutePortAuthorization); | ||
} | ||
else | ||
{ | ||
|
||
var listExpressRoutePortAuthorizations = this.NetworkClient.NetworkManagementClient.ExpressRoutePortAuthorizations.ListWithHttpMessagesAsync(this.ExpressRoutePortObject.ResourceGroupName, this.ExpressRoutePortObject.Name).GetAwaiter().GetResult().Body; | ||
var psExpressRoutePortAuthorizations = new List<PSExpressRoutePortAuthorization>(); | ||
if (listExpressRoutePortAuthorizations != null) | ||
{ | ||
psExpressRoutePortAuthorizations = NetworkResourceManagerProfile.Mapper.Map<List<PSExpressRoutePortAuthorization>>(listExpressRoutePortAuthorizations); | ||
} | ||
|
||
WriteObject(psExpressRoutePortAuthorizations, true); | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...Network/ExpressRoutePort/Authorization/RemoveAzureExpressRoutePortAuthorizationCommand.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// Copyright Microsoft Corporation | ||
// 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. | ||
// ---------------------------------------------------------------------------------- | ||
|
||
using Microsoft.Azure.Commands.Network.Models; | ||
using System.Linq; | ||
using System.Management.Automation; | ||
|
||
|
||
namespace Microsoft.Azure.Commands.Network | ||
{ | ||
[Cmdlet("Remove", ResourceManager.Common.AzureRMConstants.AzureRMPrefix + "ExpressRoutePortAuthorization", SupportsShouldProcess = true), OutputType(typeof(bool))] | ||
public class RemoveAzureExpressRoutePortAuthorizationCommand : NetworkBaseCmdlet | ||
{ | ||
[Parameter( | ||
Mandatory = true, | ||
HelpMessage = "The name of the Authorization")] | ||
[ValidateNotNullOrEmpty] | ||
public string Name { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = true, | ||
ValueFromPipeline = true, | ||
HelpMessage = "The ExpressRoutePort Object")] | ||
public PSExpressRoutePort ExpressRoutePortObject { get; set; } | ||
|
||
[Parameter( | ||
Mandatory = false, | ||
HelpMessage = "Do not ask for confirmation if you want to delete resource")] | ||
public SwitchParameter Force { get; set; } | ||
|
||
[Parameter(Mandatory = false)] | ||
public SwitchParameter PassThru { get; set; } | ||
|
||
[Parameter(Mandatory = false, HelpMessage = "Run cmdlet in the background")] | ||
public SwitchParameter AsJob { get; set; } | ||
|
||
public override void Execute() | ||
{ | ||
base.Execute(); | ||
|
||
ConfirmAction( | ||
Force.IsPresent, | ||
string.Format(Properties.Resources.RemovingResource, Name), | ||
Properties.Resources.RemoveResourceMessage, | ||
Name, | ||
() => | ||
{ | ||
this.NetworkClient.NetworkManagementClient.ExpressRoutePortAuthorizations.DeleteWithHttpMessagesAsync(ExpressRoutePortObject.ResourceGroupName, ExpressRoutePortObject.Name, Name).GetAwaiter().GetResult(); | ||
if (PassThru.IsPresent) | ||
{ | ||
WriteObject(true); | ||
} | ||
}); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.