-
Notifications
You must be signed in to change notification settings - Fork 4k
Cmdlets for Cross server gt #1471
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
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
b2355c2
Add server communication link
adumitr bba1025
Merge branch 'dev' into cross_server_gt
adumitr 13eb57b
Changes for CR comments
adumitr 41b7edb
Disable server communication link tests and fix build
adumitr 650669a
Fix reference in Commands.Sql.Test
adumitr 21aace3
Adding OutputType to cmdlets per code review comments
adumitr c05a38d
Merge branch 'dev' into cross_server_gt
adumitr 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
47 changes: 47 additions & 0 deletions
47
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ServerCommunicationLinkCrudTests.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,47 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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.ScenarioTest.SqlTests; | ||
using Microsoft.WindowsAzure.Commands.ScenarioTest; | ||
using Xunit; | ||
|
||
namespace Microsoft.Azure.Commands.Sql.Test.ScenarioTests | ||
{ | ||
public class ServerCommunicationLinkCrudTests : SqlTestsBase | ||
{ | ||
// TODO: adumitr: re-enable the tests when feature is fully enabled in the region the tests use | ||
// [Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestServerCommunicationLinkCreate() | ||
{ | ||
RunPowerShellTest("Test-CreateServerCommunicationLink"); | ||
} | ||
|
||
// TODO: adumitr: re-enable the tests when feature is fully enabled in the region the tests use | ||
// [Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestServerCommunicationLinkGet() | ||
{ | ||
RunPowerShellTest("Test-GetServerCommunicationLink"); | ||
} | ||
|
||
// TODO: adumitr: re-enable the tests when feature is fully enabled in the region the tests use | ||
// [Fact] | ||
[Trait(Category.AcceptanceType, Category.CheckIn)] | ||
public void TestServerCommunicationLinkRemove() | ||
{ | ||
RunPowerShellTest("Test-RemoveServerCommunicationLink"); | ||
} | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
src/ResourceManager/Sql/Commands.Sql.Test/ScenarioTests/ServerCommunicationLinkCrudTests.ps1
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,100 @@ | ||
# ---------------------------------------------------------------------------------- | ||
# | ||
# 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. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
<# | ||
.SYNOPSIS | ||
Tests creating a server communication link | ||
#> | ||
function Test-CreateServerCommunicationLink | ||
{ | ||
# Setup | ||
$rg = Create-ResourceGroupForTest | ||
$server = Create-ServerForTest $rg "Japan East" | ||
$server2 = Create-ServerForTest $rg "Japan East" | ||
|
||
try | ||
{ | ||
$linkName = Get-ElasticPoolName | ||
$ep1 = New-AzureRmSqlServerCommunicationLink -ServerName $server1.ServerName -ResourceGroupName $rg.ResourceGroupName ` | ||
-LinkName $linkName -PartnerServer $server2.ServerName | ||
|
||
Assert-NotNull $ep1 | ||
Assert-AreEqual $server2.ServerName $ep1.PartnerServer | ||
} | ||
finally | ||
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Tests getting a server communication link | ||
#> | ||
function Test-GetServerCommunicationLink | ||
{ | ||
# Setup | ||
$rg = Create-ResourceGroupForTest | ||
$server = Create-ServerForTest $rg "Japan East" | ||
$server2 = Create-ServerForTest $rg "Japan East" | ||
|
||
$linkName = Get-ElasticPoolName | ||
$ep1 = New-AzureRmSqlServerCommunicationLink -ServerName $server1.ServerName -ResourceGroupName $rg.ResourceGroupName ` | ||
-LinkName $linkName -PartnerServer $server2.ServerName | ||
Assert-NotNull $ep1 | ||
|
||
try | ||
{ | ||
$gep1 = Get-AzureRmSqlServerCommunicationLink -ServerName $server1.ServerName -ResourceGroupName $rg.ResourceGroupName ` | ||
-LinkName $ep1.LinkName | ||
Assert-NotNull $ep1 | ||
Assert-AreEqual $server2.ServerName $ep1.PartnerServer | ||
|
||
$all = $server | Get-AzureRmSqlServerCommunicationLink | ||
Assert-AreEqual $all.Count 1 | ||
} | ||
finally | ||
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} | ||
|
||
<# | ||
.SYNOPSIS | ||
Tests removing a server communication link | ||
#> | ||
function Test-RemoveServerCommunicationLink | ||
{ | ||
# Setup | ||
$rg = Create-ResourceGroupForTest | ||
$server1 = Create-ServerForTest $rg "Japan East" | ||
$server2 = Create-ServerForTest $rg "Japan East" | ||
|
||
$linkName = Get-ElasticPoolName | ||
$ep1 = New-AzureRmSqlServerCommunicationLink -ServerName $server1.ServerName -ResourceGroupName $rg.ResourceGroupName ` | ||
-LinkName $linkName -PartnerServer $server2.ServerName | ||
Assert-NotNull $ep1 | ||
|
||
try | ||
{ | ||
Remove-AzureRmSqlServerCommunicationLink -ServerName $server1.ServerName -ResourceGroupName $rg.ResourceGroupName -LinkName $ep1.LinkName -Force | ||
|
||
$all = $server | Get-AzureRmSqlServerCommunicationLink | ||
Assert-AreEqual $all.Count 0 | ||
} | ||
finally | ||
{ | ||
Remove-ResourceGroupForTest $rg | ||
} | ||
} |
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
29 changes: 28 additions & 1 deletion
29
src/ResourceManager/Sql/Commands.Sql/Properties/Resources.Designer.cs
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
45 changes: 45 additions & 0 deletions
45
.../Commands.Sql/ServerCommunicationLink/Cmdlet/AzureSqlServerCommunicationLinkCmdletBase.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,45 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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 System.Collections.Generic; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.Sql.Common; | ||
using Microsoft.Azure.Commands.Sql.ServerCommunicationLink.Model; | ||
using Microsoft.Azure.Commands.Sql.ServerCommunicationLink.Services; | ||
|
||
namespace Microsoft.Azure.Commands.Sql.ServerCommunicationLink.Cmdlet | ||
{ | ||
public abstract class AzureSqlServerCommunicationLinkCmdletBase : AzureSqlCmdletBase<IEnumerable<AzureSqlServerCommunicationLinkModel>, AzureSqlServerCommunicationLinkAdapter> | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the server to use. | ||
/// </summary> | ||
[Parameter(Mandatory = true, | ||
ValueFromPipelineByPropertyName = true, | ||
Position = 1, | ||
HelpMessage = "The name of the Azure SQL Server.")] | ||
[ValidateNotNullOrEmpty] | ||
public string ServerName { get; set; } | ||
|
||
/// <summary> | ||
/// Initializes the adapter | ||
/// </summary> | ||
/// <param name="subscription">The subscription</param> | ||
/// <returns>Link adapter for ServerCommunicationLink</returns> | ||
protected override AzureSqlServerCommunicationLinkAdapter InitModelAdapter(Azure.Common.Authentication.Models.AzureSubscription subscription) | ||
{ | ||
return new AzureSqlServerCommunicationLinkAdapter(DefaultProfile.Context); | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...ger/Sql/Commands.Sql/ServerCommunicationLink/Cmdlet/GetAzureSqlServerCommunicationLink.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,76 @@ | ||
// ---------------------------------------------------------------------------------- | ||
// | ||
// 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 System.Collections.Generic; | ||
using System.Management.Automation; | ||
using Microsoft.Azure.Commands.Sql.ServerCommunicationLink.Model; | ||
|
||
namespace Microsoft.Azure.Commands.Sql.ServerCommunicationLink.Cmdlet | ||
{ | ||
[Cmdlet(VerbsCommon.Get, "AzureRmSqlServerCommunicationLink", | ||
ConfirmImpact = ConfirmImpact.None), OutputType(typeof(AzureSqlServerCommunicationLinkModel))] | ||
public class GetAzureSqlServerCommunicationLink : AzureSqlServerCommunicationLinkCmdletBase | ||
{ | ||
/// <summary> | ||
/// Gets or sets the name of the server communication link to use. | ||
/// </summary> | ||
[Parameter(Mandatory = false, | ||
ValueFromPipelineByPropertyName = true, | ||
Position = 2, | ||
HelpMessage = "The name of the Azure SQL server communication link to retrieve.")] | ||
[ValidateNotNullOrEmpty] | ||
public string LinkName { get; set; } | ||
|
||
/// <summary> | ||
/// Get the entities from the service | ||
/// </summary> | ||
/// <returns>The list of entities</returns> | ||
protected override IEnumerable<AzureSqlServerCommunicationLinkModel> GetEntity() | ||
{ | ||
ICollection<AzureSqlServerCommunicationLinkModel> results; | ||
|
||
if (MyInvocation.BoundParameters.ContainsKey("LinkName")) | ||
{ | ||
results = new List<AzureSqlServerCommunicationLinkModel>(); | ||
results.Add(ModelAdapter.GetServerCommunicationLink(this.ResourceGroupName, this.ServerName, this.LinkName)); | ||
} | ||
else | ||
{ | ||
results = ModelAdapter.ListServerCommunicationLinks(this.ResourceGroupName, this.ServerName); | ||
} | ||
|
||
return results; | ||
} | ||
|
||
/// <summary> | ||
/// No user input to apply to model | ||
/// </summary> | ||
/// <param name="model">Model retrieved from service</param> | ||
/// <returns>The model that was passed in</returns> | ||
protected override IEnumerable<AzureSqlServerCommunicationLinkModel> ApplyUserInputToModel(IEnumerable<AzureSqlServerCommunicationLinkModel> model) | ||
{ | ||
return model; | ||
} | ||
|
||
/// <summary> | ||
/// No changes to persist to server | ||
/// </summary> | ||
/// <param name="entity">The output of apply user input to model</param> | ||
/// <returns>The input entity</returns> | ||
protected override IEnumerable<AzureSqlServerCommunicationLinkModel> PersistChanges(IEnumerable<AzureSqlServerCommunicationLinkModel> entity) | ||
{ | ||
return entity; | ||
} | ||
} | ||
} |
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.
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.
@adumitr What is the OutputType for this cmdlet? Please add the attribute for OutputType with the cmdlet OutputType
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.
Added