Skip to content

Commit

Permalink
working
Browse files Browse the repository at this point in the history
  • Loading branch information
JFriel committed Oct 15, 2024
1 parent 55ea6ec commit 99f68d4
Show file tree
Hide file tree
Showing 14 changed files with 814 additions and 38 deletions.
2 changes: 2 additions & 0 deletions InterfaceToJira/InterfaceToJira.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\Aggregateprogress.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\ApplicationProperty.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\AQLQuery.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\AQLResponse.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\AssetResponse.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\Attachment.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\Attachments.cs" />
<Compile Include="$(MSBuildThisFileDirectory)RestApiClient2\JiraModel\Author.cs" />
Expand Down
33 changes: 31 additions & 2 deletions InterfaceToJira/RestApiClient2/JiraAPIClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using HIC.Common.InterfaceToJira.JIRA.RestApiClient2;
using InterfaceToJira.RestApiClient2;
using InterfaceToJira.RestApiClient2.JiraModel;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json;
using NPOI.SS.UserModel;
using RestSharp;
Expand Down Expand Up @@ -64,16 +65,44 @@ public JiraAPIClient(JiraAccount account)
}
}

public List<JiraAsset> GetAllProjectAssets()
public JiraModel.AssetResponse GetProjectAsset(int id)
{
var request = new RestRequest
{
Resource = $"/jsm/assets/workspace/{_workspaceID}/v1/object/{id}",
Method = Method.Get,
};
var response = RESTHelper.Execute<AssetResponse>(client, request);
return response;
}

public List<JiraAsset> GetAllProjectAssets()
{
List<JiraAsset> assets = new();
var request = new RestRequest
{
Resource = $"/jsm/assets/workspace/{_workspaceID}/v1/object/aql",
Method = Method.Post,
RequestFormat = DataFormat.Json,
};
request.AddBody("{\"qlQuery\": \"objectType = Project\"}");
return RESTHelper.Execute<List<JiraAsset>>(client, request);

var response = RESTHelper.Execute<AQLResponse>(client, request);
int total = response.total;
assets.AddRange(response.values);
while(total > assets.Count) {
//go get the rest
request = new RestRequest
{
Resource = $"/jsm/assets/workspace/{_workspaceID}/v1/object/aql?startAt={assets.Count+1}",
Method = Method.Post,
RequestFormat = DataFormat.Json,
};
request.AddBody("{\"qlQuery\": \"objectType = Project\"}");

var additioanlResponse = RESTHelper.Execute<AQLResponse>(client, request);
assets.AddRange(additioanlResponse.values);
}
return assets.ToList();
}
}
190 changes: 190 additions & 0 deletions InterfaceToJira/RestApiClient2/JiraModel/AQLResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace InterfaceToJira.RestApiClient2.JiraModel;


public class AQLResponse
{
public int startAt { get; set; }
public int maxResults { get; set; }
public int total { get; set; }
public bool isLast { get; set; }
public List<JiraAsset> values { get; set; }
public List<ObjectTypeAttribute> objectTypeAttributes { get; set; }
}

// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class Attribute
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string objectTypeAttributeId { get; set; }
public List<ObjectAttributeValue> objectAttributeValues { get; set; }
public string objectId { get; set; }
}

public class Avatar
{
public string workspaceId { get; set; }
public string url16 { get; set; }
public string url48 { get; set; }
public string url72 { get; set; }
public string url144 { get; set; }
public string url288 { get; set; }
public string objectId { get; set; }
public MediaClientConfig mediaClientConfig { get; set; }
}

public class DefaultType
{
public int id { get; set; }
public string name { get; set; }
}

public class Icon
{
public string id { get; set; }
public string name { get; set; }
public string url16 { get; set; }
public string url48 { get; set; }
}

public class Links
{
public string self { get; set; }
}

public class MediaClientConfig
{
public string clientId { get; set; }
public string mediaBaseUrl { get; set; }
public string mediaJwtToken { get; set; }
public string fileId { get; set; }
}

public class ObjectAttributeValue
{
public object value { get; set; }
public string displayValue { get; set; }
public object searchValue { get; set; }
public bool referencedType { get; set; }
public ReferencedObject referencedObject { get; set; }
}

public class ObjectType
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string name { get; set; }
public int type { get; set; }
public string description { get; set; }
public Icon icon { get; set; }
public int position { get; set; }
public DateTime created { get; set; }
public DateTime updated { get; set; }
public int objectCount { get; set; }
public string objectSchemaId { get; set; }
public bool inherited { get; set; }
public bool abstractObjectType { get; set; }
public bool parentObjectTypeInherited { get; set; }
}

public class ObjectTypeAttribute
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public ObjectType objectType { get; set; }
public string name { get; set; }
public bool label { get; set; }
public DefaultType defaultType { get; set; }
public bool editable { get; set; }
public bool system { get; set; }
public bool sortable { get; set; }
public bool summable { get; set; }
public bool indexed { get; set; }
public int minimumCardinality { get; set; }
public int maximumCardinality { get; set; }
public bool removable { get; set; }
public bool hidden { get; set; }
public bool includeChildObjectTypes { get; set; }
public bool uniqueAttribute { get; set; }
public string options { get; set; }
public int position { get; set; }
public string description { get; set; }
public string suffix { get; set; }
public string regexValidation { get; set; }
public ReferenceType referenceType { get; set; }
public string referenceObjectTypeId { get; set; }
public ReferenceObjectType referenceObjectType { get; set; }
}

public class ReferencedObject
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string label { get; set; }
public string objectKey { get; set; }
public Avatar avatar { get; set; }
public ObjectType objectType { get; set; }
public DateTime created { get; set; }
public DateTime updated { get; set; }
public bool hasAvatar { get; set; }
public long timestamp { get; set; }
public Links _links { get; set; }
public string name { get; set; }
}

public class ReferenceObjectType
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string name { get; set; }
public Icon icon { get; set; }
public int position { get; set; }
public DateTime created { get; set; }
public DateTime updated { get; set; }
public int objectCount { get; set; }
public string objectSchemaId { get; set; }
public bool inherited { get; set; }
public bool abstractObjectType { get; set; }
public bool parentObjectTypeInherited { get; set; }
}

public class ReferenceType
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string name { get; set; }
public string description { get; set; }
public string color { get; set; }
public string url16 { get; set; }
public bool removable { get; set; }
}


public class Value
{
public string workspaceId { get; set; }
public string globalId { get; set; }
public string id { get; set; }
public string label { get; set; }
public string objectKey { get; set; }
public Avatar avatar { get; set; }
public ObjectType objectType { get; set; }
public DateTime created { get; set; }
public DateTime updated { get; set; }
public bool hasAvatar { get; set; }
public long timestamp { get; set; }
public List<Attribute> attributes { get; set; }
public Links _links { get; set; }
public string name { get; set; }
}

Loading

0 comments on commit 99f68d4

Please sign in to comment.