Skip to content
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

Add Helix sdk warnings for expiring queues #8270

Merged
merged 3 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,306 changes: 1,306 additions & 0 deletions src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/Aggregate.cs

Large diffs are not rendered by default.

252 changes: 252 additions & 0 deletions src/Microsoft.DotNet.Helix/Client/CSharp/generated-code/Analysis.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Azure;
using Azure.Core;



namespace Microsoft.DotNet.Helix.Client
{
public partial interface IAnalysis
{
Task SetReasonAsync(
string analysisName,
string analysisType,
Models.FailureReason body,
string job,
string workitem,
CancellationToken cancellationToken = default
);

Task<Newtonsoft.Json.Linq.JToken> GetDetailsAsync(
string analysisName,
string analysisType,
string job,
string workitem,
CancellationToken cancellationToken = default
);

}

internal partial class Analysis : IServiceOperations<HelixApi>, IAnalysis
{
public Analysis(HelixApi client)
{
Client = client ?? throw new ArgumentNullException(nameof(client));
}

public HelixApi Client { get; }

partial void HandleFailedRequest(RestApiException ex);

partial void HandleFailedSetReasonRequest(RestApiException ex);

public async Task SetReasonAsync(
string analysisName,
string analysisType,
Models.FailureReason body,
string job,
string workitem,
CancellationToken cancellationToken = default
)
{

if (string.IsNullOrEmpty(analysisName))
{
throw new ArgumentNullException(nameof(analysisName));
}

if (string.IsNullOrEmpty(analysisType))
{
throw new ArgumentNullException(nameof(analysisType));
}

if (body == default(Models.FailureReason))
{
throw new ArgumentNullException(nameof(body));
}

if (string.IsNullOrEmpty(job))
{
throw new ArgumentNullException(nameof(job));
}

if (string.IsNullOrEmpty(workitem))
{
throw new ArgumentNullException(nameof(workitem));
}

const string apiVersion = "2019-06-17";

var _baseUri = Client.Options.BaseUri;
var _url = new RequestUriBuilder();
_url.Reset(_baseUri);
_url.AppendPath(
"/api/analysis/{job}/{analysisType}/reason".Replace("{job}", Uri.EscapeDataString(Client.Serialize(job))).Replace("{analysisType}", Uri.EscapeDataString(Client.Serialize(analysisType))),
false);

if (!string.IsNullOrEmpty(workitem))
{
_url.AppendQuery("workitem", Client.Serialize(workitem));
}
if (!string.IsNullOrEmpty(analysisName))
{
_url.AppendQuery("analysisName", Client.Serialize(analysisName));
}
_url.AppendQuery("api-version", Client.Serialize(apiVersion));


using (var _req = Client.Pipeline.CreateRequest())
{
_req.Uri = _url;
_req.Method = RequestMethod.Put;

if (body != default(Models.FailureReason))
{
_req.Content = RequestContent.Create(Encoding.UTF8.GetBytes(Client.Serialize(body)));
_req.Headers.Add("Content-Type", "application/json; charset=utf-8");
}

using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
{
if (_res.Status < 200 || _res.Status >= 300)
{
await OnSetReasonFailed(_req, _res).ConfigureAwait(false);
}


return;
}
}
}

internal async Task OnSetReasonFailed(Request req, Response res)
{
string content = null;
if (res.ContentStream != null)
{
using (var reader = new StreamReader(res.ContentStream))
{
content = await reader.ReadToEndAsync().ConfigureAwait(false);
}
}

var ex = new RestApiException<Models.ApiError>(
req,
res,
content,
Client.Deserialize<Models.ApiError>(content)
);
HandleFailedSetReasonRequest(ex);
HandleFailedRequest(ex);
Client.OnFailedRequest(ex);
throw ex;
}

partial void HandleFailedGetDetailsRequest(RestApiException ex);

public async Task<Newtonsoft.Json.Linq.JToken> GetDetailsAsync(
string analysisName,
string analysisType,
string job,
string workitem,
CancellationToken cancellationToken = default
)
{

if (string.IsNullOrEmpty(analysisName))
{
throw new ArgumentNullException(nameof(analysisName));
}

if (string.IsNullOrEmpty(analysisType))
{
throw new ArgumentNullException(nameof(analysisType));
}

if (string.IsNullOrEmpty(job))
{
throw new ArgumentNullException(nameof(job));
}

if (string.IsNullOrEmpty(workitem))
{
throw new ArgumentNullException(nameof(workitem));
}

const string apiVersion = "2019-06-17";

var _baseUri = Client.Options.BaseUri;
var _url = new RequestUriBuilder();
_url.Reset(_baseUri);
_url.AppendPath(
"/api/analysis/{job}/{analysisType}".Replace("{job}", Uri.EscapeDataString(Client.Serialize(job))).Replace("{analysisType}", Uri.EscapeDataString(Client.Serialize(analysisType))),
false);

if (!string.IsNullOrEmpty(workitem))
{
_url.AppendQuery("workitem", Client.Serialize(workitem));
}
if (!string.IsNullOrEmpty(analysisName))
{
_url.AppendQuery("analysisName", Client.Serialize(analysisName));
}
_url.AppendQuery("api-version", Client.Serialize(apiVersion));


using (var _req = Client.Pipeline.CreateRequest())
{
_req.Uri = _url;
_req.Method = RequestMethod.Get;

using (var _res = await Client.SendAsync(_req, cancellationToken).ConfigureAwait(false))
{
if (_res.Status < 200 || _res.Status >= 300)
{
await OnGetDetailsFailed(_req, _res).ConfigureAwait(false);
}

if (_res.ContentStream == null)
{
await OnGetDetailsFailed(_req, _res).ConfigureAwait(false);
}

using (var _reader = new StreamReader(_res.ContentStream))
{
var _content = await _reader.ReadToEndAsync().ConfigureAwait(false);
var _body = Client.Deserialize<Newtonsoft.Json.Linq.JToken>(_content);
return _body;
}
}
}
}

internal async Task OnGetDetailsFailed(Request req, Response res)
{
string content = null;
if (res.ContentStream != null)
{
using (var reader = new StreamReader(res.ContentStream))
{
content = await reader.ReadToEndAsync().ConfigureAwait(false);
}
}

var ex = new RestApiException<Models.ApiError>(
req,
res,
content,
Client.Deserialize<Models.ApiError>(content)
);
HandleFailedGetDetailsRequest(ex);
HandleFailedRequest(ex);
Client.OnFailedRequest(ex);
throw ex;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,12 @@ public partial interface IHelixApi
{
HelixApiOptions Options { get; set; }

IAggregate Aggregate { get; }
IAnalysis Analysis { get; }
IInformation Information { get; }
IJob Job { get; }
IMachine Machine { get; }
IRepository Repository { get; }
IScaleSets ScaleSets { get; }
IStorage Storage { get; }
ITelemetry Telemetry { get; }
IWorkItem WorkItem { get; }
Expand Down Expand Up @@ -105,13 +107,17 @@ public HttpPipeline Pipeline

public JsonSerializerSettings SerializerSettings { get; }

public IAggregate Aggregate { get; }

public IAnalysis Analysis { get; }

public IInformation Information { get; }

public IJob Job { get; }

public IMachine Machine { get; }

public IRepository Repository { get; }
public IScaleSets ScaleSets { get; }

public IStorage Storage { get; }

Expand All @@ -128,10 +134,12 @@ public HelixApi()
public HelixApi(HelixApiOptions options)
{
Options = options;
Aggregate = new Aggregate(this);
Analysis = new Analysis(this);
Information = new Information(this);
Job = new Job(this);
Machine = new Machine(this);
Repository = new Repository(this);
ScaleSets = new ScaleSets(this);
Storage = new Storage(this);
Telemetry = new Telemetry(this);
WorkItem = new WorkItem(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using System;
using System.Collections.Immutable;
using Newtonsoft.Json;

namespace Microsoft.DotNet.Helix.Client.Models
{
public partial class AggregateAnalysisDetail
{
public AggregateAnalysisDetail(Newtonsoft.Json.Linq.JToken analysis, string job, string workItem, IImmutableDictionary<string, string> key)
{
Analysis = analysis;
Job = job;
WorkItem = workItem;
Key = key;
}

[JsonProperty("Analysis")]
public Newtonsoft.Json.Linq.JToken Analysis { get; set; }

[JsonProperty("Job")]
public string Job { get; set; }

[JsonProperty("WorkItem")]
public string WorkItem { get; set; }

[JsonProperty("Key")]
public IImmutableDictionary<string, string> Key { get; set; }

[JsonIgnore]
public bool IsValid
{
get
{
if (Analysis == default(Newtonsoft.Json.Linq.JToken))
{
return false;
}
if (string.IsNullOrEmpty(Job))
{
return false;
}
if (string.IsNullOrEmpty(WorkItem))
{
return false;
}
if (Key == default(IImmutableDictionary<string, string>))
{
return false;
}
return true;
}
}
}
}
Loading