Skip to content

Commit 632e318

Browse files
committed
feat: search fo files
1 parent 727e880 commit 632e318

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Fossology.Rest.Dotnet/FossologyClientSearch.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,5 +92,31 @@ public IReadOnlyList<SearchResult> Search(
9292

9393
return result;
9494
} // Search()
95+
96+
/// <summary>
97+
/// Searches for files by hash.
98+
/// </summary>
99+
/// <param name="fileHashes">A list of file hashes.</param>
100+
/// <param name="groupName">Name of the group.</param>
101+
/// <returns>A raw JSON result.</returns>
102+
public string SearchForFile(List<Hash> fileHashes, string groupName = "")
103+
{
104+
Log.Debug($"Searching for files by hash...");
105+
106+
var json = JsonConvert.SerializeObject(fileHashes);
107+
108+
var request = new RestRequest(this.Url + "/filesearch", Method.POST);
109+
request.RequestFormat = DataFormat.Json;
110+
request.JsonSerializer = new JsonSerializer();
111+
request.Parameters.Clear();
112+
if (!string.IsNullOrEmpty(groupName))
113+
{
114+
request.AddHeader("groupName", groupName);
115+
} // if
116+
117+
request.AddJsonBody(json);
118+
var resultRaw = this.api.Execute(request);
119+
return resultRaw.Content;
120+
} // SearchForFile()
95121
} // FossologyClient
96122
}

0 commit comments

Comments
 (0)