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

define reponses model for application api and update the Queries dire… #12

Merged
merged 1 commit into from
Oct 15, 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 @@ -10,8 +10,8 @@ internal sealed class ApplicationCreateOrUpdateBuilder : QueryBuilder<CreateOrUp
{
protected override void BuildCore(Query query, CreateOrUpdateApplicationOptions options)
{
query.Add("upsert",options.Upsert.ToLowerCaseString());
query.Add("validate",options.Validate.ToLowerCaseString());
query.Add("upsert",options.Upsert);
query.Add("validate",options.Validate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class ApplicationDeleteBuilder : QueryBuilder<DeleteApplicationO
{
protected override void BuildCore(Query query, DeleteApplicationOptions options)
{
query.Add("cascade",options.Cascade.ToLowerCaseString());
query.Add("cascade",options.Cascade);

if (options.PropagationPolicy.IsNotNullOrEmpty())
query.Add("propagationPolicy",options.PropagationPolicy);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using ArgoCD.Client.Internal.Utilities;
using ArgoCD.Client.Models.Application.Requests;

namespace ArgoCD.Client.Internal.Builders
{
internal sealed class ApplicationDetailsQueryBuilder : QueryBuilder<ApplicationDetailsQueryOptions>
{
protected override void BuildCore(Query query, ApplicationDetailsQueryOptions options)
{
if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace",options.AppNamespace);

if (options.Project.IsNotNullOrEmpty())
query.Add("project", options.Project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ internal sealed class ApplicationListQueryBuilder : QueryBuilder<ApplicationList
protected override void BuildCore(Query query, ApplicationListQueryOptions options)
{
if (options.Name.IsNotNullOrEmpty())
query.Add("name",options.Name);
query.Add("name", options.Name);

if (options.Refresh.IsNotNullOrEmpty())
query.Add("refresh", options.Refresh);

query.Add("projects",options.Projects);

if (options.ResourceVersion.IsNotNullOrEmpty())
query.Add("resourceVersion", options.ResourceVersion);

Expand All @@ -28,14 +30,7 @@ protected override void BuildCore(Query query, ApplicationListQueryOptions optio
if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace", options.AppNamespace);

foreach (string item in options.Projects)
{
query.Add("projects",item);
}
foreach (string item in options.Project)
{
query.Add("project", item);
}
query.Add("project", options.Project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected override void BuildCore(Query query, ApplicationLogQueryOptions option
if (options.TailLines.IsNotNullOrEmpty())
query.Add("tailLines", options.TailLines);

query.Add("follow", options.Follow.ToLowerCaseString());
query.Add("follow", options.Follow);

if (options.UntilTime.IsNotNullOrEmpty())
query.Add("untilTime", options.UntilTime);
Expand All @@ -47,7 +47,7 @@ protected override void BuildCore(Query query, ApplicationLogQueryOptions option
if (options.ResourceName.IsNotNullOrEmpty())
query.Add("resourceName", options.ResourceName);

query.Add("previous", options.Previous.ToLowerCaseString());
query.Add("previous", options.Previous);

if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace", options.AppNamespace);
Expand Down
10 changes: 2 additions & 8 deletions src/ArgoCD.Client/Internal/Builders/ApplicationQueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ protected override void BuildCore(Query query, ApplicationQueryOptions options)
if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace", options.AppNamespace);

foreach (string item in options.Projects)
{
query.Add("projects", item);
}
foreach (string item in options.Project)
{
query.Add("project", item);
}
query.Add("projects", options.Projects);
query.Add("project", options.Project);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ protected override void BuildCore(Query query, DeleteApplicationResourceOptions
if (options.Kind.IsNotNullOrEmpty())
query.Add("kind", options.Kind);

query.Add("force", options.Force.ToLowerCaseString());
query.Add("orphan", options.Orphan.ToLowerCaseString());
query.Add("force", options.Force);
query.Add("orphan", options.Orphan);

if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace", options.AppNamespace);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ protected override void BuildCore(Query query, ApplicationSetListQueryOptions op
if (options.AppsetNamespace.IsNotNullOrEmpty())
query.Add("appsetNamespace", options.AppsetNamespace);

foreach (string item in options.Projects)
{
query.Add("projects",item);
}
query.Add("projects", options.Projects);

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Text;
using ArgoCD.Client.Internal.Utilities;
using ArgoCD.Client.Models.Application.Requests;

namespace ArgoCD.Client.Internal.Builders
{
internal sealed class ApplicationUpdateSpecBuilder : QueryBuilder<UpdateApplicationSpecOptions>
{
protected override void BuildCore(Query query, UpdateApplicationSpecOptions options)
{
query.Add("validate",options.Validate);

if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace",options.AppNamespace);

if (options.Project.IsNotNullOrEmpty())
query.Add("project", options.Project);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;
using ArgoCD.Client.Internal.Utilities;
using ArgoCD.Client.Models.Application.Requests;

namespace ArgoCD.Client.Internal.Builders
{
internal sealed class ApplicationWatchQueryBuilder : QueryBuilder<ApplicationWatchQueryOptions>
{
protected override void BuildCore(Query query, ApplicationWatchQueryOptions options)
{
if (options.Name.IsNotNullOrEmpty())
query.Add("name",options.Name);

if (options.Refresh.IsNotNullOrEmpty())
query.Add("refresh", options.Refresh);

query.Add("projects", options.Projects);
query.Add("project", options.Project);

if (options.ResourceVersion.IsNotNullOrEmpty())
query.Add("resourceVersion", options.ResourceVersion);

if (options.Selector.IsNotNullOrEmpty())
query.Add("selector", options.Selector);

if (options.Repo.IsNotNullOrEmpty())
query.Add("repo", options.Repo);

if (options.AppNamespace.IsNotNullOrEmpty())
query.Add("appNamespace", options.AppNamespace);
}
}
}
6 changes: 1 addition & 5 deletions src/ArgoCD.Client/Internal/Builders/ClusterUpdateBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@ protected override void BuildCore(Query query, UpdateClusterOptions options)
{
query.Add("id.value",options.IdValue);
}

foreach (string item in options.UpdatedFields)
{
query.Add("updatedFields", item);
}
query.Add("updatedFields", options.UpdatedFields);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ internal sealed class CreateRepositoryBuilder : QueryBuilder<CreateRepositoryOpt
{
protected override void BuildCore(Query query, CreateRepositoryOptions options)
{
query.Add("upsert",options.Upsert.ToLowerCaseString());
query.Add("credsOnly",options.CredsOnly.ToLowerCaseString());
query.Add("upsert",options.Upsert);
query.Add("credsOnly",options.CredsOnly);
}
}
}
22 changes: 17 additions & 5 deletions src/ArgoCD.Client/Internal/Builders/QueryBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ protected class Query
private readonly NameValueCollection _nameValues = new NameValueCollection();

public void Add(string name, string value)
=> _nameValues.Add(name, value);
{
if(name.IsNotNullOrEmpty())
_nameValues.Add(name, value);
}

public void Add(string name, bool value)
=> Add(name, value.ToLowerCaseString());
Expand All @@ -28,20 +31,29 @@ public void Add(string name, DateTime value)

public void Add(string name, IList<string> values)
{
if (!values.Any())
if (name.IsNullOrEmpty() || values == null || !values.Any())
return;

Add(name, string.Join(",", values));
foreach (string item in values)
{
if(item.IsNotNullOrEmpty())
Add(name, item);
}
}

public void Add(string name, IList<int> values)
{
if (name.IsNullOrEmpty() || values == null)
return;

foreach (int val in values)
Add($"{name}[]", val.ToString());
}

public void Add(IList<int> values)
{
if (values == null)
return;

foreach (int iid in values)
Add("iids[]", iid.ToString());
}
Expand All @@ -61,7 +73,7 @@ public string Build(string baseUrl, T options)
{
var query = new Query();
BuildCore(query, options);
return baseUrl + query.ToQueryString();
return string.Concat(baseUrl, query.ToQueryString());
}

protected abstract void BuildCore(Query query, T options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal sealed class RepositoryQueryBuilder : QueryBuilder<RepositoryQueryOptio
{
protected override void BuildCore(Query query, RepositoryQueryOptions options)
{
query.Add("forceRefresh", options.ForceRefresh.ToLowerCaseString());
query.Add("forceRefresh", options.ForceRefresh);

if (options.Repo.IsNotNullOrEmpty())
query.Add("repo",options.Repo);
Expand Down
2 changes: 1 addition & 1 deletion src/ArgoCD.Client/Internal/Builders/UpsertBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal class UpsertBuilder : QueryBuilder<UpsertOptions>
{
protected override void BuildCore(Query query, UpsertOptions options)
{
query.Add("upsert", options.Upsert.ToLowerCaseString());
query.Add("upsert", options.Upsert);
}
}
}
6 changes: 3 additions & 3 deletions src/ArgoCD.Client/Internal/Builders/ValidateAccessBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ internal sealed class ValidateAccessBuilder : QueryBuilder<ValidateAccessOptions
{
protected override void BuildCore(Query query, ValidateAccessOptions options)
{
query.Add("insecure", options.Insecure.ToLowerCaseString());
query.Add("enableOci", options.EnableOCI.ToLowerCaseString());
query.Add("forceHttpBasicAuth", options.ForceHttpBasicAuth.ToLowerCaseString());
query.Add("insecure", options.Insecure);
query.Add("enableOci", options.EnableOCI);
query.Add("forceHttpBasicAuth", options.ForceHttpBasicAuth);

if (options.Username.IsNotNullOrEmpty())
query.Add("username",options.Username);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace ArgoCD.Client.Models.Application.Reponses
{
public class ApplicationApplicationSyncWindow
{

public string Duration { get; set; }

public string Kind { get; set; }


public bool ManualSync { get; set; }


public string Schedule { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;

namespace ArgoCD.Client.Models.Application.Reponses
{
public class ApplicationSyncWindows
{

public ApplicationApplicationSyncWindow[] ActiveWindows { get; set; }


public ApplicationApplicationSyncWindow[] AssignedWindows { get; set; }


public bool CanSync { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace ArgoCD.Client.Models.Application.Reponses
{
public class ResourceActionsList
{
public V1alpha1ResourceAction[] Actions { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;
using static System.Net.Mime.MediaTypeNames;

namespace ArgoCD.Client.Models.Application.Reponses
{
/// <summary>
/// ApplicationWatchEvent contains information about application change.
/// </summary>
public class V1alpha1ApplicationWatchEvent
{

public V1alpha1Application Application { get; set; }


public string Type { get; set; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using System.Xml.Linq;

namespace ArgoCD.Client.Models.Application.Reponses
{
public class V1alpha1ChartDetails
{
public string Description { get; set; }

public string Home { get; set; }


/// <summary>
/// List of maintainer details, name and email, e.g. ["John Doe <[email protected]>"]
/// </summary>
public string[] Maintainers { get; set; }
}
}
Loading