Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
Loading items

Target

Select target project
  • coscine/backend/scripts/metadataextractorcron
1 result
Select Git revision
Loading items
Show changes
Commits on Source (4)
Showing
with 606 additions and 354 deletions
# Metadata Extractor Cronjob # Coscine.MetadataExtractorCron - the C# cronjob for the Metadata Extractor API
[[_TOC_]] [[_TOC_]]
## 📝 Overview ## 📝 Overview
This application goes daily over all resources in Coscine which have the Metadata Extraction activated and executes it. It is a metadata extractor that extracts metadata from files and stores it in a database. It is designed to be run as a cron job on a server. The extracted metadata includes information such as the title, author, and creation date of the PDF files. The program uses C#, Python and several third-party libraries to extract the metadata and interact with the database. This cronjob interacts with the Coscine Api and the Metadata Extraction API to extract metadata from research data.
## ⚙️ Configuration ### Features
- **Configuration-driven**: Behavior driven by settings defined in configuration files and environment variables (see `appsettings.json`).
Before you can run and use the script, you need to ensure that the following dependencies and prerequisites are in place: - **Logging**: Extensive logging capabilities to track the process and troubleshoot issues.
1. The project's referenced .NET SDK(s) must be installed. Please refer to the project's source code for information on which .NET SDK(s) are required. ## ⚙️ Configuration
Once you have all the necessary dependencies and prerequisites in place, you should be able to run and use this script. The deployment script uses a configuration class `MetadataExtractorCronConfiguration` to manage settings such as:
- `IsEnabled`: Toggles the extractor on or off.
- `MetadataExtractionUrl`: Specifies the metadata extraction service URL.
- `DetectionByteLimit`: Specifies limit the metadata extraction cronjob should adhere to.
- `Logger` Configuration: Specifies the logging level and output directory.
### Example `appsettings.json`
```json
{
"MetadataExtractorConfiguration": {
"IsEnabled": true,
"MetadataExtractionUrl": "https://metadataextractor.otc.coscine.dev/",
"DetectionByteLimit": 16000000,
"Logger": {
"LogLevel": "Trace",
"LogHome": "C:\\coscine\\logs\\MetadataExtractorCron\\"
}
}
}
```
## 📖 Usage ## 📖 Usage
...@@ -20,9 +39,11 @@ To get started with this project, you will need to ensure you have configured an ...@@ -20,9 +39,11 @@ To get started with this project, you will need to ensure you have configured an
1. Execute the built executable (`.exe`) 1. Execute the built executable (`.exe`)
To use the **MetadataExtractorCron**, execute the main program with appropriate command-line arguments to control its operation.
## 👥 Contributing ## 👥 Contributing
As an open source plattform and project, we welcome contributions from our community in any form. You can do so by submitting bug reports or feature requests, or by directly contributing to Coscine's source code. To submit your contribution please follow our [Contributing Guideline](https://git.rwth-aachen.de/coscine/docs/public/wiki/-/blob/master/Contributing%20To%20Coscine.md). As an open source platform and project, we welcome contributions from our community in any form. You can do so by submitting bug reports or feature requests, or by directly contributing to Coscine's source code. To submit your contribution please follow our [Contributing Guideline](https://git.rwth-aachen.de/coscine/docs/public/wiki/-/blob/master/Contributing%20To%20Coscine.md).
## 📄 License ## 📄 License
...@@ -43,5 +64,3 @@ By following these simple steps, you can get the support you need to use Coscine ...@@ -43,5 +64,3 @@ By following these simple steps, you can get the support you need to use Coscine
External users can find the _Releases and Changelog_ inside each project's repository. The repository contains a section for Releases (`Deployments > Releases`), where users can find the latest release changelog and source. Withing the Changelog you can find a list of all the changes made in that particular release and version. External users can find the _Releases and Changelog_ inside each project's repository. The repository contains a section for Releases (`Deployments > Releases`), where users can find the latest release changelog and source. Withing the Changelog you can find a list of all the changes made in that particular release and version.
By regularly checking for new releases and changes in the Changelog, you can stay up-to-date with the latest improvements and bug fixes by our team and community! By regularly checking for new releases and changes in the Changelog, you can stay up-to-date with the latest improvements and bug fixes by our team and community!
#!/bin/bash
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# Generate C# API Client using OpenAPI Generator:
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# This script generates a C# API client based on the OpenAPI specification.
#
# The actions performed are:
# - Downloading the OpenAPI generator CLI tool.
# - Generating the API client code.
# - Deleting existing API client source files.
# - Copying the newly generated API client source to the project directory.
# - Replacing the README.md file.
# - Cleaning up temporary files and the downloaded tool.
#
# Defined variables:
GENERATOR_URL="https://repo1.maven.org/maven2/org/openapitools/openapi-generator-cli/7.0.1/openapi-generator-cli-7.0.1.jar" # URL to the OpenAPI generator JAR file
GENERATOR_JAR="openapi-generator-cli.jar" # The name of the OpenAPI generator JAR file
OUTPUT_DIR="temp" # The temporary directory for generated files
ARTIFACT_ID="Coscine.MetadataExtractor.Core" # The artifact ID for the API client
PACKAGE_NAME="Coscine.MetadataExtractor.Core" # The package name for the API client
API_SPEC_URL="https://metadataextractor.otc.coscine.dev/swagger.json" # URL to the OpenAPI spec file
# --------------------------------------------------------------------------------------------------------------------------------------------------------------------
# ANSI color codes for styling
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Download the OpenAPI generator JAR file
echo -e "${CYAN}Downloading the OpenAPI generator JAR file...${NC}"
curl -o "$GENERATOR_JAR" "$GENERATOR_URL"
# Run the OpenAPI generator
echo -e "${CYAN}Running the OpenAPI generator...${NC}"
java -jar "$GENERATOR_JAR" generate -i "$API_SPEC_URL" -g csharp -o "$OUTPUT_DIR" --artifact-id "$ARTIFACT_ID" --package-name "$PACKAGE_NAME" --skip-validate-spec --server-variables=host=localhost:7206,basePath=coscine
echo -e "${GREEN}API client generation complete.${NC}"
# Delete the current API client source
echo -e "${YELLOW}Deleting current API client source...${NC}"
rm -rf "src/$PACKAGE_NAME"
rm -rf "src/${PACKAGE_NAME}.Test"
# Copy the generated API client source to the src directory
echo -e "${CYAN}Copying generated API client source to src directory...${NC}"
cp -R "$OUTPUT_DIR/src/$PACKAGE_NAME" "src/$PACKAGE_NAME"
cp -R "$OUTPUT_DIR/src/${PACKAGE_NAME}.Test" "src/${PACKAGE_NAME}.Test"
# Remove the temp directory and the generator JAR file
echo -e "${YELLOW}Cleaning up...${NC}"
rm -rf "$OUTPUT_DIR"
rm -f "$GENERATOR_JAR"
echo -e "${GREEN}Finished.${NC}"
...@@ -3,13 +3,26 @@ ...@@ -3,13 +3,26 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Web;
using Newtonsoft.Json; using Newtonsoft.Json;
using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Serialization;
using RestSharp; using RestSharp;
...@@ -17,7 +30,7 @@ using RestSharp.Serializers; ...@@ -17,7 +30,7 @@ using RestSharp.Serializers;
using RestSharpMethod = RestSharp.Method; using RestSharpMethod = RestSharp.Method;
using Polly; using Polly;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Allows RestSharp to Serialize/Deserialize JSON using our custom logic, but only when ContentType is JSON. /// Allows RestSharp to Serialize/Deserialize JSON using our custom logic, but only when ContentType is JSON.
...@@ -25,7 +38,6 @@ namespace Org.OpenAPITools.Client ...@@ -25,7 +38,6 @@ namespace Org.OpenAPITools.Client
internal class CustomJsonCodec : IRestSerializer, ISerializer, IDeserializer internal class CustomJsonCodec : IRestSerializer, ISerializer, IDeserializer
{ {
private readonly IReadableConfiguration _configuration; private readonly IReadableConfiguration _configuration;
private static readonly string _contentType = "application/json";
private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings private readonly JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
{ {
// OpenAPI generated types generally hide default constructors. // OpenAPI generated types generally hide default constructors.
...@@ -57,10 +69,10 @@ namespace Org.OpenAPITools.Client ...@@ -57,10 +69,10 @@ namespace Org.OpenAPITools.Client
/// <returns>A JSON string.</returns> /// <returns>A JSON string.</returns>
public string Serialize(object obj) public string Serialize(object obj)
{ {
if (obj != null && obj is Org.OpenAPITools.Model.AbstractOpenAPISchema) if (obj != null && obj is Coscine.MetadataExtractor.Core.Model.AbstractOpenAPISchema)
{ {
// the object to be serialized is an oneOf/anyOf schema // the object to be serialized is an oneOf/anyOf schema
return ((Org.OpenAPITools.Model.AbstractOpenAPISchema)obj).ToJson(); return ((Coscine.MetadataExtractor.Core.Model.AbstractOpenAPISchema)obj).ToJson();
} }
else else
{ {
...@@ -138,17 +150,13 @@ namespace Org.OpenAPITools.Client ...@@ -138,17 +150,13 @@ namespace Org.OpenAPITools.Client
public ISerializer Serializer => this; public ISerializer Serializer => this;
public IDeserializer Deserializer => this; public IDeserializer Deserializer => this;
public string[] AcceptedContentTypes => RestSharp.Serializers.ContentType.JsonAccept; public string[] AcceptedContentTypes => RestSharp.ContentType.JsonAccept;
public SupportsContentType SupportsContentType => contentType => public SupportsContentType SupportsContentType => contentType =>
contentType.EndsWith("json", StringComparison.InvariantCultureIgnoreCase) || contentType.Value.EndsWith("json", StringComparison.InvariantCultureIgnoreCase) ||
contentType.EndsWith("javascript", StringComparison.InvariantCultureIgnoreCase); contentType.Value.EndsWith("javascript", StringComparison.InvariantCultureIgnoreCase);
public string ContentType public ContentType ContentType { get; set; } = RestSharp.ContentType.Json;
{
get { return _contentType; }
set { throw new InvalidOperationException("Not allowed to set content type."); }
}
public DataFormat DataFormat => DataFormat.Json; public DataFormat DataFormat => DataFormat.Json;
} }
...@@ -195,7 +203,7 @@ namespace Org.OpenAPITools.Client ...@@ -195,7 +203,7 @@ namespace Org.OpenAPITools.Client
/// </summary> /// </summary>
public ApiClient() public ApiClient()
{ {
_baseUrl = Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath; _baseUrl = Coscine.MetadataExtractor.Core.Client.GlobalConfiguration.Instance.BasePath;
} }
/// <summary> /// <summary>
...@@ -421,7 +429,7 @@ namespace Org.OpenAPITools.Client ...@@ -421,7 +429,7 @@ namespace Org.OpenAPITools.Client
return transformed; return transformed;
} }
private ApiResponse<T> Exec<T>(RestRequest req, RequestOptions options, IReadableConfiguration configuration) private ApiResponse<T> Exec<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration)
{ {
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
...@@ -441,32 +449,33 @@ namespace Org.OpenAPITools.Client ...@@ -441,32 +449,33 @@ namespace Org.OpenAPITools.Client
CookieContainer = cookies, CookieContainer = cookies,
MaxTimeout = configuration.Timeout, MaxTimeout = configuration.Timeout,
Proxy = configuration.Proxy, Proxy = configuration.Proxy,
UserAgent = configuration.UserAgent UserAgent = configuration.UserAgent,
UseDefaultCredentials = configuration.UseDefaultCredentials,
RemoteCertificateValidationCallback = configuration.RemoteCertificateValidationCallback
}; };
RestClient client = new RestClient(clientOptions) using (RestClient client = new RestClient(clientOptions,
.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)); configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration))))
{
InterceptRequest(req); InterceptRequest(request);
RestResponse<T> response; RestResponse<T> response;
if (RetryConfiguration.RetryPolicy != null) if (RetryConfiguration.RetryPolicy != null)
{ {
var policy = RetryConfiguration.RetryPolicy; var policy = RetryConfiguration.RetryPolicy;
var policyResult = policy.ExecuteAndCapture(() => client.Execute(req)); var policyResult = policy.ExecuteAndCapture(() => client.Execute(request));
response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result) : new RestResponse<T> response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result) : new RestResponse<T>(request)
{ {
Request = req,
ErrorException = policyResult.FinalException ErrorException = policyResult.FinalException
}; };
} }
else else
{ {
response = client.Execute<T>(req); response = client.Execute<T>(request);
} }
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data // if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(Org.OpenAPITools.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) if (typeof(Coscine.MetadataExtractor.Core.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
{ {
try try
{ {
...@@ -490,7 +499,7 @@ namespace Org.OpenAPITools.Client ...@@ -490,7 +499,7 @@ namespace Org.OpenAPITools.Client
response.Data = (T)(object)response.Content; response.Data = (T)(object)response.Content;
} }
InterceptResponse(req, response); InterceptResponse(request, response);
var result = ToApiResponse(response); var result = ToApiResponse(response);
if (response.ErrorMessage != null) if (response.ErrorMessage != null)
...@@ -526,8 +535,9 @@ namespace Org.OpenAPITools.Client ...@@ -526,8 +535,9 @@ namespace Org.OpenAPITools.Client
} }
return result; return result;
} }
}
private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest req, RequestOptions options, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) private async Task<ApiResponse<T>> ExecAsync<T>(RestRequest request, RequestOptions options, IReadableConfiguration configuration, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{ {
var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl; var baseUrl = configuration.GetOperationServerUrl(options.Operation, options.OperationIndex) ?? _baseUrl;
...@@ -536,32 +546,32 @@ namespace Org.OpenAPITools.Client ...@@ -536,32 +546,32 @@ namespace Org.OpenAPITools.Client
ClientCertificates = configuration.ClientCertificates, ClientCertificates = configuration.ClientCertificates,
MaxTimeout = configuration.Timeout, MaxTimeout = configuration.Timeout,
Proxy = configuration.Proxy, Proxy = configuration.Proxy,
UserAgent = configuration.UserAgent UserAgent = configuration.UserAgent,
UseDefaultCredentials = configuration.UseDefaultCredentials
}; };
RestClient client = new RestClient(clientOptions) using (RestClient client = new RestClient(clientOptions,
.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration)); configureSerialization: serializerConfig => serializerConfig.UseSerializer(() => new CustomJsonCodec(SerializerSettings, configuration))))
{
InterceptRequest(req); InterceptRequest(request);
RestResponse<T> response; RestResponse<T> response;
if (RetryConfiguration.AsyncRetryPolicy != null) if (RetryConfiguration.AsyncRetryPolicy != null)
{ {
var policy = RetryConfiguration.AsyncRetryPolicy; var policy = RetryConfiguration.AsyncRetryPolicy;
var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(req, ct), cancellationToken).ConfigureAwait(false); var policyResult = await policy.ExecuteAndCaptureAsync((ct) => client.ExecuteAsync(request, ct), cancellationToken).ConfigureAwait(false);
response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result) : new RestResponse<T> response = (policyResult.Outcome == OutcomeType.Successful) ? client.Deserialize<T>(policyResult.Result) : new RestResponse<T>(request)
{ {
Request = req,
ErrorException = policyResult.FinalException ErrorException = policyResult.FinalException
}; };
} }
else else
{ {
response = await client.ExecuteAsync<T>(req, cancellationToken).ConfigureAwait(false); response = await client.ExecuteAsync<T>(request, cancellationToken).ConfigureAwait(false);
} }
// if the response type is oneOf/anyOf, call FromJSON to deserialize the data // if the response type is oneOf/anyOf, call FromJSON to deserialize the data
if (typeof(Org.OpenAPITools.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T))) if (typeof(Coscine.MetadataExtractor.Core.Model.AbstractOpenAPISchema).IsAssignableFrom(typeof(T)))
{ {
response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content }); response.Data = (T) typeof(T).GetMethod("FromJson").Invoke(null, new object[] { response.Content });
} }
...@@ -574,7 +584,7 @@ namespace Org.OpenAPITools.Client ...@@ -574,7 +584,7 @@ namespace Org.OpenAPITools.Client
response.Data = (T)(object)response.RawBytes; response.Data = (T)(object)response.RawBytes;
} }
InterceptResponse(req, response); InterceptResponse(request, response);
var result = ToApiResponse(response); var result = ToApiResponse(response);
if (response.ErrorMessage != null) if (response.ErrorMessage != null)
...@@ -610,6 +620,7 @@ namespace Org.OpenAPITools.Client ...@@ -610,6 +620,7 @@ namespace Org.OpenAPITools.Client
} }
return result; return result;
} }
}
#region IAsynchronousClient #region IAsynchronousClient
/// <summary> /// <summary>
......
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// API Exception /// API Exception
......
...@@ -3,14 +3,16 @@ ...@@ -3,14 +3,16 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections.Generic;
using System.Net; using System.Net;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Provides a non-generic contract for the ApiResponse wrapper. /// Provides a non-generic contract for the ApiResponse wrapper.
......
...@@ -3,15 +3,22 @@ ...@@ -3,15 +3,22 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using System.Globalization; using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Utility functions providing some benefit to API client consumers. /// Utility functions providing some benefit to API client consumers.
...@@ -50,15 +57,13 @@ namespace Org.OpenAPITools.Client ...@@ -50,15 +57,13 @@ namespace Org.OpenAPITools.Client
} }
else if (value is IDictionary dictionary) else if (value is IDictionary dictionary)
{ {
if (collectionFormat == "deepObject") if(collectionFormat == "deepObject") {
{
foreach (DictionaryEntry entry in dictionary) foreach (DictionaryEntry entry in dictionary)
{ {
parameters.Add(name + "[" + entry.Key + "]", ParameterToString(entry.Value)); parameters.Add(name + "[" + entry.Key + "]", ParameterToString(entry.Value));
} }
} }
else else {
{
foreach (DictionaryEntry entry in dictionary) foreach (DictionaryEntry entry in dictionary)
{ {
parameters.Add(entry.Key.ToString(), ParameterToString(entry.Value)); parameters.Add(entry.Key.ToString(), ParameterToString(entry.Value));
...@@ -97,8 +102,14 @@ namespace Org.OpenAPITools.Client ...@@ -97,8 +102,14 @@ namespace Org.OpenAPITools.Client
return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat); return dateTimeOffset.ToString((configuration ?? GlobalConfiguration.Instance).DateTimeFormat);
if (obj is bool boolean) if (obj is bool boolean)
return boolean ? "true" : "false"; return boolean ? "true" : "false";
if (obj is ICollection collection) if (obj is ICollection collection) {
return string.Join(",", collection.Cast<object>()); List<string> entries = new List<string>();
foreach (var entry in collection)
entries.Add(ParameterToString(entry, configuration));
return string.Join(",", entries);
}
if (obj is Enum && HasEnumMemberAttrValue(obj))
return GetEnumMemberAttrValue(obj);
return Convert.ToString(obj, CultureInfo.InvariantCulture); return Convert.ToString(obj, CultureInfo.InvariantCulture);
} }
...@@ -197,5 +208,40 @@ namespace Org.OpenAPITools.Client ...@@ -197,5 +208,40 @@ namespace Org.OpenAPITools.Client
return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json"); return JsonRegex.IsMatch(mime) || mime.Equals("application/json-patch+json");
} }
/// <summary>
/// Is the Enum decorated with EnumMember Attribute
/// </summary>
/// <param name="enumVal"></param>
/// <returns>true if found</returns>
private static bool HasEnumMemberAttrValue(object enumVal)
{
if (enumVal == null)
throw new ArgumentNullException(nameof(enumVal));
var enumType = enumVal.GetType();
var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType<EnumMemberAttribute>().FirstOrDefault();
if (attr != null) return true;
return false;
}
/// <summary>
/// Get the EnumMember value
/// </summary>
/// <param name="enumVal"></param>
/// <returns>EnumMember value as string otherwise null</returns>
private static string GetEnumMemberAttrValue(object enumVal)
{
if (enumVal == null)
throw new ArgumentNullException(nameof(enumVal));
var enumType = enumVal.GetType();
var memInfo = enumType.GetMember(enumVal.ToString() ?? throw new InvalidOperationException());
var attr = memInfo.FirstOrDefault()?.GetCustomAttributes(false).OfType<EnumMemberAttribute>().FirstOrDefault();
if (attr != null)
{
return attr.Value;
}
return null;
}
} }
} }
...@@ -3,16 +3,24 @@ ...@@ -3,16 +3,24 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net; using System.Net;
using System.Reflection;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Net.Http;
using System.Net.Security;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Represents a set of configuration settings /// Represents a set of configuration settings
...@@ -50,6 +58,11 @@ namespace Org.OpenAPITools.Client ...@@ -50,6 +58,11 @@ namespace Org.OpenAPITools.Client
string.Format("Error calling {0}: {1}", methodName, response.RawContent), string.Format("Error calling {0}: {1}", methodName, response.RawContent),
response.RawContent, response.Headers); response.RawContent, response.Headers);
} }
if (status == 0)
{
return new ApiException(status,
string.Format("Error calling {0}: {1}", methodName, response.ErrorText), response.ErrorText);
}
return null; return null;
}; };
...@@ -63,6 +76,8 @@ namespace Org.OpenAPITools.Client ...@@ -63,6 +76,8 @@ namespace Org.OpenAPITools.Client
/// </summary> /// </summary>
private string _basePath; private string _basePath;
private bool _useDefaultCredentials = false;
/// <summary> /// <summary>
/// Gets or sets the API key based on the authentication name. /// Gets or sets the API key based on the authentication name.
/// This is the key and value comprising the "secret" for accessing an API. /// This is the key and value comprising the "secret" for accessing an API.
...@@ -168,11 +183,21 @@ namespace Org.OpenAPITools.Client ...@@ -168,11 +183,21 @@ namespace Org.OpenAPITools.Client
/// <summary> /// <summary>
/// Gets or sets the base path for API access. /// Gets or sets the base path for API access.
/// </summary> /// </summary>
public virtual string BasePath { public virtual string BasePath
{
get { return _basePath; } get { return _basePath; }
set { _basePath = value; } set { _basePath = value; }
} }
/// <summary>
/// Determine whether or not the "default credentials" (e.g. the user account under which the current process is running) will be sent along to the server. The default is false.
/// </summary>
public virtual bool UseDefaultCredentials
{
get { return _useDefaultCredentials; }
set { _useDefaultCredentials = value; }
}
/// <summary> /// <summary>
/// Gets or sets the default header. /// Gets or sets the default header.
/// </summary> /// </summary>
...@@ -437,7 +462,7 @@ namespace Org.OpenAPITools.Client ...@@ -437,7 +462,7 @@ namespace Org.OpenAPITools.Client
/// <return>The operation server URL.</return> /// <return>The operation server URL.</return>
public string GetOperationServerUrl(string operation, int index, Dictionary<string, string> inputVariables) public string GetOperationServerUrl(string operation, int index, Dictionary<string, string> inputVariables)
{ {
if (OperationServers.TryGetValue(operation, out var operationServer)) if (operation != null && OperationServers.TryGetValue(operation, out var operationServer))
{ {
return GetServerUrl(operationServer, index, inputVariables); return GetServerUrl(operationServer, index, inputVariables);
} }
...@@ -497,6 +522,11 @@ namespace Org.OpenAPITools.Client ...@@ -497,6 +522,11 @@ namespace Org.OpenAPITools.Client
return url; return url;
} }
/// <summary>
/// Gets and Sets the RemoteCertificateValidationCallback
/// </summary>
public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
#endregion Properties #endregion Properties
#region Methods #region Methods
...@@ -506,10 +536,10 @@ namespace Org.OpenAPITools.Client ...@@ -506,10 +536,10 @@ namespace Org.OpenAPITools.Client
/// </summary> /// </summary>
public static string ToDebugReport() public static string ToDebugReport()
{ {
string report = "C# SDK (Org.OpenAPITools) Debug Report:\n"; string report = "C# SDK (Coscine.MetadataExtractor.Core) Debug Report:\n";
report += " OS: " + System.Environment.OSVersion + "\n"; report += " OS: " + System.Environment.OSVersion + "\n";
report += " .NET Framework Version: " + System.Environment.Version + "\n"; report += " .NET Framework Version: " + System.Environment.Version + "\n";
report += " Version of the API: 0.1.1\n"; report += " Version of the API: 0.4.3\n";
report += " SDK Package Version: 1.0.0\n"; report += " SDK Package Version: 1.0.0\n";
return report; return report;
...@@ -572,6 +602,8 @@ namespace Org.OpenAPITools.Client ...@@ -572,6 +602,8 @@ namespace Org.OpenAPITools.Client
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath, TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat, DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat,
ClientCertificates = second.ClientCertificates ?? first.ClientCertificates, ClientCertificates = second.ClientCertificates ?? first.ClientCertificates,
UseDefaultCredentials = second.UseDefaultCredentials,
RemoteCertificateValidationCallback = second.RemoteCertificateValidationCallback ?? first.RemoteCertificateValidationCallback,
}; };
return config; return config;
} }
......
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// A delegate to ExceptionFactory method /// A delegate to ExceptionFactory method
......
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System.Collections.Generic;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// <see cref="GlobalConfiguration"/> provides a compile-time extension point for globally configuring /// <see cref="GlobalConfiguration"/> provides a compile-time extension point for globally configuring
......
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Http methods supported by swagger /// Http methods supported by swagger
......
...@@ -3,11 +3,14 @@ ...@@ -3,11 +3,14 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Represents configuration aspects required to interact with the API endpoints. /// Represents configuration aspects required to interact with the API endpoints.
......
...@@ -3,11 +3,15 @@ ...@@ -3,11 +3,15 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System;
using System.Threading.Tasks;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Contract for Asynchronous RESTful API interactions. /// Contract for Asynchronous RESTful API interactions.
......
...@@ -3,15 +3,18 @@ ...@@ -3,15 +3,18 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections.Generic;
using System.Net; using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates; using System.Security.Cryptography.X509Certificates;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Represents a readable-only configuration contract. /// Represents a readable-only configuration contract.
...@@ -97,6 +100,11 @@ namespace Org.OpenAPITools.Client ...@@ -97,6 +100,11 @@ namespace Org.OpenAPITools.Client
/// <value>Password.</value> /// <value>Password.</value>
string Password { get; } string Password { get; }
/// <summary>
/// Determine whether or not the "default credentials" (e.g. the user account under which the current process is running) will be sent along to the server. The default is false.
/// </summary>
bool UseDefaultCredentials { get; }
/// <summary> /// <summary>
/// Get the servers associated with the operation. /// Get the servers associated with the operation.
/// </summary> /// </summary>
...@@ -123,5 +131,11 @@ namespace Org.OpenAPITools.Client ...@@ -123,5 +131,11 @@ namespace Org.OpenAPITools.Client
/// </summary> /// </summary>
/// <value>X509 Certificate collection.</value> /// <value>X509 Certificate collection.</value>
X509CertificateCollection ClientCertificates { get; } X509CertificateCollection ClientCertificates { get; }
/// <summary>
/// Callback function for handling the validation of remote certificates. Useful for certificate pinning and
/// overriding certificate errors in the scope of a request.
/// </summary>
RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; }
} }
} }
...@@ -3,11 +3,15 @@ ...@@ -3,11 +3,15 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
namespace Org.OpenAPITools.Client
using System;
using System.IO;
namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Contract for Synchronous RESTful API interactions. /// Contract for Synchronous RESTful API interactions.
......
...@@ -3,14 +3,16 @@ ...@@ -3,14 +3,16 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// A dictionary in which one key has many associated values. /// A dictionary in which one key has many associated values.
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using Newtonsoft.Json.Converters; using Newtonsoft.Json.Converters;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Formatter for 'date' openapi formats ss defined by full-date - RFC3339 /// Formatter for 'date' openapi formats ss defined by full-date - RFC3339
......
...@@ -3,14 +3,17 @@ ...@@ -3,14 +3,17 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
using System;
using System.Collections.Generic;
using System.IO;
using System.Net; using System.Net;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// A container for generalized request inputs. This type allows consumers to extend the request functionality /// A container for generalized request inputs. This type allows consumers to extend the request functionality
...@@ -30,7 +33,7 @@ namespace Org.OpenAPITools.Client ...@@ -30,7 +33,7 @@ namespace Org.OpenAPITools.Client
public Multimap<string, string> QueryParameters { get; set; } public Multimap<string, string> QueryParameters { get; set; }
/// <summary> /// <summary>
/// Header parameters to be applied to to the request. /// Header parameters to be applied to the request.
/// Keys may have 1 or more values associated. /// Keys may have 1 or more values associated.
/// </summary> /// </summary>
public Multimap<string, string> HeaderParameters { get; set; } public Multimap<string, string> HeaderParameters { get; set; }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* This API extracts RDF triples from files * This API extracts RDF triples from files
* *
* The version of the OpenAPI document: 0.1.1 * The version of the OpenAPI document: 0.4.3
* Generated by: https://github.com/openapitools/openapi-generator.git * Generated by: https://github.com/openapitools/openapi-generator.git
*/ */
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
using Polly; using Polly;
using RestSharp; using RestSharp;
namespace Org.OpenAPITools.Client namespace Coscine.MetadataExtractor.Core.Client
{ {
/// <summary> /// <summary>
/// Configuration class to set the polly retry policies to be applied to the requests. /// Configuration class to set the polly retry policies to be applied to the requests.
......
...@@ -2,29 +2,29 @@ ...@@ -2,29 +2,29 @@
<PropertyGroup> <PropertyGroup>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 --> <GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->
<TargetFramework>netstandard2.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<AssemblyName>Org.OpenAPITools</AssemblyName> <AssemblyName>Coscine.MetadataExtractor.Core</AssemblyName>
<PackageId>Org.OpenAPITools</PackageId> <PackageId>Coscine.MetadataExtractor.Core</PackageId>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<Authors>OpenAPI</Authors> <Authors>OpenAPI</Authors>
<Company>OpenAPI</Company> <Company>OpenAPI</Company>
<AssemblyTitle>OpenAPI Library</AssemblyTitle> <AssemblyTitle>OpenAPI Library</AssemblyTitle>
<Description>A library generated from a OpenAPI doc</Description> <Description>A library generated from a OpenAPI doc</Description>
<Copyright>No Copyright</Copyright> <Copyright>No Copyright</Copyright>
<RootNamespace>Org.OpenAPITools</RootNamespace> <RootNamespace>Coscine.MetadataExtractor.Core</RootNamespace>
<Version>0.1.10</Version> <Version>0.1.11</Version>
<DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Org.OpenAPITools.xml</DocumentationFile> <DocumentationFile>bin\$(Configuration)\$(TargetFramework)\Coscine.MetadataExtractor.Core.xml</DocumentationFile>
<RepositoryUrl>https://github.com/GIT_USER_ID/GIT_REPO_ID.git</RepositoryUrl> <RepositoryUrl>https://github.com/GIT_USER_ID/GIT_REPO_ID.git</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Minor update</PackageReleaseNotes> <PackageReleaseNotes>Minor update</PackageReleaseNotes>
<Nullable>annotations</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="JsonSubTypes" Version="1.9.0" /> <PackageReference Include="JsonSubTypes" Version="2.0.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RestSharp" Version="108.0.1" /> <PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Polly" Version="7.2.3" /> <PackageReference Include="Polly" Version="7.2.3" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......