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

Replace VSTS/TFS/AzureDevOps libraries #815

Merged
merged 8 commits into from
Sep 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static IServiceCollection AddWorkflowServices(this IServiceCollection ser
services.AddScoped<UpdateRunner>();
services.AddSingleton<UpdateScheduler>();

services.AddScoped<AzureDevOpsProvider>();
services.AddHttpClient<AzureDevOpsProvider>();
services.AddScoped<Synchronizer>();

return services;
Expand Down
30 changes: 30 additions & 0 deletions server/Tingle.Dependabot/Models/Azure/AzdoRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Text.Json.Serialization;

namespace Tingle.Dependabot.Models.Azure;

public class AzdoRepository
{
[JsonPropertyName("id")]
public required string Id { get; set; }

[JsonPropertyName("name")]
public required string Name { get; set; }

[JsonPropertyName("project")]
public required AzdoProject Project { get; set; }

[JsonPropertyName("isDisabled")]
public bool IsDisabled { get; set; }

[JsonPropertyName("isFork")]
public bool IsFork { get; set; }
}

public class AzdoListResponse<T> where T : class
{
[JsonPropertyName("value")]
public required List<T> Value { get; set; }

[JsonPropertyName("count")]
public required int Count { get; set; }
}
68 changes: 68 additions & 0 deletions server/Tingle.Dependabot/Models/Azure/AzdoRepositoryItem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Tingle.Dependabot.Models.Azure;

public class AzdoRepositoryItem
{
[JsonPropertyName("objectId")]
public required string ObjectId { get; set; }

[JsonPropertyName("originalObjectId")]
public string? OriginalObjectId { get; set; }

[JsonPropertyName("gitObjectType")]
public required AzdoRepositoryItemType GitObjectType { get; set; }

[JsonPropertyName("commitId")]
public required string CommitId { get; set; }

[JsonPropertyName("latestProcessedChange")]
public required AzdoCommitRef LatestProcessedChange { get; set; }

[JsonPropertyName("path")]
public required string Path { get; set; }

[JsonPropertyName("isFolder")]
public bool IsFolder { get; set; }

[JsonPropertyName("content")]
public required string Content { get; set; }

[JsonPropertyName("isSymLink")]
public bool IsSymbolicLink { get; set; }
}

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum AzdoRepositoryItemType
{
[EnumMember(Value = "bad")]
Bad,

[EnumMember(Value = "blob")]
Blob,

[EnumMember(Value = "commit")]
Commit,

[EnumMember(Value = "ext2")]
Ext2,

[EnumMember(Value = "ofsDelta")]
OfsDelta,

[EnumMember(Value = "refDelta")]
RefDelta,

[EnumMember(Value = "tree")]
Tree,

[EnumMember(Value = "tag")]
Tag,
}

public class AzdoCommitRef
{
[JsonPropertyName("commitId")]
public required string CommitId { get; set; }
}
119 changes: 119 additions & 0 deletions server/Tingle.Dependabot/Models/Azure/AzdoSubscriptionsQuery.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
using System.Runtime.Serialization;
using System.Text.Json.Serialization;

namespace Tingle.Dependabot.Models.Azure;

public class AzdoSubscriptionsQuery
{
[JsonPropertyName("consumerActionId")]
public string? ConsumerActionId { get; set; }

[JsonPropertyName("consumerId")]
public string? ConsumerId { get; set; }

[JsonPropertyName("consumerInputFilters")]
public List<AzdoSubscriptionsQueryInputFilter>? ConsumerInputFilters { get; set; }

[JsonPropertyName("eventType")]
public string? EventType { get; set; }

[JsonPropertyName("publisherId")]
public string? PublisherId { get; set; }

[JsonPropertyName("publisherInputFilters")]
public List<AzdoSubscriptionsQueryInputFilter>? PublisherInputFilters { get; set; }

[JsonPropertyName("subscriberId")]
public string? SubscriberId { get; set; }
}

public class AzdoSubscriptionsQueryInputFilter
{
[JsonPropertyName("conditions")]
public List<AzdoSubscriptionsQueryInputFilterCondition>? Conditions { get; set; }
}

public class AzdoSubscriptionsQueryInputFilterCondition
{
[JsonPropertyName("caseSensitive")]
public bool? CaseSensitive { get; set; }

[JsonPropertyName("inputId")]
public string? InputId { get; set; }

[JsonPropertyName("inputValue")]
public string? InputValue { get; set; }

[JsonPropertyName("operator")]
public AzdoSubscriptionsQueryInputFilterOperator Operator { get; set; }
}

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum AzdoSubscriptionsQueryInputFilterOperator
{
[EnumMember(Value = "equals")]
Equals,
[EnumMember(Value = "notEquals")]
NotEquals
}

public class AzdoSubscriptionsQueryResponse : AzdoSubscriptionsQuery
{
[JsonPropertyName("results")]
public required List<AzdoSubscription> Results { get; set; }
}

public class AzdoSubscription
{
[JsonPropertyName("id")]
public string? Id { get; set; }

[JsonPropertyName("status")]
public AzdoSubscriptionStatus Status { get; set; }

[JsonPropertyName("publisherId")]
public required string PublisherId { get; set; }

[JsonPropertyName("publisherInputs")]
public Dictionary<string, string> PublisherInputs { get; set; } = new();

[JsonPropertyName("consumerId")]
public string? ConsumerId { get; set; }

[JsonPropertyName("consumerActionId")]
public string? ConsumerActionId { get; set; }

[JsonPropertyName("consumerInputs")]
public Dictionary<string, string> ConsumerInputs { get; set; } = new();

[JsonPropertyName("eventType")]
public required string EventType { get; set; }

[JsonPropertyName("resourceVersion")]
public required string ResourceVersion { get; set; }

[JsonPropertyName("eventDescription")]
public string? EventDescription { get; set; }

[JsonPropertyName("actionDescription")]
public string? ActionDescription { get; set; }
}

[JsonConverter(typeof(JsonStringEnumMemberConverter))]
public enum AzdoSubscriptionStatus
{
[EnumMember(Value = "enabled")]
Enabled,

[EnumMember(Value = "onProbation")]
OnProbation,

[EnumMember(Value = "disabledByUser")]
DisabledByUser,

[EnumMember(Value = "disabledBySystem")]
DisabledBySystem,

[EnumMember(Value = "disabledByInactiveIdentity")]
DisabledByInactiveIdentity,
}
2 changes: 1 addition & 1 deletion server/Tingle.Dependabot/Models/Management/Project.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class Project
/// <example>https://dev.azure.com/tingle/dependabot</example>
[Url]
[Required]
public string? Url { get; set; }
public string? Url { get; set; } // TODO: change this to AzureDevOpsProjectUrl when we have converters for JSON and EfCore hence reduce the conversions all over the code

/// <summary>
/// Token for accessing the project with permissions for repositories, pull requests, and service hooks.
Expand Down
2 changes: 0 additions & 2 deletions server/Tingle.Dependabot/Tingle.Dependabot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.11" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore" Version="7.0.11" />
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.6.1" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="19.225.0-preview" />
<PackageReference Include="Microsoft.VisualStudio.Services.ServiceHooks.WebApi" Version="19.225.0-preview" />
<PackageReference Include="System.Linq.Async" Version="6.0.1" />
<!-- <PackageReference Include="Tingle.AspNetCore.ApplicationInsights" Version="4.2.1" /> -->
<PackageReference Include="Tingle.EventBus.Transports.Azure.ServiceBus" Version="0.19.2" />
Expand Down
Loading