-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Adding first version of Edge gateway sdk and tests #5250
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
eacb7f7
Adding first version of Edge gateway sdk and tests
anponnet 086558c
Fixing PR comments - Project property corrections, add assemblyinfo, …
anponnet 73d8947
Fix PR comments - assemblyinfo, assemblyversion, unnecassary properti…
anponnet 8c6919b
PR comment fixes: Target framework, folder structure
anponnet d81ea39
Updated device updates test case
anponnet 57e1f10
Regenerated client code with generate.ps1 pointing to azure master re…
anponnet 6ec1d5b
PR Comments: project property fixes, rerun tests
anponnet 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
Empty file.
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,7 @@ | ||
| <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
| <!--This file and it's contents are updated at build time moving or editing might result in build failure. Take due deligence while editing this file--> | ||
| <PropertyGroup> | ||
| <AzureApiTag>DataBoxEdge_2019-03-01;</AzureApiTag> | ||
| <PackageTags>$(PackageTags);$(CommonTags);$(AzureApiTag);</PackageTags> | ||
| </PropertyGroup> | ||
| </Project> |
28 changes: 28 additions & 0 deletions
28
src/SDKs/EdgeGateway/EdgeGateway.Tests/EdgeGateway.Tests.csproj
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,28 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0"> | ||
| <!-- Please do not move/edit code below this line --> | ||
| <Import Condition=" Exists('$([MSBuild]::GetPathOfFileAbove(AzSdk.test.reference.props))') " Project="$([MSBuild]::GetPathOfFileAbove('AzSdk.test.reference.props'))" /> | ||
| <!-- Please do not move/edit code below this line --> | ||
| <PropertyGroup> | ||
| <PackageId>EdgeGateway.Tests</PackageId> | ||
| <Version>1.0.0</Version> | ||
| <AssemblyName>EdgeGateway.Tests</AssemblyName> | ||
| <Description>EdgeGateway.Tests;</Description> | ||
| </PropertyGroup> | ||
| <PropertyGroup> | ||
| <TargetFrameworks>netcoreapp2.0</TargetFrameworks> | ||
| <TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <ProjectReference Include="..\Management.EdgeGateway\Microsoft.Azure.Management.EdgeGateway.csproj" /> | ||
| </ItemGroup> | ||
| <!--Do not remove until VS Test Tools fixes #472--> | ||
| <ItemGroup> | ||
| <Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" /> | ||
| </ItemGroup> | ||
| <ItemGroup> | ||
| <None Update="SessionRecords\**\*.json "> | ||
| <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> | ||
| </None> | ||
| </ItemGroup> | ||
| </Project> | ||
51 changes: 51 additions & 0 deletions
51
src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/AlertHelper.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,51 @@ | ||
| using Microsoft.Azure.Management.EdgeGateway; | ||
| using Microsoft.Azure.Management.EdgeGateway.Models; | ||
| using Microsoft.Rest.Azure; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace EdgeGateway.Tests | ||
| { | ||
| /// <summary> | ||
| /// Contains the test helper methods | ||
| /// </summary> | ||
| public static partial class TestUtilities | ||
| { | ||
| /// <summary> | ||
| /// Gets alerts int the device | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="deviceName"></param> | ||
| /// <param name="resourceGroupName"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<Alert> ListAlerts( | ||
| DataBoxEdgeManagementClient client, | ||
| string deviceName, | ||
| string resourceGroupName, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<Alert> alertList = client.Alerts.ListByDataBoxEdgeDevice(deviceName, resourceGroupName); | ||
| continuationToken = alertList.NextPageLink; | ||
| return alertList; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets next page of alerts in device | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="nextLink"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<Alert> ListAlertsNext( | ||
| DataBoxEdgeManagementClient client, | ||
| string nextLink, | ||
| out string continuationToken) | ||
| { | ||
| // Gets the alert list | ||
| IPage<Alert> alertList = client.Alerts.ListByDataBoxEdgeDeviceNext(nextLink); | ||
| continuationToken = alertList.NextPageLink; | ||
| return alertList; | ||
| } | ||
| } | ||
| } |
67 changes: 67 additions & 0 deletions
67
src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/BandwidthScheduleHelper.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 @@ | ||
| using Microsoft.Azure.Management.EdgeGateway; | ||
| using Microsoft.Azure.Management.EdgeGateway.Models; | ||
| using Microsoft.Rest.Azure; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace EdgeGateway.Tests | ||
| { | ||
| public static partial class TestUtilities | ||
| { | ||
|
|
||
| /// <summary> | ||
| /// Gets a bandwidth schedule object | ||
| /// </summary> | ||
| /// <returns>BandwidthSchedule</returns> | ||
| public static BandwidthSchedule GetBWSObject() | ||
| { | ||
|
|
||
| string start = string.Format("{0}:{1}:{2}", 0, 0, 0); | ||
| string stopTime = string.Format("{0}:{1}:{2}", 13, 59, 0); | ||
| List<string> days = new List<string> { "Sunday", "Monday" }; | ||
|
|
||
| BandwidthSchedule bws = new BandwidthSchedule(start, stopTime, 100, days); | ||
| return bws; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets the bandwidth schedules in device | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="deviceName"></param> | ||
| /// <param name="resourceGroupName"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<BandwidthSchedule> ListBandwidthSchedules( | ||
| DataBoxEdgeManagementClient client, | ||
| string deviceName, | ||
| string resourceGroupName, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<BandwidthSchedule> scheduleList = client.BandwidthSchedules.ListByDataBoxEdgeDevice(deviceName, resourceGroupName); | ||
| continuationToken = scheduleList.NextPageLink; | ||
| return scheduleList; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets next page of bandwidth schedules in device | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="nextLink"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<BandwidthSchedule> ListBandwidthSchedulesNext( | ||
| DataBoxEdgeManagementClient client, | ||
| string nextLink, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<BandwidthSchedule> scheduleList = client.BandwidthSchedules.ListByDataBoxEdgeDeviceNext(nextLink); | ||
| continuationToken = scheduleList.NextPageLink; | ||
| return scheduleList; | ||
| } | ||
| } | ||
| } | ||
|
|
134 changes: 134 additions & 0 deletions
134
src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/DeviceHelper.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,134 @@ | ||
| using Microsoft.Azure.Management.EdgeGateway; | ||
| using Microsoft.Azure.Management.EdgeGateway.Models; | ||
| using Microsoft.Rest.Azure; | ||
| using System.Collections.Generic; | ||
|
|
||
| namespace EdgeGateway.Tests | ||
| { | ||
| public static partial class TestUtilities | ||
| { | ||
|
|
||
| /// <summary> | ||
| /// Creates or updates given edge resource | ||
| /// </summary> | ||
| /// <param name="device"></param> | ||
| /// <param name="deviceName"></param> | ||
| /// <param name="client"></param> | ||
| /// <param name="resourceGroupName"></param> | ||
| /// <returns></returns> | ||
| public static DataBoxEdgeDevice CreateOrUpdate( | ||
| this DataBoxEdgeDevice device, | ||
| string deviceName, | ||
| DataBoxEdgeManagementClient client, | ||
| string resourceGroupName) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| client.Devices.CreateOrUpdate(deviceName, | ||
| device, | ||
| resourceGroupName | ||
| ); | ||
|
|
||
| //Returns a databox edge/gateway device | ||
| return client.Devices.Get(deviceName, resourceGroupName); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Populates the values of a gateway device | ||
| /// </summary> | ||
| /// <param name="device"></param> | ||
| /// <returns></returns> | ||
| public static void PopulateGatewayDeviceProperties(this DataBoxEdgeDevice device) | ||
| { | ||
| device.Location = TestConstants.DefaultResourceLocation; | ||
| device.Sku = new Sku("Gateway", "standard"); | ||
| device.Tags = new Dictionary<string, string>(); | ||
| device.Tags.Add("tag1", "value1"); | ||
| device.Tags.Add("tag2", "value2"); | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Populates the values of a edge device | ||
| /// </summary> | ||
| /// <param name="device"></param> | ||
| /// <returns></returns> | ||
| public static void PopulateEdgeDeviceProperties(this DataBoxEdgeDevice device) | ||
| { | ||
| device.Location = TestConstants.DefaultResourceLocation; | ||
| device.Sku = new Sku("Edge", "standard"); | ||
| device.Tags = new Dictionary<string, string>(); | ||
| device.Tags.Add("tag1", "value1"); | ||
| device.Tags.Add("tag2", "value2"); | ||
| } | ||
|
|
||
|
|
||
| /// <summary> | ||
| /// Gets resources by resource group | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="resourceGroupName"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<DataBoxEdgeDevice> GetResourcesByResourceGroup( | ||
| DataBoxEdgeManagementClient client, | ||
| string resourceGroupName, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListByResourceGroup(resourceGroupName); | ||
| continuationToken = resourceList.NextPageLink; | ||
| return resourceList; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets next page in resource group | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="nextLink"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<DataBoxEdgeDevice> GetResourcesByResourceGroupNext( | ||
| DataBoxEdgeManagementClient client, | ||
| string nextLink, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListByResourceGroupNext(nextLink); | ||
| continuationToken = resourceList.NextPageLink; | ||
| return resourceList; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets resources by subscription | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<DataBoxEdgeDevice> GetResourcesBySubscription( | ||
| DataBoxEdgeManagementClient client, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListBySubscription(); | ||
| continuationToken = resourceList.NextPageLink; | ||
| return resourceList; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets next page of resources in subscription | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="nextLink"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns></returns> | ||
| public static IEnumerable<DataBoxEdgeDevice> GetResourcesBySubscriptionNext( | ||
| DataBoxEdgeManagementClient client, | ||
| string nextLink, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<DataBoxEdgeDevice> resourceList = client.Devices.ListBySubscriptionNext(nextLink); | ||
| continuationToken = resourceList.NextPageLink; | ||
| return resourceList; | ||
| } | ||
| } | ||
| } |
28 changes: 28 additions & 0 deletions
28
src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/DevicePatchHelper.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,28 @@ | ||
| using Microsoft.Azure.Management.EdgeGateway; | ||
| using Microsoft.Azure.Management.EdgeGateway.Models; | ||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
|
|
||
| namespace EdgeGateway.Tests | ||
| { | ||
| public static partial class TestUtilities | ||
| { | ||
| /// <summary> | ||
| /// Gets the tags. | ||
| /// </summary> | ||
| /// <param name="device"></param> | ||
| /// <returns></returns> | ||
| public static Dictionary<string, string> GetTags(this DataBoxEdgeDevice device) | ||
| { | ||
| var Tags = new Dictionary<string, string>(); | ||
| if (device.Tags != null) | ||
| { | ||
| Tags = device.Tags.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); | ||
| } | ||
| Tags.Add("tag3", "value3"); | ||
| Tags.Add("tag4", "value4"); | ||
|
|
||
| return Tags; | ||
| } | ||
| } | ||
| } |
46 changes: 46 additions & 0 deletions
46
src/SDKs/EdgeGateway/EdgeGateway.Tests/Helpers/OrderHelper.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,46 @@ | ||
| using Microsoft.Azure.Management.EdgeGateway; | ||
| using Microsoft.Azure.Management.EdgeGateway.Models; | ||
| using Microsoft.Rest.Azure; | ||
| using System; | ||
| using System.Collections.Generic; | ||
| using System.Text; | ||
|
|
||
| namespace EdgeGateway.Tests | ||
| { | ||
| public static partial class TestUtilities | ||
| { | ||
| /// <summary> | ||
| /// Gets an order object | ||
| /// </summary> | ||
| /// <returns>Order</returns> | ||
| public static Order GetOrderObject() | ||
| { | ||
| ContactDetails contactDetails = new ContactDetails("John Mcclane", "Microsoft", "8004269400", new List<string>() { "john@microsoft.com" }); | ||
|
|
||
| Address shippingAddress = new Address("Microsoft Corporation", "98052", "Redmond", "WA", "USA"); | ||
| Order order = new Order(contactDetails, shippingAddress); | ||
| return order; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Gets storage account credentials in the device | ||
| /// </summary> | ||
| /// <param name="client"></param> | ||
| /// <param name="deviceName"></param> | ||
| /// <param name="resourceGroupName"></param> | ||
| /// <param name="continuationToken"></param> | ||
| /// <returns>List of order</returns> | ||
| public static IEnumerable<Order> ListOrders( | ||
| DataBoxEdgeManagementClient client, | ||
| string deviceName, | ||
| string resourceGroupName, | ||
| out string continuationToken) | ||
| { | ||
| //Create a databox edge/gateway device | ||
| IPage<Order> orderList = client.Orders.ListByDataBoxEdgeDevice(deviceName, resourceGroupName); | ||
| continuationToken = orderList.NextPageLink; | ||
| return orderList; | ||
| } | ||
|
|
||
| } | ||
| } |
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.
Please use a regex like
SessionRecords\**\*.jsoninsteadThere 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.
fixed