Files
sqltoolsservice/src/Microsoft.SqlTools.ResourceProvider.DefaultImpl/AzureSubscriptionIdentifier.cs
Kevin Cunnane 7acc668c04 Create Firewall Rule support with a simple Resource Provider implementation
Implementation of the resource provider APIs in order to support Create Firewall Rule. Provides definition for a ResourceProvider and Authentication service. The ResourceProvider supports firewall rules for now, and since authentication is routed through that method it will call into the auth service to set up the current account to be used.

Additional notes:
- Fixed deserialization by adding an Accept header. This shouldn't be necessary, but for some reason the firewall rule defaults to XML without this
- Use generic server list and parse the ID to get the resource group, avoiding a large number of extra calls for each RG
- Errors now include error message from the API
2017-10-09 15:45:33 -07:00

72 lines
2.2 KiB
C#

//
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using Microsoft.SqlTools.ResourceProvider.Core;
using Microsoft.SqlTools.ResourceProvider.Core.Authentication;
namespace Microsoft.SqlTools.ResourceProvider.DefaultImpl
{
/// <summary>
/// Implementation for <see cref="IAzureSubscriptionIdentifier" />
/// Contains information about an Azure subscription identifier
/// </summary>
public class AzureSubscriptionIdentifier : IAzureSubscriptionIdentifier
{
/// <summary>
/// Default constructor to initialize the subscription identifier
/// </summary>
public AzureSubscriptionIdentifier(IAzureUserAccount userAccount, string tenantId, string subscriptionId, Uri serviceManagementEndpoint)
{
UserAccount = userAccount;
TenantId = tenantId;
SubscriptionId = subscriptionId;
ServiceManagementEndpoint = serviceManagementEndpoint;
}
/// <summary>
/// Returns true if given subscription identifier equals this class
/// </summary>
public bool Equals(IAzureSubscriptionIdentifier other)
{
return other != null &&
CommonUtil.SameString(SubscriptionId, other.SubscriptionId) &&
CommonUtil.SameUri(ServiceManagementEndpoint, other.ServiceManagementEndpoint);
}
public IAzureUserAccount UserAccount
{
get;
private set;
}
/// <summary>
/// Returns the endpoint url used by the identifier
/// </summary>
public Uri ServiceManagementEndpoint
{
get;
private set;
}
/// <summary>
/// Subscription id
/// </summary>
public string SubscriptionId
{
get;
private set;
}
/// <summary>
/// The ID of the tenant this subscription comes from
/// </summary>
public string TenantId
{
get;
private set;
}
}
}