Skip to content

Commit

Permalink
Support multiple architectures for genes (#86)
Browse files Browse the repository at this point in the history
* Update REST client
* Add user-friendly formatting for gene information
  • Loading branch information
ChristopherMann authored Oct 28, 2024
1 parent 4843c99 commit 99de852
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ public static OperationTaskReference OperationTaskReference(string id = null, Ta
/// <param name="geneType"></param>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <param name="size"></param>
/// <param name="hash"></param>
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/> or <paramref name="hash"/> is null. </exception>
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/>, <paramref name="architecture"/> or <paramref name="hash"/> is null. </exception>
/// <returns> A new <see cref="Models.Gene"/> instance for mocking. </returns>
public static Gene Gene(string id = null, GeneType geneType = default, string geneSet = null, string name = null, long size = default, string hash = null)
public static Gene Gene(string id = null, GeneType geneType = default, string geneSet = null, string name = null, string architecture = null, long size = default, string hash = null)
{
if (id == null)
{
Expand All @@ -160,6 +161,10 @@ public static Gene Gene(string id = null, GeneType geneType = default, string ge
{
throw new ArgumentNullException(nameof(name));
}
if (architecture == null)
{
throw new ArgumentNullException(nameof(architecture));
}
if (hash == null)
{
throw new ArgumentNullException(nameof(hash));
Expand All @@ -170,6 +175,7 @@ public static Gene Gene(string id = null, GeneType geneType = default, string ge
geneType,
geneSet,
name,
architecture,
size,
hash);
}
Expand All @@ -181,12 +187,13 @@ public static Gene Gene(string id = null, GeneType geneType = default, string ge
/// <param name="dataStore"></param>
/// <param name="project"></param>
/// <param name="environment"></param>
/// <param name="gene"></param>
/// <param name="path"></param>
/// <param name="sizeBytes"></param>
/// <param name="parentId"></param>
/// <param name="attachedCatlets"></param>
/// <returns> A new <see cref="Models.VirtualDisk"/> instance for mocking. </returns>
public static VirtualDisk VirtualDisk(string id = null, string name = null, string location = null, string dataStore = null, Project project = null, string environment = null, string path = null, long? sizeBytes = null, string parentId = null, IEnumerable<VirtualDiskAttachedCatlet> attachedCatlets = null)
public static VirtualDisk VirtualDisk(string id = null, string name = null, string location = null, string dataStore = null, Project project = null, string environment = null, VirtualDiskGeneInfo gene = null, string path = null, long? sizeBytes = null, string parentId = null, IEnumerable<VirtualDiskAttachedCatlet> attachedCatlets = null)
{
attachedCatlets ??= new List<VirtualDiskAttachedCatlet>();

Expand All @@ -197,12 +204,37 @@ public static VirtualDisk VirtualDisk(string id = null, string name = null, stri
dataStore,
project,
environment,
gene,
path,
sizeBytes,
parentId,
attachedCatlets?.ToList());
}

/// <summary> Initializes a new instance of <see cref="Models.VirtualDiskGeneInfo"/>. </summary>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <exception cref="ArgumentNullException"> <paramref name="geneSet"/>, <paramref name="name"/> or <paramref name="architecture"/> is null. </exception>
/// <returns> A new <see cref="Models.VirtualDiskGeneInfo"/> instance for mocking. </returns>
public static VirtualDiskGeneInfo VirtualDiskGeneInfo(string geneSet = null, string name = null, string architecture = null)
{
if (geneSet == null)
{
throw new ArgumentNullException(nameof(geneSet));
}
if (name == null)
{
throw new ArgumentNullException(nameof(name));
}
if (architecture == null)
{
throw new ArgumentNullException(nameof(architecture));
}

return new VirtualDiskGeneInfo(geneSet, name, architecture);
}

/// <summary> Initializes a new instance of <see cref="Models.VirtualDiskAttachedCatlet"/>. </summary>
/// <param name="type"></param>
/// <param name="catletId"></param>
Expand Down Expand Up @@ -340,12 +372,13 @@ public static CatletDrive CatletDrive(CatletDriveType type = default, string att
/// <param name="geneType"></param>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <param name="size"></param>
/// <param name="hash"></param>
/// <param name="catlets"></param>
/// <param name="disks"></param>
/// <returns> A new <see cref="Models.GeneWithUsage"/> instance for mocking. </returns>
public static GeneWithUsage GeneWithUsage(string id = null, GeneType geneType = default, string geneSet = null, string name = null, long size = default, string hash = null, IEnumerable<string> catlets = null, IEnumerable<string> disks = null)
public static GeneWithUsage GeneWithUsage(string id = null, GeneType geneType = default, string geneSet = null, string name = null, string architecture = null, long size = default, string hash = null, IEnumerable<string> catlets = null, IEnumerable<string> disks = null)
{
catlets ??= new List<string>();
disks ??= new List<string>();
Expand All @@ -355,6 +388,7 @@ public static GeneWithUsage GeneWithUsage(string id = null, GeneType geneType =
geneType,
geneSet,
name,
architecture,
size,
hash,
catlets?.ToList(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ internal static Gene DeserializeGene(JsonElement element)
GeneType geneType = default;
string geneSet = default;
string name = default;
string architecture = default;
long size = default;
string hash = default;
foreach (var property in element.EnumerateObject())
Expand All @@ -46,6 +47,11 @@ internal static Gene DeserializeGene(JsonElement element)
name = property.Value.GetString();
continue;
}
if (property.NameEquals("architecture"u8))
{
architecture = property.Value.GetString();
continue;
}
if (property.NameEquals("size"u8))
{
size = property.Value.GetInt64();
Expand All @@ -62,6 +68,7 @@ internal static Gene DeserializeGene(JsonElement element)
geneType,
geneSet,
name,
architecture,
size,
hash);
}
Expand Down
9 changes: 7 additions & 2 deletions src/Eryph.ComputeClient/Generated/Models/Gene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,23 @@ public partial class Gene
/// <param name="geneType"></param>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <param name="size"></param>
/// <param name="hash"></param>
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/> or <paramref name="hash"/> is null. </exception>
internal Gene(string id, GeneType geneType, string geneSet, string name, long size, string hash)
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/>, <paramref name="architecture"/> or <paramref name="hash"/> is null. </exception>
internal Gene(string id, GeneType geneType, string geneSet, string name, string architecture, long size, string hash)
{
Argument.AssertNotNull(id, nameof(id));
Argument.AssertNotNull(geneSet, nameof(geneSet));
Argument.AssertNotNull(name, nameof(name));
Argument.AssertNotNull(architecture, nameof(architecture));
Argument.AssertNotNull(hash, nameof(hash));

Id = id;
GeneType = geneType;
GeneSet = geneSet;
Name = name;
Architecture = architecture;
Size = size;
Hash = hash;
}
Expand All @@ -43,6 +46,8 @@ internal Gene(string id, GeneType geneType, string geneSet, string name, long si
public string GeneSet { get; }
/// <summary> Gets the name. </summary>
public string Name { get; }
/// <summary> Gets the architecture. </summary>
public string Architecture { get; }
/// <summary> Gets the size. </summary>
public long Size { get; }
/// <summary> Gets the hash. </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal static GeneWithUsage DeserializeGeneWithUsage(JsonElement element)
GeneType geneType = default;
string geneSet = default;
string name = default;
string architecture = default;
long size = default;
string hash = default;
IReadOnlyList<string> catlets = default;
Expand All @@ -49,6 +50,11 @@ internal static GeneWithUsage DeserializeGeneWithUsage(JsonElement element)
name = property.Value.GetString();
continue;
}
if (property.NameEquals("architecture"u8))
{
architecture = property.Value.GetString();
continue;
}
if (property.NameEquals("size"u8))
{
size = property.Value.GetInt64();
Expand Down Expand Up @@ -93,6 +99,7 @@ internal static GeneWithUsage DeserializeGeneWithUsage(JsonElement element)
geneType,
geneSet,
name,
architecture,
size,
hash,
catlets ?? new ChangeTrackingList<string>(),
Expand Down
13 changes: 10 additions & 3 deletions src/Eryph.ComputeClient/Generated/Models/GeneWithUsage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@ public partial class GeneWithUsage
/// <param name="geneType"></param>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <param name="size"></param>
/// <param name="hash"></param>
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/> or <paramref name="hash"/> is null. </exception>
internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name, long size, string hash)
/// <exception cref="ArgumentNullException"> <paramref name="id"/>, <paramref name="geneSet"/>, <paramref name="name"/>, <paramref name="architecture"/> or <paramref name="hash"/> is null. </exception>
internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name, string architecture, long size, string hash)
{
Argument.AssertNotNull(id, nameof(id));
Argument.AssertNotNull(geneSet, nameof(geneSet));
Argument.AssertNotNull(name, nameof(name));
Argument.AssertNotNull(architecture, nameof(architecture));
Argument.AssertNotNull(hash, nameof(hash));

Id = id;
GeneType = geneType;
GeneSet = geneSet;
Name = name;
Architecture = architecture;
Size = size;
Hash = hash;
Catlets = new ChangeTrackingList<string>();
Expand All @@ -43,16 +46,18 @@ internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name
/// <param name="geneType"></param>
/// <param name="geneSet"></param>
/// <param name="name"></param>
/// <param name="architecture"></param>
/// <param name="size"></param>
/// <param name="hash"></param>
/// <param name="catlets"></param>
/// <param name="disks"></param>
internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name, long size, string hash, IReadOnlyList<string> catlets, IReadOnlyList<string> disks)
internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name, string architecture, long size, string hash, IReadOnlyList<string> catlets, IReadOnlyList<string> disks)
{
Id = id;
GeneType = geneType;
GeneSet = geneSet;
Name = name;
Architecture = architecture;
Size = size;
Hash = hash;
Catlets = catlets;
Expand All @@ -67,6 +72,8 @@ internal GeneWithUsage(string id, GeneType geneType, string geneSet, string name
public string GeneSet { get; }
/// <summary> Gets the name. </summary>
public string Name { get; }
/// <summary> Gets the architecture. </summary>
public string Architecture { get; }
/// <summary> Gets the size. </summary>
public long Size { get; }
/// <summary> Gets the hash. </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ internal static VirtualDisk DeserializeVirtualDisk(JsonElement element)
string dataStore = default;
Project project = default;
string environment = default;
VirtualDiskGeneInfo gene = default;
string path = default;
long? sizeBytes = default;
string parentId = default;
Expand Down Expand Up @@ -61,6 +62,15 @@ internal static VirtualDisk DeserializeVirtualDisk(JsonElement element)
environment = property.Value.GetString();
continue;
}
if (property.NameEquals("gene"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
{
continue;
}
gene = VirtualDiskGeneInfo.DeserializeVirtualDiskGeneInfo(property.Value);
continue;
}
if (property.NameEquals("path"u8))
{
if (property.Value.ValueKind == JsonValueKind.Null)
Expand Down Expand Up @@ -113,6 +123,7 @@ internal static VirtualDisk DeserializeVirtualDisk(JsonElement element)
dataStore,
project,
environment,
gene,
path,
sizeBytes,
parentId,
Expand Down
6 changes: 5 additions & 1 deletion src/Eryph.ComputeClient/Generated/Models/VirtualDisk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,20 @@ internal VirtualDisk(string id, string name, string location, string dataStore,
/// <param name="dataStore"></param>
/// <param name="project"></param>
/// <param name="environment"></param>
/// <param name="gene"></param>
/// <param name="path"></param>
/// <param name="sizeBytes"></param>
/// <param name="parentId"></param>
/// <param name="attachedCatlets"></param>
internal VirtualDisk(string id, string name, string location, string dataStore, Project project, string environment, string path, long? sizeBytes, string parentId, IReadOnlyList<VirtualDiskAttachedCatlet> attachedCatlets)
internal VirtualDisk(string id, string name, string location, string dataStore, Project project, string environment, VirtualDiskGeneInfo gene, string path, long? sizeBytes, string parentId, IReadOnlyList<VirtualDiskAttachedCatlet> attachedCatlets)
{
Id = id;
Name = name;
Location = location;
DataStore = dataStore;
Project = project;
Environment = environment;
Gene = gene;
Path = path;
SizeBytes = sizeBytes;
ParentId = parentId;
Expand All @@ -76,6 +78,8 @@ internal VirtualDisk(string id, string name, string location, string dataStore,
public Project Project { get; }
/// <summary> Gets the environment. </summary>
public string Environment { get; }
/// <summary> Gets the gene. </summary>
public VirtualDiskGeneInfo Gene { get; }
/// <summary> Gets the path. </summary>
public string Path { get; }
/// <summary> Gets the size bytes. </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System.Text.Json;
using Azure;

namespace Eryph.ComputeClient.Models
{
public partial class VirtualDiskGeneInfo
{
internal static VirtualDiskGeneInfo DeserializeVirtualDiskGeneInfo(JsonElement element)
{
if (element.ValueKind == JsonValueKind.Null)
{
return null;
}
string geneSet = default;
string name = default;
string architecture = default;
foreach (var property in element.EnumerateObject())
{
if (property.NameEquals("gene_set"u8))
{
geneSet = property.Value.GetString();
continue;
}
if (property.NameEquals("name"u8))
{
name = property.Value.GetString();
continue;
}
if (property.NameEquals("architecture"u8))
{
architecture = property.Value.GetString();
continue;
}
}
return new VirtualDiskGeneInfo(geneSet, name, architecture);
}

/// <summary> Deserializes the model from a raw response. </summary>
/// <param name="response"> The response to deserialize the model from. </param>
internal static VirtualDiskGeneInfo FromResponse(Response response)
{
using var document = JsonDocument.Parse(response.Content);
return DeserializeVirtualDiskGeneInfo(document.RootElement);
}
}
}
Loading

0 comments on commit 99de852

Please sign in to comment.