Skip to content

Commit

Permalink
Added Resource base types to Common library
Browse files Browse the repository at this point in the history
  • Loading branch information
stankovski committed Mar 30, 2015
1 parent 26af009 commit bf4b786
Show file tree
Hide file tree
Showing 6 changed files with 311 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/Common/Common.csproj
Expand Up @@ -27,6 +27,9 @@
<Compile Include="Models\OperationStatus.cs" />
<Compile Include="Models\OperationStatusResponse.cs" />
<Compile Include="Handlers\ClientRequestTrackingHandler.cs" />
<Compile Include="Models\ResourceBase.cs" />
<Compile Include="Models\ResourceBaseExtended.cs" />
<Compile Include="Models\ResourceIdentity.cs" />
<Compile Include="OData\FilterParameterAttribute.cs" />
<Compile Include="OData\FilterString.cs" />
<Compile Include="OData\UrlExpressionVisitor.cs" />
Expand Down
2 changes: 1 addition & 1 deletion src/Common/Microsoft.Azure.Common.nuget.proj
Expand Up @@ -5,7 +5,7 @@
Microsoft.Azure.Common
-->
<SdkNuGetPackage Include="Microsoft.Azure.Common">
<PackageVersion>2.0.4</PackageVersion>
<PackageVersion>2.1.0</PackageVersion>

<Folder>$(MSBuildThisFileDirectory)</Folder>
</SdkNuGetPackage>
Expand Down
77 changes: 77 additions & 0 deletions src/Common/Models/ResourceBase.cs
@@ -0,0 +1,77 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//

// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using System;
using System.Collections.Generic;
using Hyak.Common;

namespace Microsoft.Azure
{
/// <summary>
/// Resource information.
/// </summary>
public partial class ResourceBase
{
private string _location;

/// <summary>
/// Required. Gets or sets the location of the resource.
/// </summary>
public string Location
{
get { return this._location; }
set { this._location = value; }
}

private IDictionary<string, string> _tags;

/// <summary>
/// Optional. Gets or sets the tags attached to the resource.
/// </summary>
public IDictionary<string, string> Tags
{
get { return this._tags; }
set { this._tags = value; }
}

/// <summary>
/// Initializes a new instance of the ResourceBase class.
/// </summary>
public ResourceBase()
{
this.Tags = new LazyDictionary<string, string>();
}

/// <summary>
/// Initializes a new instance of the ResourceBase class with required
/// arguments.
/// </summary>
public ResourceBase(string location)
: this()
{
if (location == null)
{
throw new ArgumentNullException("location");
}
this.Location = location;
}
}
}
85 changes: 85 additions & 0 deletions src/Common/Models/ResourceBaseExtended.cs
@@ -0,0 +1,85 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//

// Warning: This code was generated by a tool.
//
// Changes to this file may cause incorrect behavior and will be lost if the
// code is regenerated.

using System;

namespace Microsoft.Azure
{
/// <summary>
/// Resource information with extended details.
/// </summary>
public partial class ResourceBaseExtended : ResourceBase
{
private string _id;

/// <summary>
/// Optional. Gets or sets the ID of the resource.
/// </summary>
public string Id
{
get { return this._id; }
set { this._id = value; }
}

private string _name;

/// <summary>
/// Optional. Gets or sets the name of the resource.
/// </summary>
public string Name
{
get { return this._name; }
set { this._name = value; }
}

private string _type;

/// <summary>
/// Optional. Gets or sets the type of the resource.
/// </summary>
public string Type
{
get { return this._type; }
set { this._type = value; }
}

/// <summary>
/// Initializes a new instance of the ResourceBaseExtended class.
/// </summary>
public ResourceBaseExtended()
{
}

/// <summary>
/// Initializes a new instance of the ResourceBaseExtended class with
/// required arguments.
/// </summary>
public ResourceBaseExtended(string location)
: this()
{
if (location == null)
{
throw new ArgumentNullException("location");
}
this.Location = location;
}
}
}
143 changes: 143 additions & 0 deletions src/Common/Models/ResourceIdentity.cs
@@ -0,0 +1,143 @@
//
// Copyright (c) Microsoft and contributors. All rights reserved.
//
// 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.
//

namespace Microsoft.Azure
{
/// <summary>
/// Resource identity.
/// </summary>
public partial class ResourceIdentity
{
private string _parentResourcePath;

/// <summary>
/// Optional. Gets or sets parent resource path (optional).
/// </summary>
public string ParentResourcePath
{
get { return this._parentResourcePath; }
set { this._parentResourcePath = value; }
}

private string _resourceName;

/// <summary>
/// Required. Gets or sets resource name.
/// </summary>
public string ResourceName
{
get { return this._resourceName; }
set { this._resourceName = value; }
}

private string _resourceProviderApiVersion;

/// <summary>
/// Required. Gets or sets API version of the resource provider.
/// </summary>
public string ResourceProviderApiVersion
{
get { return this._resourceProviderApiVersion; }
set { this._resourceProviderApiVersion = value; }
}

private string _resourceProviderNamespace;

/// <summary>
/// Required. Gets or sets namespace of the resource provider.
/// </summary>
public string ResourceProviderNamespace
{
get { return this._resourceProviderNamespace; }
set { this._resourceProviderNamespace = value; }
}

private string _resourceType;

/// <summary>
/// Required. Gets or sets resource type.
/// </summary>
public string ResourceType
{
get { return this._resourceType; }
set { this._resourceType = value; }
}

/// <summary>
/// Initializes a new instance of the ResourceIdentity class.
/// </summary>
public ResourceIdentity()
{
}

/// <summary>
/// Initializes a new instance of the ResourceIdentity class.
/// </summary>
public ResourceIdentity(string name, string resourceType, string apiVersion)
{
ResourceName = name;
ResourceProviderNamespace = GetProviderFromResourceType(resourceType);
ResourceType = GetTypeFromResourceType(resourceType);
ResourceProviderApiVersion = apiVersion;
}

/// <summary>
/// Returns provider string from resource type.
/// </summary>
/// <param name="resourceType">Resource type.</param>
/// <returns>Provider</returns>
public static string GetProviderFromResourceType(string resourceType)
{
if (resourceType == null)
{
return null;
}

int indexOfSlash = resourceType.IndexOf('/');
if (indexOfSlash < 0)
{
return string.Empty;
}
else
{
return resourceType.Substring(0, indexOfSlash);
}
}

/// <summary>
/// Returns type string from resource type.
/// </summary>
/// <param name="resourceType">Resource type.</param>
/// <returns>Type</returns>
public static string GetTypeFromResourceType(string resourceType)
{
if (resourceType == null)
{
return null;
}

int lastIndexOfSlash = resourceType.LastIndexOf('/');
if (lastIndexOfSlash < 0)
{
return string.Empty;
}
else
{
return resourceType.Substring(lastIndexOfSlash + 1);
}
}
}
}
4 changes: 2 additions & 2 deletions src/Common/Properties/AssemblyInfo.cs
Expand Up @@ -18,5 +18,5 @@
//This file is shared with Common.NetFramework to provide consistent file version.
//Do not put in extra assembly metadatas here; rather put them in AssemblyAdditionalInfo.cs.
//Also merge AssemblyAdditionalInfo.cs into the file once we delete the Common.NetFramework.
[assembly: AssemblyFileVersion("2.0.4.0")]
[assembly: AssemblyVersion("2.0.0.0")]
[assembly: AssemblyFileVersion("2.1.0.0")]
[assembly: AssemblyVersion("2.0.0.0")]

0 comments on commit bf4b786

Please sign in to comment.