Skip to content
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

Regenearte Cognitive Services Mgmt. SDK with latest Spec and AutoRest (targeting release as 2.1) #3909

Merged
merged 26 commits into from
Dec 19, 2017
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
cb0dfce
Merge remote-tracking branch 'refs/remotes/Azure/psSdkJson6' into psS…
felixwa Dec 1, 2017
b6adccc
Regenerate using the latest AutoRest
felixwa Dec 1, 2017
8f5f8a9
Remove AssemblyInfo.cs file
felixwa Dec 6, 2017
d561d47
Remove Properties folder in test proj
felixwa Dec 6, 2017
10ae273
Resolve some review comments
felixwa Dec 7, 2017
3d4e3a1
Add PackageReleaseNotes
felixwa Dec 7, 2017
660d61a
Revert "Remove AssemblyInfo.cs file"
felixwa Dec 11, 2017
ed30e6c
Run msbuild to update build tools
felixwa Dec 11, 2017
772c991
Merge branch 'psSdkJson6' of https://github.com/felixwa/azure-sdk-for…
felixwa Dec 11, 2017
eb20f0b
Merge branch 'psSdkJson6' into Regenearte-SDK-2.1
felixwa Dec 11, 2017
d99299c
Revert CognitiveServices.Tests.csproj
felixwa Dec 11, 2017
923a9e4
Resolve conflicts.
felixwa Dec 11, 2017
89c151d
Merge branch 'psSdkJson6' into Regenearte-SDK-2.1
felixwa Dec 11, 2017
e599916
Merge branch 'psSdkJson6' into Regenearte-SDK-2.1
felixwa Dec 11, 2017
f1da037
Revert indents in CogntiiveServices.csproj
felixwa Dec 11, 2017
14f315e
Merge branch 'Regenearte-SDK-2.1' of https://github.com/felixwa/azure…
felixwa Dec 11, 2017
056c0d1
Correct previous commit
felixwa Dec 11, 2017
8ee1eac
Correct indents
felixwa Dec 11, 2017
2d45fe8
Correct indents
felixwa Dec 11, 2017
af19f45
Change Assembly version
felixwa Dec 11, 2017
03dbd36
Remove AzSdk.RP.props file
felixwa Dec 11, 2017
42a1d5b
Regenerated against latest spec.
felixwa Dec 13, 2017
91a5ee0
Merge branch 'psSdkJson6' into Regenearte-SDK-2.1
shahabhijeet Dec 13, 2017
ef5c41d
Regenerate SDK again as shahabhijeet requested
felixwa Dec 14, 2017
bf14abf
Bump version to 3.0.0.0 as there is a breaking change
felixwa Dec 15, 2017
9a4ec4f
Add AzSdk.RP.props
felixwa Dec 15, 2017
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 @@ -10,6 +10,9 @@
<PropertyGroup>
<TargetFrameworks>netcoreapp1.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@felixwa please remove line 13 to 15 and line 35 to 38

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove and also removed AssemblyInfo.cs

<Compile Remove="Properties\AssemblyInfo.cs" />
</ItemGroup>

<ItemGroup>
<!--<PackageReference Include="Microsoft.Azure.Management.CognitiveServices" Version="0.3.0-preview" />-->
Expand All @@ -29,4 +32,8 @@
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
</ItemGroup>

<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public static string CreateCognitiveServicesAccount(CognitiveServicesManagementC
string accountName = TestUtilities.GenerateName("csa");
CognitiveServicesAccountCreateParameters parameters = GetDefaultCognitiveServicesAccountParameters();
if (!string.IsNullOrEmpty(kind)) parameters.Kind = kind;
var createRequest2 = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, parameters);
var createRequest2 = cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, parameters);

return accountName;
}
Expand All @@ -122,7 +122,7 @@ public static CognitiveServicesAccount CreateAndValidateAccountWithOnlyRequiredP
Location = location ?? DefaultLocation,
Properties = new object(),
};
var account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgName, accountName, parameters);
var account = cognitiveServicesMgmtClient.Accounts.Create(rgName, accountName, parameters);
VerifyAccountProperties(account, false, accountType, skuName, location ?? DefaultLocation);

return account;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ public void CognitiveServicesAccountCreateTest()
var parameters = CognitiveServicesManagementTestUtilities.GetDefaultCognitiveServicesAccountParameters();

// Create cognitive services account
var account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, parameters);
var account = cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, parameters);
CognitiveServicesManagementTestUtilities.VerifyAccountProperties(account, true);

// Create same account again, make sure it doesn't fail
account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, parameters);
account = cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, parameters);
CognitiveServicesManagementTestUtilities.VerifyAccountProperties(account, true);

// Create account with only required params, for each sku (but free, since we can't have two free accounts in the same subscription)
Expand Down Expand Up @@ -99,16 +99,16 @@ public void CognitiveServicesAccountDeleteTest()
var rgname = CognitiveServicesManagementTestUtilities.CreateResourceGroup(resourcesClient);

// Delete an account which does not exist
cognitiveServicesMgmtClient.CognitiveServicesAccounts.Delete(rgname, "missingaccount");
cognitiveServicesMgmtClient.Accounts.Delete(rgname, "missingaccount");

// Create cognitive services account
string accountName = CognitiveServicesManagementTestUtilities.CreateCognitiveServicesAccount(cognitiveServicesMgmtClient, rgname);

// Delete an account
cognitiveServicesMgmtClient.CognitiveServicesAccounts.Delete(rgname, accountName);
cognitiveServicesMgmtClient.Accounts.Delete(rgname, accountName);

// Delete an account which was just deleted
cognitiveServicesMgmtClient.CognitiveServicesAccounts.Delete(rgname, accountName);
cognitiveServicesMgmtClient.Accounts.Delete(rgname, accountName);
}
}

Expand All @@ -129,12 +129,12 @@ public void CognitiveServicesAccountCreateAndGetDifferentSkusTest()
var f0Account = CognitiveServicesManagementTestUtilities.CreateAndValidateAccountWithOnlyRequiredParameters(cognitiveServicesMgmtClient, rgname, SkuName.F0, Kind.TextAnalytics);
var s1Account = CognitiveServicesManagementTestUtilities.CreateAndValidateAccountWithOnlyRequiredParameters(cognitiveServicesMgmtClient, rgname, SkuName.S1, Kind.TextAnalytics);

var f0Properties = cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties(rgname, f0Account.Name);
var f0Properties = cognitiveServicesMgmtClient.Accounts.GetProperties(rgname, f0Account.Name);
Assert.Equal(SkuName.F0, f0Properties.Sku.Name);
Assert.Equal(Kind.TextAnalytics.ToString(), f0Properties.Kind);


var s1Properties = cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties(rgname, s1Account.Name);
var s1Properties = cognitiveServicesMgmtClient.Accounts.GetProperties(rgname, s1Account.Name);
Assert.Equal(SkuName.S1, s1Properties.Sku.Name);
Assert.Equal(Kind.TextAnalytics.ToString(), s1Properties.Kind);
}
Expand Down Expand Up @@ -218,7 +218,7 @@ public void CognitiveServicesAccountListKeysTest()
string accountName = CognitiveServicesManagementTestUtilities.CreateCognitiveServicesAccount(cognitiveServicesMgmtClient, rgname);

// List keys
var keys = cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListKeys(rgname, accountName);
var keys = cognitiveServicesMgmtClient.Accounts.ListKeys(rgname, accountName);
Assert.NotNull(keys);

// Validate Key1
Expand All @@ -245,13 +245,13 @@ public void CognitiveServicesAccountRegenerateKeyTest()
string accountName = CognitiveServicesManagementTestUtilities.CreateCognitiveServicesAccount(cognitiveServicesMgmtClient, rgname);

// List keys
var keys = cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListKeys(rgname, accountName);
var keys = cognitiveServicesMgmtClient.Accounts.ListKeys(rgname, accountName);
Assert.NotNull(keys);
var key2 = keys.Key2;
Assert.NotNull(key2);

// Regenerate keys and verify that keys change
var regenKeys = cognitiveServicesMgmtClient.CognitiveServicesAccounts.RegenerateKey(rgname, accountName, KeyName.Key2);
var regenKeys = cognitiveServicesMgmtClient.Accounts.RegenerateKey(rgname, accountName, KeyName.Key2);
var key2Regen = regenKeys.Key2;
Assert.NotNull(key2Regen);

Expand All @@ -278,11 +278,11 @@ public void CognitiveServicesAccountUpdateWithCreateTest()
var accountName = createdAccount.Name;

// Update SKU
var account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Update(rgname, accountName, new Sku { Name = SkuName.S1 });
var account = cognitiveServicesMgmtClient.Accounts.Update(rgname, accountName, new Sku { Name = SkuName.S1 });
Assert.Equal(SkuName.S1, account.Sku.Name);

// Validate
var fetchedAccount = cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties(rgname, accountName);
var fetchedAccount = cognitiveServicesMgmtClient.Accounts.GetProperties(rgname, accountName);
Assert.Equal(SkuName.S1, fetchedAccount.Sku.Name);

var newTags = new Dictionary<string, string>
Expand All @@ -293,10 +293,10 @@ public void CognitiveServicesAccountUpdateWithCreateTest()
};

// Update account tags
account = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Update(rgname, accountName, null, newTags);
account = cognitiveServicesMgmtClient.Accounts.Update(rgname, accountName, null, newTags);
Assert.Equal(newTags.Count, account.Tags.Count);
// Validate
fetchedAccount = cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties(rgname, accountName);
fetchedAccount = cognitiveServicesMgmtClient.Accounts.GetProperties(rgname, accountName);
Assert.Equal(SkuName.S1, fetchedAccount.Sku.Name);
Assert.Equal(newTags.Count, fetchedAccount.Tags.Count());
Assert.Collection(fetchedAccount.Tags,
Expand Down Expand Up @@ -326,9 +326,9 @@ public void CognitiveServicesAccountEnumerateSkusTest()

// Enumerate SKUs

var skuList = cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListSkus(rgname, accountName);
var skuList = cognitiveServicesMgmtClient.Accounts.ListSkus(rgname, accountName);

Assert.Equal(1, skuList.Value.Select(x => x.ResourceType).Distinct().Count());
Assert.Single(skuList.Value.Select(x => x.ResourceType).Distinct());

Assert.Equal($"{c_resourceNamespace}/{c_resourceType}", skuList.Value.Select(x => x.ResourceType).First());

Expand Down Expand Up @@ -366,12 +366,12 @@ public void CognitiveServicesCreateAccountErrorTest()
};

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create("NotExistedRG", accountName, parameters),
() => cognitiveServicesMgmtClient.Accounts.Create("NotExistedRG", accountName, parameters),
"ResourceGroupNotFound");

parameters.Location = "BLA";
CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, parameters),
() => cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, parameters),
"LocationNotAvailableForResourceType");
}
}
Expand Down Expand Up @@ -407,11 +407,11 @@ public void CognitiveServicesCreateAccountErrorTest2()
};

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, nonExistApiPara),
() => cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, nonExistApiPara),
"InvalidApiSetId");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, accountName, nonExistSkuPara),
() => cognitiveServicesMgmtClient.Accounts.Create(rgname, accountName, nonExistSkuPara),
"InvalidSkuId");
}
}
Expand All @@ -430,11 +430,11 @@ public void CognitiveServicesGetAccountErrorTest()
var rgname = CognitiveServicesManagementTestUtilities.CreateResourceGroup(resourcesClient);

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties("NotExistedRG", "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.GetProperties("NotExistedRG", "nonExistedAccountName"),
"ResourceGroupNotFound");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.GetProperties(rgname, "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.GetProperties(rgname, "nonExistedAccountName"),
"ResourceNotFound");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
Expand Down Expand Up @@ -462,16 +462,16 @@ public void CognitiveServicesUpdateAccountErrorTest()

// try to update non-existent account
CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Update("NotExistedRG", "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.Update("NotExistedRG", "nonExistedAccountName"),
"ResourceGroupNotFound");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Update(rgname, "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.Update(rgname, "nonExistedAccountName"),
"ResourceNotFound");

// Update with a SKU which doesn't exist
CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Update(rgname, accountName, new Sku(SkuName.S0)),
() => cognitiveServicesMgmtClient.Accounts.Update(rgname, accountName, new Sku(SkuName.S0)),
"InvalidSkuId");
}
}
Expand All @@ -491,7 +491,7 @@ public void CognitiveServicesDeleteAccountErrorTest()

// try to delete non-existent account
CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.Delete("NotExistedRG", "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.Delete("NotExistedRG", "nonExistedAccountName"),
"ResourceGroupNotFound");
}
}
Expand All @@ -510,11 +510,11 @@ public void CognitiveServicesAccountKeysErrorTest()
var rgname = CognitiveServicesManagementTestUtilities.CreateResourceGroup(resourcesClient);

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListKeys("NotExistedRG", "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.ListKeys("NotExistedRG", "nonExistedAccountName"),
"ResourceGroupNotFound");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListKeys(rgname, "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.ListKeys(rgname, "nonExistedAccountName"),
"ResourceNotFound");
}
}
Expand All @@ -533,11 +533,11 @@ public void CognitiveServicesEnumerateSkusErrorTest()
var rgname = CognitiveServicesManagementTestUtilities.CreateResourceGroup(resourcesClient);

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListSkus("NotExistedRG", "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.ListSkus("NotExistedRG", "nonExistedAccountName"),
"ResourceGroupNotFound");

CognitiveServicesManagementTestUtilities.ValidateExpectedException(
() => cognitiveServicesMgmtClient.CognitiveServicesAccounts.ListSkus(rgname, "nonExistedAccountName"),
() => cognitiveServicesMgmtClient.Accounts.ListSkus(rgname, "nonExistedAccountName"),
"ResourceNotFound");
}
}
Expand Down Expand Up @@ -588,8 +588,8 @@ public void CognitiveServicesAccountMinMaxNameLengthTest()
var minName = "zz";
var maxName = "AcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcadAcad";

var minAccount = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, minName, parameters);
var maxAccount = cognitiveServicesMgmtClient.CognitiveServicesAccounts.Create(rgname, maxName, parameters);
var minAccount = cognitiveServicesMgmtClient.Accounts.Create(rgname, minName, parameters);
var maxAccount = cognitiveServicesMgmtClient.Accounts.Create(rgname, maxName, parameters);

Assert.Equal(minName, minAccount.Name);
Assert.Equal(maxName, maxAccount.Name);
Expand Down
Loading