Skip to content

Commit

Permalink
update based on feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
wiboris committed Jun 14, 2024
1 parent 451fe5d commit b68657b
Show file tree
Hide file tree
Showing 25 changed files with 65 additions and 250 deletions.
5 changes: 1 addition & 4 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,7 @@
# ServiceOwners: @rpsqrd @edyoung

# PRLabel: %Batch
/sdk/batch/ @wiboris @dpwatrous

# PRLabel: %Batch
/sdk/batch/Azure.Compute.Batch @wiboris @dpwatrous
/sdk/batch/ @wiboris @dpwatrous @wanghoppe @skapur12

# ServiceLabel: %Batch
# ServiceOwners: @wiboris @dpwatrous
Expand Down
10 changes: 2 additions & 8 deletions sdk/batch/Azure.Compute.Batch/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,9 @@

## 1.0.0-beta.1 (2024-06-01)

### Breaking Changes
### Features Added

New design of track 2 initial commit.

### Package Name

The package name has been changed from `Microsoft.Azure.Batch` to `Azure.Compute.Batch`.

### General New Features
New design of track 2 initial commit. This package, `Azure.Compute.Batch`, replaces `Microsoft.Azure.Batch`.

This package follows the [new Azure SDK guidelines](https://azure.github.io/azure-sdk/general_introduction.html), and provides many core capabilities.

Expand Down
4 changes: 2 additions & 2 deletions sdk/batch/Azure.Compute.Batch/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Azure Compute.Batch client library for .NET
# Azure Batch client library for .NET

Azure.Compute.Batch is a managed service that helps developers get secret simply and securely.
Azur Batch is a managed service that helps developers get secret simply and securely.

Use the client library for to:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,10 +478,10 @@ internal BatchErrorMessage() { }
public partial class BatchFileProperties
{
internal BatchFileProperties() { }
public bool BatchFileIsDirectory { get { throw null; } }
public string BatchFileMode { get { throw null; } }
public string BatchFileUrl { get { throw null; } }
public System.DateTime CreationTime { get { throw null; } }
public string FileUrl { get { throw null; } }
public bool IsDirectory { get { throw null; } }
public string Mode { get { throw null; } }
}
public partial class BatchJob : System.ClientModel.Primitives.IJsonModel<Azure.Compute.Batch.BatchJob>, System.ClientModel.Primitives.IPersistableModel<Azure.Compute.Batch.BatchJob>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ namespace Azure.Compute.Batch.Custom
/// </summary>
internal class BatchNamedKeyCredentialPolicy : HttpPipelineSynchronousPolicy
{
/// <summary>
/// Whether to always add the x-ms-date header.
/// </summary>
private const bool IncludeXMsDate = true;

/// <summary>
/// Batch Account name
/// </summary>
Expand Down Expand Up @@ -63,12 +58,8 @@ public override void OnSendingRequest(HttpMessage message)
{
base.OnSendingRequest(message);

// Add a x-ms-date header
if (IncludeXMsDate)
{
var date = DateTimeOffset.UtcNow.ToString("r", CultureInfo.InvariantCulture);
message.Request.Headers.SetValue(Constants.HeaderNames.Date, date);
}
var date = DateTimeOffset.UtcNow.ToString("r", CultureInfo.InvariantCulture);
message.Request.Headers.SetValue(Constants.HeaderNames.OCPDate, date);

var stringToSign = BuildStringToSign(message);
var signature = ComputeSasSignature(stringToSign);
Expand Down Expand Up @@ -107,7 +98,7 @@ private string BuildStringToSign(HttpMessage message)
stringBuilder.Append(contentLengthString == "0" ? "" : contentLengthString ?? "").Append('\n');
stringBuilder.Append(contentMD5 ?? "");// todo: fix base 64 VALUE
stringBuilder.Append('\n');
stringBuilder.Append(contentType ?? "").Append('\n'); // Empty date because x-ms-date is expected (as per web page above))
stringBuilder.Append(contentType ?? "").Append('\n'); // Empty date because ocp-date is expected (as per web page above))
stringBuilder.Append('\n');
stringBuilder.Append(ifModifiedSince ?? "").Append('\n');
stringBuilder.Append(ifMatch ?? "").Append('\n');
Expand All @@ -122,7 +113,7 @@ private string BuildStringToSign(HttpMessage message)
// If you change this method, make sure live tests are passing before merging PR.
private void BuildCanonicalizedHeaders(StringBuilder stringBuilder, HttpMessage message)
{
// Grab all the "x-ms-*" headers, trim whitespace, lowercase, sort,
// Grab all the "ocp-*" headers, trim whitespace, lowercase, sort,
// and combine them with their values (separated by a colon).
var headers = new List<HttpHeader>();
foreach (var header in message.Request.Headers)
Expand All @@ -148,14 +139,14 @@ private void BuildCanonicalizedHeaders(StringBuilder stringBuilder, HttpMessage
// If you change this method, make sure live tests are passing before merging PR.
private void BuildCanonicalizedResource(StringBuilder stringBuilder, Uri resource)
{
// https://docs.microsoft.com/en-us/rest/api/Batchservices/authentication-for-the-azure-Batch-services
// https://learn.microsoft.com/rest/api/batchservice/authenticate-requests-to-the-azure-batch-service
stringBuilder.Append('/');
stringBuilder.Append(AccountName);
if (resource.AbsolutePath.Length > 0)
{
// Any portion of the CanonicalizedResource string that is derived from
// the resource's URI should be encoded exactly as it is in the URI.
// -- https://msdn.microsoft.com/en-gb/library/azure/dd179428.aspx
// -- https://msdn.microsoft.com/library/azure/dd179428.aspx
stringBuilder.Append(resource.AbsolutePath);//EscapedPath()
}
else
Expand Down
2 changes: 1 addition & 1 deletion sdk/batch/Azure.Compute.Batch/src/Custom/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ internal static class Constants
internal static class HeaderNames
{
public const string OCPPrefix = "ocp-";
public const string Date = "ocp-date";
public const string OCPDate = "ocp-date";
public const string SharedKey = "SharedKey";
public const string Authorization = "Authorization";
public const string ContentEncoding = "Content-Encoding";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System;
using System.Collections.Generic;
using System.Globalization;
Expand All @@ -19,20 +15,20 @@ public partial class BatchFileProperties
{
internal BatchFileProperties(bool batchFileIsDirectory, string batchFileMode, string batchFileUrl, DateTime creationTime)
{
BatchFileIsDirectory = batchFileIsDirectory;
BatchFileMode = batchFileMode;
BatchFileUrl = batchFileUrl;
IsDirectory = batchFileIsDirectory;
Mode = batchFileMode;
FileUrl = batchFileUrl;
CreationTime = creationTime;
}

/// <summary> Whether the object represents a directory. </summary>
public bool BatchFileIsDirectory { get; }
public bool IsDirectory { get; }

/// <summary> The file mode attribute in octal format. </summary>
public string BatchFileMode { get; }
public string Mode { get; }

/// <summary> The URL of the file. </summary>
public string BatchFileUrl { get; }
public string FileUrl { get; }

/// <summary> The file creation time. </summary>
public DateTime CreationTime { get; }
Expand All @@ -41,21 +37,21 @@ internal BatchFileProperties(bool batchFileIsDirectory, string batchFileMode, st
/// <param name="response"> The response to deserialize the model from. </param>
internal static BatchFileProperties FromResponse(Response response)
{
string batchFileIsDirectoryStr = "";
bool batchFileIsDirectory = false;
string batchFileMode = "";
string batchFileUrl = "";
string isDirectoryStr = "";
bool isDirectory = false;
string mode = "";
string fileUrl = "";
string creationTimeStr = "";

response.Headers.TryGetValue("ocp-creation-time", out creationTimeStr);
response.Headers.TryGetValue("ocp-batch-file-isdirectory", out batchFileIsDirectoryStr);
response.Headers.TryGetValue("ocp-batch-file-url", out batchFileUrl);
response.Headers.TryGetValue("ocp-batch-file-mode", out batchFileMode);
response.Headers.TryGetValue("ocp-batch-file-isdirectory", out isDirectoryStr);
response.Headers.TryGetValue("ocp-batch-file-url", out fileUrl);
response.Headers.TryGetValue("ocp-batch-file-mode", out mode);

Boolean.TryParse(batchFileIsDirectoryStr, out batchFileIsDirectory);
Boolean.TryParse(isDirectoryStr, out isDirectory);
DateTime creationTime = DateTime.Parse(creationTimeStr, CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal);

return new BatchFileProperties(batchFileIsDirectory, batchFileMode, batchFileUrl, creationTime);
return new BatchFileProperties(isDirectory, mode, fileUrl, creationTime);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@

namespace Azure.Compute.Batch
{
/// <summary>
/// Customizing the Serialization of BatchPoolReplaceContent to handle the missing variable certificateReferences. This
/// is a work around will be removed in the next release
/// </summary>
public partial class BatchPoolReplaceContent : IUtf8JsonSerializable, IJsonModel<BatchPoolReplaceContent>
{
void global::Azure.Core.IUtf8JsonSerializable.Write(Utf8JsonWriter writer) => ((IJsonModel<BatchPoolReplaceContent>)this).Write(writer, ModelSerializationExtensions.WireOptions);
Expand Down

This file was deleted.

9 changes: 1 addition & 8 deletions sdk/batch/Azure.Compute.Batch/src/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,4 @@
using System.Reflection;
using System.Security.Cryptography;

[assembly: SuppressMessage("Usage", "AZC0030:Use one of the following pre-approved namespace groups (https://azure.github.io/azure-sdk/registered_namespaces.html): Azure.AI, Azure.Analytics, Azure.Communication, Azure.Containers, Azure.Core.Expressions, Azure.Data, Azure.DigitalTwins, Azure.Identity, Azure.IoT, Azure.Learn, Azure.Management, Azure.Media, Azure.Messaging, Azure.MixedReality, Azure.Monitor, Azure.ResourceManager, Azure.Search, Azure.Security, Azure.Storage, Azure.Template, Microsoft.Extensions.Azure", Justification = "<Pending>", Scope = "namespaceanddescendants", Target = "~N:Azure.Compute.Batch")]
[assembly: SuppressMessage("Usage", "AZC0001:Use one of the following pre-approved namespace groups (https://azure.github.io/azure-sdk/registered_namespaces.html): Azure.AI, Azure.Analytics, Azure.Communication, Azure.Containers, Azure.Core.Expressions, Azure.Data, Azure.DigitalTwins, Azure.Identity, Azure.IoT, Azure.Learn, Azure.Management, Azure.Media, Azure.Messaging, Azure.MixedReality, Azure.Monitor, Azure.ResourceManager, Azure.Search, Azure.Security, Azure.Storage, Azure.Template, Microsoft.Extensions.Azure", Justification = "<Pending>", Scope = "namespaceanddescendants", Target = "~N:Azure.Compute.Batch")]
[assembly: SuppressMessage("Usage", "AZC0002:DO ensure all service methods, both asynchronous and synchronous, take an optional CancellationToken parameter called cancellationToken.", Justification = "<Pending>", Scope = "namespaceanddescendants", Target = "~N:Azure.Compute.Batch")]
[assembly: SuppressMessage("Usage", "AZC0012:Avoid single word type names", Justification = "<Pending>", Scope = "type", Target = "~T:Azure.Compute.Batch.Schedule")]
[assembly: SuppressMessage("Usage", "AZC0001:Use one of the following pre-approved namespace groups (https://azure.github.io/azure-sdk/registered_namespaces.html): Azure.AI, Azure.Analytics, Azure.Communication, Azure.Containers, Azure.Core.Expressions, Azure.Data, Azure.DigitalTwins, Azure.Identity, Azure.IoT, Azure.Learn, Azure.Management, Azure.Media, Azure.Messaging, Azure.MixedReality, Azure.Monitor, Azure.ResourceManager, Azure.Search, Azure.Security, Azure.Storage, Azure.Template, Microsoft.Extensions.Azure", Justification = "<Pending>", Scope = "namespace", Target = "~N:Azure.Compute.Batch.Models")]
[assembly: SuppressMessage("Usage", "AZC0012:Avoid single word type names", Justification = "<Pending>", Scope = "type", Target = "~T:Azure.Compute.Batch.Models.Schedule")]
[assembly: SuppressMessage("Usage", "AZC0012:Avoid single word type names", Justification = "<Pending>", Scope = "type", Target = "~T:Azure.Compute.Batch.Models.Schedule")]
[assembly: SuppressMessage("Usage", "AZC0012:Avoid single word type names", Justification = "<Pending>", Scope = "type", Target = "~T:Azure.Compute.Batch.Models.Schedule")]
[assembly: SuppressMessage("Usage", "AZC0030:Model name 'ExitOptions' ends with 'Options'. Suggest to rename it to 'ExitConfig' or any other appropriate name.", Justification = "SDK Review Approved, ExitCodeMapping and ExitCodeRangeMapping models have parameter called exitOptions which we wanted to match", Scope = "namespaceanddescendants", Target = "~N:Azure.Compute.Batch")]
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
// Replace Microsoft.Test with the correct resource provider namepace for your service and uncomment.
// See https://docs.microsoft.com/en-us/azure/azure-resource-manager/management/azure-services-resource-providers
// for the list of possible values.
[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Template")]
[assembly: Azure.Core.AzureResourceProviderNamespace("Microsoft.Batch")]
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,4 @@
<ItemGroup>
<PackageReference Include="Azure.Identity" />
</ItemGroup>

<ItemGroup>
<Folder Include="SessionRecords\" />
</ItemGroup>
</Project>

This file was deleted.

21 changes: 0 additions & 21 deletions sdk/batch/Azure.Compute.Batch/tests/Infrastructure/DetailLevel.cs

This file was deleted.

34 changes: 0 additions & 34 deletions sdk/batch/Azure.Compute.Batch/tests/Infrastructure/IRefreshable.cs

This file was deleted.

12 changes: 0 additions & 12 deletions sdk/batch/Azure.Compute.Batch/tests/Infrastructure/PoolFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@ protected PoolFixture(string poolId, BatchClient batchClient, bool isPlayback)
PlayBack = isPlayback;
}

public async void Dispose()
{
//This should not throw so swallow exceptions?
try
{
await this.client.DeletePoolAsync(PoolId);
}
catch (Exception)
{
}
}

public async Task<BatchPool> FindPoolIfExistsAsync()
{
// reuse existing pool if it exists
Expand Down
15 changes: 0 additions & 15 deletions sdk/batch/Azure.Compute.Batch/tests/Infrastructure/PoolUtilites.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

namespace Azure.Compute.Batch.Tests.Infrastructure
{
internal class IaasLinuxPoolFixture : PoolFixture
internal class WindowsPoolFixture : PoolFixture
{
public IaasLinuxPoolFixture(BatchClient batchClient, string poolID, bool isPlayback) : base(poolID, batchClient, isPlayback) { }
public WindowsPoolFixture(BatchClient batchClient, string poolID, bool isPlayback) : base(poolID, batchClient, isPlayback) { }

public async Task<BatchPool> CreatePoolAsync(int targetDedicatedNodes = 1)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public BatchJobIntegrationTests(bool isAsync) : base(isAsync)
public async Task JobOperations()
{
var client = CreateBatchClient();
IaasLinuxPoolFixture iaasWindowsPoolFixture = new IaasLinuxPoolFixture(client, "JobOperations", isPlayBack());
WindowsPoolFixture iaasWindowsPoolFixture = new WindowsPoolFixture(client, "JobOperations", isPlayBack());
string poolID = iaasWindowsPoolFixture.PoolId;
string jobID = "batchJob1";
string taskID = "Task1";
Expand Down Expand Up @@ -131,7 +131,7 @@ public async Task JobOperations()
public async Task PatchJob()
{
var client = CreateBatchClient();
IaasLinuxPoolFixture iaasWindowsPoolFixture = new IaasLinuxPoolFixture(client, "PatchJob", isPlayBack());
WindowsPoolFixture iaasWindowsPoolFixture = new WindowsPoolFixture(client, "PatchJob", isPlayBack());
string poolID = iaasWindowsPoolFixture.PoolId;
string jobID = "batchJob2";
string commandLine = "cmd /c echo Hello World";
Expand Down
Loading

0 comments on commit b68657b

Please sign in to comment.