mirror of
https://github.com/eliasstepanik/IonosDDNSUpdater.git
synced 2026-01-11 19:48:26 +00:00
Added OpenAPI Generated APIClient
This commit is contained in:
parent
ab1c28f58a
commit
57d2b8d75f
@ -2,6 +2,8 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DDNSUpdater", "DDNSUpdater\DDNSUpdater.csproj", "{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DDNSUpdater", "DDNSUpdater\DDNSUpdater.csproj", "{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj", "{2F1B5788-B2D6-43B9-A523-5D308F33279C}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -12,5 +14,9 @@ Global
|
|||||||
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EDEDF642-4CFC-4EEB-A8F2-3872DBEC63E3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{2F1B5788-B2D6-43B9-A523-5D308F33279C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{2F1B5788-B2D6-43B9-A523-5D308F33279C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{2F1B5788-B2D6-43B9-A523-5D308F33279C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{2F1B5788-B2D6-43B9-A523-5D308F33279C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
6
DDNSUpdater/APIs/GRPC/Grpc.cs
Normal file
6
DDNSUpdater/APIs/GRPC/Grpc.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace DDNSUpdater.APIs.GRPC;
|
||||||
|
|
||||||
|
public class Grpc
|
||||||
|
{
|
||||||
|
//This is where the GRPC Server for Communication between Services should come
|
||||||
|
}
|
||||||
48
DDNSUpdater/APIs/Ionos/IonosAPIClient.cs
Normal file
48
DDNSUpdater/APIs/Ionos/IonosAPIClient.cs
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Extensions;
|
||||||
|
using Microsoft.Kiota.Serialization.Form;
|
||||||
|
using Microsoft.Kiota.Serialization.Json;
|
||||||
|
using Microsoft.Kiota.Serialization.Text;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient {
|
||||||
|
/// <summary>
|
||||||
|
/// The main entry point of the SDK, exposes the configuration and the fluent API.
|
||||||
|
/// </summary>
|
||||||
|
public class IonosAPIClient {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>The v1 property</summary>
|
||||||
|
public V1RequestBuilder V1 { get =>
|
||||||
|
new V1RequestBuilder(PathParameters, RequestAdapter);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new IonosAPIClient and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public IonosAPIClient(IRequestAdapter requestAdapter) {
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
PathParameters = new Dictionary<string, object>();
|
||||||
|
UrlTemplate = "{+baseurl}";
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
ApiClientBuilder.RegisterDefaultSerializer<JsonSerializationWriterFactory>();
|
||||||
|
ApiClientBuilder.RegisterDefaultSerializer<TextSerializationWriterFactory>();
|
||||||
|
ApiClientBuilder.RegisterDefaultSerializer<FormSerializationWriterFactory>();
|
||||||
|
ApiClientBuilder.RegisterDefaultDeserializer<JsonParseNodeFactory>();
|
||||||
|
ApiClientBuilder.RegisterDefaultDeserializer<TextParseNodeFactory>();
|
||||||
|
ApiClientBuilder.RegisterDefaultDeserializer<FormParseNodeFactory>();
|
||||||
|
if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) {
|
||||||
|
RequestAdapter.BaseUrl = "https://api.hosting.ionos.com/dns";
|
||||||
|
}
|
||||||
|
PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
74
DDNSUpdater/APIs/Ionos/Models/CustomerZone.cs
Normal file
74
DDNSUpdater/APIs/Ionos/Models/CustomerZone.cs
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class CustomerZone : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The zone id.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Id { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Id { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The zone name</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Name { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Name { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The records property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<RecordResponse>? Records { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<RecordResponse> Records { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>Represents the possible zone types.</summary>
|
||||||
|
public ZoneTypes? Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new CustomerZone and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public CustomerZone() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static CustomerZone CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new CustomerZone();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"id", n => { Id = n.GetStringValue(); } },
|
||||||
|
{"name", n => { Name = n.GetStringValue(); } },
|
||||||
|
{"records", n => { Records = n.GetCollectionOfObjectValues<RecordResponse>(RecordResponse.CreateFromDiscriminatorValue)?.ToList(); } },
|
||||||
|
{"type", n => { Type = n.GetEnumValue<ZoneTypes>(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("id", Id);
|
||||||
|
writer.WriteStringValue("name", Name);
|
||||||
|
writer.WriteCollectionOfObjectValues<RecordResponse>("records", Records);
|
||||||
|
writer.WriteEnumValue<ZoneTypes>("type", Type);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
DDNSUpdater/APIs/Ionos/Models/DynDnsRequest.cs
Normal file
60
DDNSUpdater/APIs/Ionos/Models/DynDnsRequest.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class DynDnsRequest : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>Dynamic Dns description.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Description { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Description { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The domains property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<string>? Domains { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<string> Domains { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new DynDnsRequest and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public DynDnsRequest() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static DynDnsRequest CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new DynDnsRequest();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"description", n => { Description = n.GetStringValue(); } },
|
||||||
|
{"domains", n => { Domains = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("description", Description);
|
||||||
|
writer.WriteCollectionOfPrimitiveValues<string>("domains", Domains);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
80
DDNSUpdater/APIs/Ionos/Models/DynamicDns.cs
Normal file
80
DDNSUpdater/APIs/Ionos/Models/DynamicDns.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class DynamicDns : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>DynDns configuration identifier.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? BulkId { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string BulkId { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>Dynamic Dns description.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Description { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Description { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The domains property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<string>? Domains { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<string> Domains { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>Use the url with GET to update the ips of (sub)domains. Query parameters: ipv4, ipv6.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? UpdateUrl { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string UpdateUrl { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new DynamicDns and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public DynamicDns() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static DynamicDns CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new DynamicDns();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"bulkId", n => { BulkId = n.GetStringValue(); } },
|
||||||
|
{"description", n => { Description = n.GetStringValue(); } },
|
||||||
|
{"domains", n => { Domains = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
|
||||||
|
{"updateUrl", n => { UpdateUrl = n.GetStringValue(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("bulkId", BulkId);
|
||||||
|
writer.WriteStringValue("description", Description);
|
||||||
|
writer.WriteCollectionOfPrimitiveValues<string>("domains", Domains);
|
||||||
|
writer.WriteStringValue("updateUrl", UpdateUrl);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
61
DDNSUpdater/APIs/Ionos/Models/Error.cs
Normal file
61
DDNSUpdater/APIs/Ionos/Models/Error.cs
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class Error : ApiException, IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The error code.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Code { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Code { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The error message.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? MessageEscaped { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string MessageEscaped { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new Error and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public Error() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static Error CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new Error();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"code", n => { Code = n.GetStringValue(); } },
|
||||||
|
{"message", n => { MessageEscaped = n.GetStringValue(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("code", Code);
|
||||||
|
writer.WriteStringValue("message", MessageEscaped);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
76
DDNSUpdater/APIs/Ionos/Models/Record.cs
Normal file
76
DDNSUpdater/APIs/Ionos/Models/Record.cs
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class Record : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The content property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Content { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Content { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>When is true, the record is not visible for lookup.</summary>
|
||||||
|
public bool? Disabled { get; set; }
|
||||||
|
/// <summary>The name property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Name { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Name { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The prio property</summary>
|
||||||
|
public int? Prio { get; set; }
|
||||||
|
/// <summary>Time to live for the record, recommended 3600.</summary>
|
||||||
|
public int? Ttl { get; set; }
|
||||||
|
/// <summary>Holds supported dns record types.</summary>
|
||||||
|
public RecordTypes? Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new record and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public Record() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static Record CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new Record();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"content", n => { Content = n.GetStringValue(); } },
|
||||||
|
{"disabled", n => { Disabled = n.GetBoolValue(); } },
|
||||||
|
{"name", n => { Name = n.GetStringValue(); } },
|
||||||
|
{"prio", n => { Prio = n.GetIntValue(); } },
|
||||||
|
{"ttl", n => { Ttl = n.GetIntValue(); } },
|
||||||
|
{"type", n => { Type = n.GetEnumValue<RecordTypes>(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("content", Content);
|
||||||
|
writer.WriteBoolValue("disabled", Disabled);
|
||||||
|
writer.WriteStringValue("name", Name);
|
||||||
|
writer.WriteIntValue("prio", Prio);
|
||||||
|
writer.WriteIntValue("ttl", Ttl);
|
||||||
|
writer.WriteEnumValue<RecordTypes>("type", Type);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
107
DDNSUpdater/APIs/Ionos/Models/RecordResponse.cs
Normal file
107
DDNSUpdater/APIs/Ionos/Models/RecordResponse.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class RecordResponse : ApiException, IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The date of the last change formatted as yyyy-MM-dd'T'HH:mm:ss.SSS'Z'</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? ChangeDate { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string ChangeDate { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The content property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Content { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Content { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>When is true, the record is not visible for lookup.</summary>
|
||||||
|
public bool? Disabled { get; set; }
|
||||||
|
/// <summary>The id property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Id { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Id { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The name property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Name { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Name { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The prio property</summary>
|
||||||
|
public int? Prio { get; set; }
|
||||||
|
/// <summary>Root zone name.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? RootName { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string RootName { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>Time to live for the record, recommended 3600.</summary>
|
||||||
|
public int? Ttl { get; set; }
|
||||||
|
/// <summary>Holds supported dns record types.</summary>
|
||||||
|
public RecordTypes? Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new recordResponse and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public RecordResponse() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static RecordResponse CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new RecordResponse();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"changeDate", n => { ChangeDate = n.GetStringValue(); } },
|
||||||
|
{"content", n => { Content = n.GetStringValue(); } },
|
||||||
|
{"disabled", n => { Disabled = n.GetBoolValue(); } },
|
||||||
|
{"id", n => { Id = n.GetStringValue(); } },
|
||||||
|
{"name", n => { Name = n.GetStringValue(); } },
|
||||||
|
{"prio", n => { Prio = n.GetIntValue(); } },
|
||||||
|
{"rootName", n => { RootName = n.GetStringValue(); } },
|
||||||
|
{"ttl", n => { Ttl = n.GetIntValue(); } },
|
||||||
|
{"type", n => { Type = n.GetEnumValue<RecordTypes>(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("changeDate", ChangeDate);
|
||||||
|
writer.WriteStringValue("content", Content);
|
||||||
|
writer.WriteBoolValue("disabled", Disabled);
|
||||||
|
writer.WriteStringValue("id", Id);
|
||||||
|
writer.WriteStringValue("name", Name);
|
||||||
|
writer.WriteIntValue("prio", Prio);
|
||||||
|
writer.WriteStringValue("rootName", RootName);
|
||||||
|
writer.WriteIntValue("ttl", Ttl);
|
||||||
|
writer.WriteEnumValue<RecordTypes>("type", Type);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
25
DDNSUpdater/APIs/Ionos/Models/RecordTypes.cs
Normal file
25
DDNSUpdater/APIs/Ionos/Models/RecordTypes.cs
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
/// <summary>Holds supported dns record types.</summary>
|
||||||
|
public enum RecordTypes {
|
||||||
|
A,
|
||||||
|
AAAA,
|
||||||
|
CNAME,
|
||||||
|
MX,
|
||||||
|
NS,
|
||||||
|
SOA,
|
||||||
|
SRV,
|
||||||
|
TXT,
|
||||||
|
CAA,
|
||||||
|
TLSA,
|
||||||
|
SMIMEA,
|
||||||
|
SSHFP,
|
||||||
|
DS,
|
||||||
|
HTTPS,
|
||||||
|
SVCB,
|
||||||
|
CERT,
|
||||||
|
URI,
|
||||||
|
RP,
|
||||||
|
LOC,
|
||||||
|
OPENPGPKEY,
|
||||||
|
}
|
||||||
|
}
|
||||||
62
DDNSUpdater/APIs/Ionos/Models/RecordUpdate.cs
Normal file
62
DDNSUpdater/APIs/Ionos/Models/RecordUpdate.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class RecordUpdate : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The content property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Content { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Content { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>When is true, the record is not visible for lookup.</summary>
|
||||||
|
public bool? Disabled { get; set; }
|
||||||
|
/// <summary>The prio property</summary>
|
||||||
|
public int? Prio { get; set; }
|
||||||
|
/// <summary>Time to live for the record, recommended 3600.</summary>
|
||||||
|
public int? Ttl { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new RecordUpdate and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public RecordUpdate() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static RecordUpdate CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new RecordUpdate();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"content", n => { Content = n.GetStringValue(); } },
|
||||||
|
{"disabled", n => { Disabled = n.GetBoolValue(); } },
|
||||||
|
{"prio", n => { Prio = n.GetIntValue(); } },
|
||||||
|
{"ttl", n => { Ttl = n.GetIntValue(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("content", Content);
|
||||||
|
writer.WriteBoolValue("disabled", Disabled);
|
||||||
|
writer.WriteIntValue("prio", Prio);
|
||||||
|
writer.WriteIntValue("ttl", Ttl);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
91
DDNSUpdater/APIs/Ionos/Models/WithZone.cs
Normal file
91
DDNSUpdater/APIs/Ionos/Models/WithZone.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class WithZone : ApiException, IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The errorRecord property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public Record? ErrorRecord { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public Record ErrorRecord { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The inputRecord property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public Record? InputRecord { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public Record InputRecord { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The invalid property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<string>? Invalid { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<string> Invalid { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The invalidFields property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<string>? InvalidFields { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<string> InvalidFields { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The requiredFields property</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public List<string>? RequiredFields { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public List<string> RequiredFields { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZone and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithZone() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static WithZone CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new WithZone();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"errorRecord", n => { ErrorRecord = n.GetObjectValue<Record>(Record.CreateFromDiscriminatorValue); } },
|
||||||
|
{"inputRecord", n => { InputRecord = n.GetObjectValue<Record>(Record.CreateFromDiscriminatorValue); } },
|
||||||
|
{"invalid", n => { Invalid = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
|
||||||
|
{"invalidFields", n => { InvalidFields = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
|
||||||
|
{"requiredFields", n => { RequiredFields = n.GetCollectionOfPrimitiveValues<string>()?.ToList(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteObjectValue<Record>("errorRecord", ErrorRecord);
|
||||||
|
writer.WriteObjectValue<Record>("inputRecord", InputRecord);
|
||||||
|
writer.WriteCollectionOfPrimitiveValues<string>("invalid", Invalid);
|
||||||
|
writer.WriteCollectionOfPrimitiveValues<string>("invalidFields", InvalidFields);
|
||||||
|
writer.WriteCollectionOfPrimitiveValues<string>("requiredFields", RequiredFields);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
64
DDNSUpdater/APIs/Ionos/Models/Zone.cs
Normal file
64
DDNSUpdater/APIs/Ionos/Models/Zone.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
public class Zone : IAdditionalDataHolder, IParsable {
|
||||||
|
/// <summary>Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well.</summary>
|
||||||
|
public IDictionary<string, object> AdditionalData { get; set; }
|
||||||
|
/// <summary>The zone id.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Id { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Id { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The zone name.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Name { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Name { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>Represents the possible zone types.</summary>
|
||||||
|
public ZoneTypes? Type { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new Zone and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public Zone() {
|
||||||
|
AdditionalData = new Dictionary<string, object>();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new instance of the appropriate class based on discriminator value
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="parseNode">The parse node to use to read the discriminator value and create the object</param>
|
||||||
|
public static Zone CreateFromDiscriminatorValue(IParseNode parseNode) {
|
||||||
|
_ = parseNode ?? throw new ArgumentNullException(nameof(parseNode));
|
||||||
|
return new Zone();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// The deserialization information for the current model
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, Action<IParseNode>> GetFieldDeserializers() {
|
||||||
|
return new Dictionary<string, Action<IParseNode>> {
|
||||||
|
{"id", n => { Id = n.GetStringValue(); } },
|
||||||
|
{"name", n => { Name = n.GetStringValue(); } },
|
||||||
|
{"type", n => { Type = n.GetEnumValue<ZoneTypes>(); } },
|
||||||
|
};
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Serializes information the current object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writer">Serialization writer to use to serialize this model</param>
|
||||||
|
public void Serialize(ISerializationWriter writer) {
|
||||||
|
_ = writer ?? throw new ArgumentNullException(nameof(writer));
|
||||||
|
writer.WriteStringValue("id", Id);
|
||||||
|
writer.WriteStringValue("name", Name);
|
||||||
|
writer.WriteEnumValue<ZoneTypes>("type", Type);
|
||||||
|
writer.WriteAdditionalData(AdditionalData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
7
DDNSUpdater/APIs/Ionos/Models/ZoneTypes.cs
Normal file
7
DDNSUpdater/APIs/Ionos/Models/ZoneTypes.cs
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.Models {
|
||||||
|
/// <summary>Represents the possible zone types.</summary>
|
||||||
|
public enum ZoneTypes {
|
||||||
|
NATIVE,
|
||||||
|
SLAVE,
|
||||||
|
}
|
||||||
|
}
|
||||||
181
DDNSUpdater/APIs/Ionos/V1/Dyndns/DyndnsRequestBuilder.cs
Normal file
181
DDNSUpdater/APIs/Ionos/V1/Dyndns/DyndnsRequestBuilder.cs
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Dyndns.Item;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Dyndns {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\dyndns
|
||||||
|
/// </summary>
|
||||||
|
public class DyndnsRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>Gets an item from the DDNSUpdater.APIs.Ionos.ApiClient.v1.dyndns.item collection</summary>
|
||||||
|
public WithBulkItemRequestBuilder this[string position] { get {
|
||||||
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
|
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("bulkId", position);
|
||||||
|
return new WithBulkItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
|
} }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new DyndnsRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public DyndnsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/dyndns";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new DyndnsRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public DyndnsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/dyndns";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Disable Dynamic Dns.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> DeleteAsync(Action<DyndnsRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> DeleteAsync(Action<DyndnsRequestBuilderDeleteRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Activate Dynamic Dns for a bundle of (sub)domains. The url from response will be used to update the ips of the (sub)domains.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<DynamicDns?> PostAsync(DynDnsRequest body, Action<DyndnsRequestBuilderPostRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<DynamicDns> PostAsync(DynDnsRequest body, Action<DyndnsRequestBuilderPostRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendAsync<DynamicDns>(requestInfo, DynamicDns.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Disable Dynamic Dns.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<DyndnsRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<DyndnsRequestBuilderDeleteRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.DELETE,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new DyndnsRequestBuilderDeleteRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Activate Dynamic Dns for a bundle of (sub)domains. The url from response will be used to update the ips of the (sub)domains.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPostRequestInformation(DynDnsRequest body, Action<DyndnsRequestBuilderPostRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPostRequestInformation(DynDnsRequest body, Action<DyndnsRequestBuilderPostRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.POST,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new DyndnsRequestBuilderPostRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class DyndnsRequestBuilderDeleteRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new dyndnsRequestBuilderDeleteRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public DyndnsRequestBuilderDeleteRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class DyndnsRequestBuilderPostRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new dyndnsRequestBuilderPostRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public DyndnsRequestBuilderPostRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,175 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Dyndns.Item {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\dyndns\{bulkId}
|
||||||
|
/// </summary>
|
||||||
|
public class WithBulkItemRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithBulkItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithBulkItemRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/dyndns/{bulkId}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithBulkItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithBulkItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/dyndns/{bulkId}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Disable Dynamic Dns for bulk id.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> DeleteAsync(Action<WithBulkItemRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> DeleteAsync(Action<WithBulkItemRequestBuilderDeleteRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Update Dynamic Dns for bulk id.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> PutAsync(DynDnsRequest body, Action<WithBulkItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> PutAsync(DynDnsRequest body, Action<WithBulkItemRequestBuilderPutRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPutRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"403", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"404", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Disable Dynamic Dns for bulk id.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<WithBulkItemRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<WithBulkItemRequestBuilderDeleteRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.DELETE,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithBulkItemRequestBuilderDeleteRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Update Dynamic Dns for bulk id.The following quota applies: 2 requests per minute per IP address.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPutRequestInformation(DynDnsRequest body, Action<WithBulkItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPutRequestInformation(DynDnsRequest body, Action<WithBulkItemRequestBuilderPutRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.PUT,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithBulkItemRequestBuilderPutRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithBulkItemRequestBuilderDeleteRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithBulkItemRequestBuilderDeleteRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithBulkItemRequestBuilderDeleteRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithBulkItemRequestBuilderPutRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithBulkItemRequestBuilderPutRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithBulkItemRequestBuilderPutRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
56
DDNSUpdater/APIs/Ionos/V1/V1RequestBuilder.cs
Normal file
56
DDNSUpdater/APIs/Ionos/V1/V1RequestBuilder.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Dyndns;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1 {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1
|
||||||
|
/// </summary>
|
||||||
|
public class V1RequestBuilder {
|
||||||
|
/// <summary>The dyndns property</summary>
|
||||||
|
public DyndnsRequestBuilder Dyndns { get =>
|
||||||
|
new DyndnsRequestBuilder(PathParameters, RequestAdapter);
|
||||||
|
}
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>The zones property</summary>
|
||||||
|
public ZonesRequestBuilder Zones { get =>
|
||||||
|
new ZonesRequestBuilder(PathParameters, RequestAdapter);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new V1RequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public V1RequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new V1RequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public V1RequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,237 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item.Records.Item {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\zones\{zoneId}\records\{recordId}
|
||||||
|
/// </summary>
|
||||||
|
public class WithRecordItemRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithRecordItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithRecordItemRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}/records/{recordId}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithRecordItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithRecordItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}/records/{recordId}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a record from the customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> DeleteAsync(Action<WithRecordItemRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> DeleteAsync(Action<WithRecordItemRequestBuilderDeleteRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToDeleteRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"404", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the record from the customer zone with the mentioned id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<RecordResponse?> GetAsync(Action<WithRecordItemRequestBuilderGetRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<RecordResponse> GetAsync(Action<WithRecordItemRequestBuilderGetRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToGetRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"404", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendAsync<RecordResponse>(requestInfo, RecordResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Update a record from the customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<RecordResponse?> PutAsync(RecordUpdate body, Action<WithRecordItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<RecordResponse> PutAsync(RecordUpdate body, Action<WithRecordItemRequestBuilderPutRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPutRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", RecordResponse.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"404", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendAsync<RecordResponse>(requestInfo, RecordResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Delete a record from the customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<WithRecordItemRequestBuilderDeleteRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToDeleteRequestInformation(Action<WithRecordItemRequestBuilderDeleteRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.DELETE,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithRecordItemRequestBuilderDeleteRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the record from the customer zone with the mentioned id.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<WithRecordItemRequestBuilderGetRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<WithRecordItemRequestBuilderGetRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.GET,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithRecordItemRequestBuilderGetRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Update a record from the customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPutRequestInformation(RecordUpdate body, Action<WithRecordItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPutRequestInformation(RecordUpdate body, Action<WithRecordItemRequestBuilderPutRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.PUT,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithRecordItemRequestBuilderPutRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithRecordItemRequestBuilderDeleteRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithRecordItemRequestBuilderDeleteRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithRecordItemRequestBuilderDeleteRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithRecordItemRequestBuilderGetRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithRecordItemRequestBuilderGetRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithRecordItemRequestBuilderGetRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithRecordItemRequestBuilderPutRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithRecordItemRequestBuilderPutRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithRecordItemRequestBuilderPutRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,123 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item.Records.Item;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item.Records {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\zones\{zoneId}\records
|
||||||
|
/// </summary>
|
||||||
|
public class RecordsRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>Gets an item from the DDNSUpdater.APIs.Ionos.ApiClient.v1.zones.item.records.item collection</summary>
|
||||||
|
public WithRecordItemRequestBuilder this[string position] { get {
|
||||||
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
|
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("recordId", position);
|
||||||
|
return new WithRecordItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
|
} }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new RecordsRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public RecordsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}/records";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new RecordsRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public RecordsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}/records";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates records for a customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<List<RecordResponse>?> PostAsync(List<Record> body, Action<RecordsRequestBuilderPostRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<List<RecordResponse>> PostAsync(List<Record> body, Action<RecordsRequestBuilderPostRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
var collectionResult = await RequestAdapter.SendCollectionAsync<RecordResponse>(requestInfo, RecordResponse.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
return collectionResult?.ToList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Creates records for a customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPostRequestInformation(List<Record> body, Action<RecordsRequestBuilderPostRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPostRequestInformation(List<Record> body, Action<RecordsRequestBuilderPostRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.POST,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new RecordsRequestBuilderPostRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class RecordsRequestBuilderPostRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new recordsRequestBuilderPostRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public RecordsRequestBuilderPostRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,276 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item.Records;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\zones\{zoneId}
|
||||||
|
/// </summary>
|
||||||
|
public class WithZoneItemRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The records property</summary>
|
||||||
|
public RecordsRequestBuilder Records { get =>
|
||||||
|
new RecordsRequestBuilder(PathParameters, RequestAdapter);
|
||||||
|
}
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZoneItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithZoneItemRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}{?suffix*,recordName*,recordType*}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZoneItemRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public WithZoneItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones/{zoneId}{?suffix*,recordName*,recordType*}";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<CustomerZone?> GetAsync(Action<WithZoneItemRequestBuilderGetRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<CustomerZone> GetAsync(Action<WithZoneItemRequestBuilderGetRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToGetRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendAsync<CustomerZone>(requestInfo, CustomerZone.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all records of the same name and type with the ones provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> PatchAsync(List<Record> body, Action<WithZoneItemRequestBuilderPatchRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> PatchAsync(List<Record> body, Action<WithZoneItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPatchRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", WithZone.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all records in the zone with the ones provided
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<Stream?> PutAsync(List<Record> body, Action<WithZoneItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<Stream> PutAsync(List<Record> body, Action<WithZoneItemRequestBuilderPutRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = ToPutRequestInformation(body, requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"400", WithZone.CreateFromDiscriminatorValue},
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
return await RequestAdapter.SendPrimitiveAsync<Stream>(requestInfo, errorMapping, cancellationToken);
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a customer zone.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<WithZoneItemRequestBuilderGetRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<WithZoneItemRequestBuilderGetRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.GET,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithZoneItemRequestBuilderGetRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddQueryParameters(requestConfig.QueryParameters);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all records of the same name and type with the ones provided.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPatchRequestInformation(List<Record> body, Action<WithZoneItemRequestBuilderPatchRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPatchRequestInformation(List<Record> body, Action<WithZoneItemRequestBuilderPatchRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.PATCH,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithZoneItemRequestBuilderPatchRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Replaces all records in the zone with the ones provided
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="body">The request body</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToPutRequestInformation(List<Record> body, Action<WithZoneItemRequestBuilderPutRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToPutRequestInformation(List<Record> body, Action<WithZoneItemRequestBuilderPutRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
_ = body ?? throw new ArgumentNullException(nameof(body));
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.PUT,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.SetContentFromParsable(RequestAdapter, "application/json", body);
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new WithZoneItemRequestBuilderPutRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a customer zone.
|
||||||
|
/// </summary>
|
||||||
|
public class WithZoneItemRequestBuilderGetQueryParameters {
|
||||||
|
/// <summary>The record names that should be included (same as name field of Record)</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? RecordName { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string RecordName { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>A comma-separated list of record types that should be included</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? RecordType { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string RecordType { get; set; }
|
||||||
|
#endif
|
||||||
|
/// <summary>The FQDN used to filter all the record names that end with it.</summary>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public string? Suffix { get; set; }
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public string Suffix { get; set; }
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithZoneItemRequestBuilderGetRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>Request query parameters</summary>
|
||||||
|
public WithZoneItemRequestBuilderGetQueryParameters QueryParameters { get; set; } = new WithZoneItemRequestBuilderGetQueryParameters();
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZoneItemRequestBuilderGetRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithZoneItemRequestBuilderGetRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithZoneItemRequestBuilderPatchRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZoneItemRequestBuilderPatchRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithZoneItemRequestBuilderPatchRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class WithZoneItemRequestBuilderPutRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new WithZoneItemRequestBuilderPutRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public WithZoneItemRequestBuilderPutRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
117
DDNSUpdater/APIs/Ionos/V1/Zones/ZonesRequestBuilder.cs
Normal file
117
DDNSUpdater/APIs/Ionos/V1/Zones/ZonesRequestBuilder.cs
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones.Item;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Serialization;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DDNSUpdater.APIs.Ionos.ApiClient.V1.Zones {
|
||||||
|
/// <summary>
|
||||||
|
/// Builds and executes requests for operations under \v1\zones
|
||||||
|
/// </summary>
|
||||||
|
public class ZonesRequestBuilder {
|
||||||
|
/// <summary>Path parameters for the request</summary>
|
||||||
|
private Dictionary<string, object> PathParameters { get; set; }
|
||||||
|
/// <summary>The request adapter to use to execute the requests.</summary>
|
||||||
|
private IRequestAdapter RequestAdapter { get; set; }
|
||||||
|
/// <summary>Url template to use to build the URL for the current request builder</summary>
|
||||||
|
private string UrlTemplate { get; set; }
|
||||||
|
/// <summary>Gets an item from the DDNSUpdater.APIs.Ionos.ApiClient.v1.zones.item collection</summary>
|
||||||
|
public WithZoneItemRequestBuilder this[string position] { get {
|
||||||
|
var urlTplParams = new Dictionary<string, object>(PathParameters);
|
||||||
|
if (!string.IsNullOrWhiteSpace(position)) urlTplParams.Add("zoneId", position);
|
||||||
|
return new WithZoneItemRequestBuilder(urlTplParams, RequestAdapter);
|
||||||
|
} }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new ZonesRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathParameters">Path parameters for the request</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public ZonesRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) {
|
||||||
|
_ = pathParameters ?? throw new ArgumentNullException(nameof(pathParameters));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones";
|
||||||
|
var urlTplParams = new Dictionary<string, object>(pathParameters);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new ZonesRequestBuilder and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
|
||||||
|
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
|
||||||
|
public ZonesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) {
|
||||||
|
if(string.IsNullOrEmpty(rawUrl)) throw new ArgumentNullException(nameof(rawUrl));
|
||||||
|
_ = requestAdapter ?? throw new ArgumentNullException(nameof(requestAdapter));
|
||||||
|
UrlTemplate = "{+baseurl}/v1/zones";
|
||||||
|
var urlTplParams = new Dictionary<string, object>();
|
||||||
|
if (!string.IsNullOrWhiteSpace(rawUrl)) urlTplParams.Add("request-raw-url", rawUrl);
|
||||||
|
PathParameters = urlTplParams;
|
||||||
|
RequestAdapter = requestAdapter;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns list of customer zones.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public async Task<List<Zone>?> GetAsync(Action<ZonesRequestBuilderGetRequestConfiguration>? requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public async Task<List<Zone>> GetAsync(Action<ZonesRequestBuilderGetRequestConfiguration> requestConfiguration = default, CancellationToken cancellationToken = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = ToGetRequestInformation(requestConfiguration);
|
||||||
|
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>> {
|
||||||
|
{"401", Error.CreateFromDiscriminatorValue},
|
||||||
|
{"500", Error.CreateFromDiscriminatorValue},
|
||||||
|
};
|
||||||
|
var collectionResult = await RequestAdapter.SendCollectionAsync<Zone>(requestInfo, Zone.CreateFromDiscriminatorValue, errorMapping, cancellationToken);
|
||||||
|
return collectionResult?.ToList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Returns list of customer zones.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
|
||||||
|
#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER
|
||||||
|
#nullable enable
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<ZonesRequestBuilderGetRequestConfiguration>? requestConfiguration = default) {
|
||||||
|
#nullable restore
|
||||||
|
#else
|
||||||
|
public RequestInformation ToGetRequestInformation(Action<ZonesRequestBuilderGetRequestConfiguration> requestConfiguration = default) {
|
||||||
|
#endif
|
||||||
|
var requestInfo = new RequestInformation {
|
||||||
|
HttpMethod = Method.GET,
|
||||||
|
UrlTemplate = UrlTemplate,
|
||||||
|
PathParameters = PathParameters,
|
||||||
|
};
|
||||||
|
requestInfo.Headers.Add("Accept", "application/json");
|
||||||
|
if (requestConfiguration != null) {
|
||||||
|
var requestConfig = new ZonesRequestBuilderGetRequestConfiguration();
|
||||||
|
requestConfiguration.Invoke(requestConfig);
|
||||||
|
requestInfo.AddRequestOptions(requestConfig.Options);
|
||||||
|
requestInfo.AddHeaders(requestConfig.Headers);
|
||||||
|
}
|
||||||
|
return requestInfo;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Configuration for the request such as headers, query parameters, and middleware options.
|
||||||
|
/// </summary>
|
||||||
|
public class ZonesRequestBuilderGetRequestConfiguration {
|
||||||
|
/// <summary>Request headers</summary>
|
||||||
|
public RequestHeaders Headers { get; set; }
|
||||||
|
/// <summary>Request options</summary>
|
||||||
|
public IList<IRequestOption> Options { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Instantiates a new zonesRequestBuilderGetRequestConfiguration and sets the default values.
|
||||||
|
/// </summary>
|
||||||
|
public ZonesRequestBuilderGetRequestConfiguration() {
|
||||||
|
Options = new List<IRequestOption>();
|
||||||
|
Headers = new RequestHeaders();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1200
DDNSUpdater/APIs/Ionos/dns.yml
Normal file
1200
DDNSUpdater/APIs/Ionos/dns.yml
Normal file
File diff suppressed because it is too large
Load Diff
29
DDNSUpdater/APIs/Ionos/kiota-lock.json
Normal file
29
DDNSUpdater/APIs/Ionos/kiota-lock.json
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
{
|
||||||
|
"descriptionHash": "9A16B89F524811904DA32D7B012B195937F8B243B3A466F6D6D8CCEAA2513B867643FB85327DB2AFFE886448B547E97877797F36A997FD7DD4C87331BDCDEDCC",
|
||||||
|
"descriptionLocation": "C:\\Users\\elias\\RiderProjects\\IonosDynamicDNSUpdater\\DDNSUpdater\\APIs\\Ionos\\dns.yml",
|
||||||
|
"lockFileVersion": "1.0.0",
|
||||||
|
"kiotaVersion": "1.0.1",
|
||||||
|
"clientClassName": "IonosAPIClient",
|
||||||
|
"clientNamespaceName": "DDNSUpdater.APIs.Ionos.ApiClient",
|
||||||
|
"language": "CSharp",
|
||||||
|
"usesBackingStore": false,
|
||||||
|
"includeAdditionalData": true,
|
||||||
|
"serializers": [
|
||||||
|
"Microsoft.Kiota.Serialization.Json.JsonSerializationWriterFactory",
|
||||||
|
"Microsoft.Kiota.Serialization.Text.TextSerializationWriterFactory",
|
||||||
|
"Microsoft.Kiota.Serialization.Form.FormSerializationWriterFactory"
|
||||||
|
],
|
||||||
|
"deserializers": [
|
||||||
|
"Microsoft.Kiota.Serialization.Json.JsonParseNodeFactory",
|
||||||
|
"Microsoft.Kiota.Serialization.Text.TextParseNodeFactory",
|
||||||
|
"Microsoft.Kiota.Serialization.Form.FormParseNodeFactory"
|
||||||
|
],
|
||||||
|
"structuredMimeTypes": [
|
||||||
|
"application/json",
|
||||||
|
"text/plain",
|
||||||
|
"application/x-www-form-urlencoded"
|
||||||
|
],
|
||||||
|
"includePatterns": [],
|
||||||
|
"excludePatterns": [],
|
||||||
|
"disabledValidationRules": []
|
||||||
|
}
|
||||||
9
DDNSUpdater/Abstracts/ADDNSService.cs
Normal file
9
DDNSUpdater/Abstracts/ADDNSService.cs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
namespace DDNSUpdater.Abstracts;
|
||||||
|
|
||||||
|
public abstract class ADDNSService
|
||||||
|
{
|
||||||
|
public abstract void Update();
|
||||||
|
|
||||||
|
// Rest of the class implementation
|
||||||
|
// ...
|
||||||
|
}
|
||||||
@ -12,10 +12,16 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="7.0.0" />
|
||||||
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.2" />
|
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.1.0" />
|
||||||
<PackageReference Include="RestSharp" Version="108.0.3" />
|
<PackageReference Include="Microsoft.Kiota.Http.HttpClientLibrary" Version="1.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Kiota.Serialization.Form" Version="1.0.1" />
|
||||||
|
<PackageReference Include="Microsoft.Kiota.Serialization.Json" Version="1.0.3" />
|
||||||
|
<PackageReference Include="Microsoft.Kiota.Serialization.Text" Version="1.0.1" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="RestSharp" Version="109.0.1" />
|
||||||
<PackageReference Include="Spectre.Console" Version="0.46.0" />
|
<PackageReference Include="Spectre.Console" Version="0.46.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@ -1,3 +1,5 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace DDNSUpdater.Models;
|
namespace DDNSUpdater.Models;
|
||||||
|
|
||||||
public class Domain
|
public class Domain
|
||||||
@ -10,4 +12,10 @@ public class Domain
|
|||||||
|
|
||||||
public string DomainString { get; set; }
|
public string DomainString { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class DomainGroup
|
||||||
|
{
|
||||||
|
public List<Domain> Domains { get; set; }
|
||||||
}
|
}
|
||||||
@ -8,54 +8,51 @@ using Microsoft.Extensions.Logging;
|
|||||||
using Microsoft.Extensions.Options;
|
using Microsoft.Extensions.Options;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
|
||||||
|
// A generic method to parse a string value into an enum of type T
|
||||||
static T ParseEnum<T>(string value)
|
static T ParseEnum<T>(string value)
|
||||||
{
|
{
|
||||||
return (T) Enum.Parse(typeof(T), value, true);
|
return (T) Enum.Parse(typeof(T), value, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Build the configuration object by loading configuration settings from an appsettings.json file
|
||||||
var builder = new ConfigurationBuilder()
|
var builder = new ConfigurationBuilder()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false);
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false);
|
||||||
|
|
||||||
|
// Read the log level from the environment variable LogLevel, or set it to LogLevel.Information if the variable is not set
|
||||||
LogLevel loglevel;
|
LogLevel loglevel;
|
||||||
if (Environment.GetEnvironmentVariables()["LogLevel"] != null)
|
if (Environment.GetEnvironmentVariables()["LogLevel"] != null)
|
||||||
loglevel = ParseEnum<LogLevel>(Environment.GetEnvironmentVariables()["LogLevel"].ToString());
|
loglevel = ParseEnum<LogLevel>(Environment.GetEnvironmentVariables()["LogLevel"].ToString());
|
||||||
else
|
else
|
||||||
loglevel = LogLevel.Information;
|
loglevel = LogLevel.Information;
|
||||||
|
|
||||||
|
|
||||||
var configuration = builder.Build();
|
var configuration = builder.Build();
|
||||||
|
|
||||||
/*var logConfig = new OptionsMonitor<SpecterConsoleLoggerConfiguration>();
|
// Set up the service collection to configure and register application services
|
||||||
logConfig.CurrentValue.LogLevelToColorMap[LogLevel.Warning] = ConsoleColor.DarkCyan;
|
|
||||||
logConfig.CurrentValue.LogLevelToColorMap[LogLevel.Error] = ConsoleColor.DarkRed;*/
|
|
||||||
|
|
||||||
var serviceProvider = new ServiceCollection()
|
var serviceProvider = new ServiceCollection()
|
||||||
.AddSingleton<IConfiguration>(configuration)
|
.AddSingleton<IConfiguration>(configuration)
|
||||||
.AddLogging(logging =>
|
.AddLogging(logging =>
|
||||||
{
|
{
|
||||||
|
// Add a custom SpecterConsoleLogger to the logging pipeline with color mappings for different log levels
|
||||||
logging.AddSpecterConsoleLogger(configuration =>
|
logging.AddSpecterConsoleLogger(configuration =>
|
||||||
{
|
{
|
||||||
// Replace warning value from appsettings.json of "Cyan"
|
|
||||||
configuration.LogLevelToColorMap[LogLevel.Warning] = ConsoleColor.DarkCyan;
|
configuration.LogLevelToColorMap[LogLevel.Warning] = ConsoleColor.DarkCyan;
|
||||||
configuration.LogLevelToColorMap[LogLevel.Debug] = ConsoleColor.DarkYellow;
|
configuration.LogLevelToColorMap[LogLevel.Debug] = ConsoleColor.DarkYellow;
|
||||||
// Replace warning value from appsettings.json of "Red"
|
|
||||||
configuration.LogLevelToColorMap[LogLevel.Error] = ConsoleColor.DarkRed;
|
configuration.LogLevelToColorMap[LogLevel.Error] = ConsoleColor.DarkRed;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Set the minimum log level to the value of the loglevel variable
|
||||||
logging.SetMinimumLevel(loglevel);
|
logging.SetMinimumLevel(loglevel);
|
||||||
})
|
})
|
||||||
.AddSingleton<ITimerService, TimerService>()
|
.AddSingleton<ITimerService, TimerService>()
|
||||||
.AddSingleton<DDNSService>()
|
.AddSingleton<DDNSService>()
|
||||||
.BuildServiceProvider();
|
.BuildServiceProvider();
|
||||||
|
|
||||||
|
// Retrieve the DDNSService and ITimerService from the service provider and start them
|
||||||
|
|
||||||
|
|
||||||
var dataAccess = serviceProvider.GetService<DDNSService>();
|
var dataAccess = serviceProvider.GetService<DDNSService>();
|
||||||
dataAccess.Start();
|
dataAccess.Start();
|
||||||
|
|
||||||
var timerService = serviceProvider.GetService<ITimerService>();
|
var timerService = serviceProvider.GetService<ITimerService>();
|
||||||
timerService.Start();
|
timerService.Start();
|
||||||
|
|
||||||
|
// Wait for a key press before exiting the program
|
||||||
Console.ReadKey();
|
Console.ReadKey();
|
||||||
|
|||||||
@ -5,27 +5,38 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Net.Mime;
|
using System.Net.Mime;
|
||||||
|
using System.Security.Authentication;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using DDNSUpdater.Abstracts;
|
||||||
|
using DDNSUpdater.APIs.Ionos;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient;
|
||||||
|
using DDNSUpdater.APIs.Ionos.ApiClient.Models;
|
||||||
using DDNSUpdater.Interfaces;
|
using DDNSUpdater.Interfaces;
|
||||||
using DDNSUpdater.Logging;
|
using DDNSUpdater.Logging;
|
||||||
using DDNSUpdater.Models;
|
using DDNSUpdater.Models;
|
||||||
using DDNSUpdater.Models.Requests;
|
using DDNSUpdater.Models.Requests;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Kiota.Abstractions;
|
||||||
|
using Microsoft.Kiota.Abstractions.Authentication;
|
||||||
|
using Microsoft.Kiota.Http.HttpClientLibrary;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
using Spectre.Console;
|
using Spectre.Console;
|
||||||
using Console = Spectre.Console.AnsiConsole;
|
using Console = Spectre.Console.AnsiConsole;
|
||||||
using ContentType = RestSharp.Serializers.ContentType;
|
using ContentType = RestSharp.ContentType;
|
||||||
|
using DynamicDns = DDNSUpdater.Models.Requests.DynamicDns;
|
||||||
|
using Method = RestSharp.Method;
|
||||||
|
|
||||||
namespace DDNSUpdater.Services;
|
namespace DDNSUpdater.Services;
|
||||||
|
|
||||||
public class DDNSService : IDDNSService
|
public class DDNSService : ADDNSService
|
||||||
{
|
{
|
||||||
private List<string>? UpdateURLs { get; set; }
|
private List<string>? UpdateURLs { get; set; }
|
||||||
public List<Domain> Domains { get; set; }
|
public List<Domain> Domains { get; set; }
|
||||||
|
|
||||||
private readonly ILogger<DDNSService> _logger;
|
private readonly ILogger<DDNSService> _logger;
|
||||||
|
private IonosAPIClient _client;
|
||||||
|
|
||||||
public DDNSService(ILogger<DDNSService> logger,IConfiguration configuration)
|
public DDNSService(ILogger<DDNSService> logger,IConfiguration configuration)
|
||||||
{
|
{
|
||||||
@ -44,8 +55,12 @@ public class DDNSService : IDDNSService
|
|||||||
Domains.Add(new Domain(env[0], env[1]));
|
Domains.Add(new Domain(env[0], env[1]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var authProvider = new AnonymousAuthenticationProvider();
|
||||||
|
var requestAdapter = new HttpClientRequestAdapter(authProvider);
|
||||||
|
_client = new IonosAPIClient(requestAdapter);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Start()
|
public async void Start()
|
||||||
@ -60,8 +75,10 @@ public class DDNSService : IDDNSService
|
|||||||
_logger.LogInformation($"Fetched {UpdateURLs.Count} UpdateURLs");
|
_logger.LogInformation($"Fetched {UpdateURLs.Count} UpdateURLs");
|
||||||
}
|
}
|
||||||
|
|
||||||
public async void Update()
|
public override async void Update()
|
||||||
{
|
{
|
||||||
|
if(UpdateURLs != null && UpdateURLs.Count != 0)
|
||||||
|
|
||||||
foreach (var UpdateURL in UpdateURLs)
|
foreach (var UpdateURL in UpdateURLs)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -73,9 +90,10 @@ public class DDNSService : IDDNSService
|
|||||||
request.AddParameter("text/plain", body, ParameterType.RequestBody);
|
request.AddParameter("text/plain", body, ParameterType.RequestBody);
|
||||||
|
|
||||||
var response = await client.ExecuteAsync(request);
|
var response = await client.ExecuteAsync(request);
|
||||||
|
|
||||||
_logger.LogInformation("Requesting Update on Ionos.");
|
_logger.LogInformation("Requesting Update on Ionos.");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (ApiException e)
|
||||||
{
|
{
|
||||||
_logger.LogError(e.Message);
|
_logger.LogError(e.Message);
|
||||||
throw;
|
throw;
|
||||||
@ -117,43 +135,37 @@ public class DDNSService : IDDNSService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach (var domainList in domainDict)
|
foreach (var (key, value) in domainDict)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var dyndns = new DynamicDns()
|
var request = new DynDnsRequest();
|
||||||
|
request.Domains = value;
|
||||||
|
request.Description = "My DynamicDns";
|
||||||
|
|
||||||
|
var reply = await _client.V1.Dyndns.PostAsync(request, configuration =>
|
||||||
{
|
{
|
||||||
Domains = domainList.Value,
|
configuration.Headers = new RequestHeaders()
|
||||||
Description = "My DynamicDns"
|
{
|
||||||
};
|
{ "X-API-Key", key }
|
||||||
var content = JsonConvert.SerializeObject(dyndns);
|
};
|
||||||
var client = new RestClient("https://api.hosting.ionos.com/dns/v1");
|
});
|
||||||
var request = new RestRequest("/dyndns", Method.Post);
|
updateURLs.Add(reply.UpdateUrl);
|
||||||
|
|
||||||
|
|
||||||
request.AddHeader("X-API-Key", domainList.Key);
|
|
||||||
|
|
||||||
request.AddStringBody(content, ContentType.Json);
|
|
||||||
|
|
||||||
var response = client.ExecutePost<DynamicDnsResponse>(request);
|
|
||||||
|
|
||||||
if (response.StatusCode == HttpStatusCode.Forbidden)
|
|
||||||
{
|
|
||||||
_logger.LogError($"Could not Fetch UpdateURL for {domainList.Key}");
|
|
||||||
Environment.Exit(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
_logger.LogDebug(response.Data.UpdateUrl);
|
|
||||||
updateURLs.Add(response.Data.UpdateUrl);
|
|
||||||
}
|
}
|
||||||
catch (Exception error)
|
catch (ApiException error)
|
||||||
{
|
{
|
||||||
_logger.LogError(error.Message);
|
string message = error.Message;
|
||||||
|
_logger.LogError(message);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return updateURLs;
|
return updateURLs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,34 +5,44 @@ using Microsoft.Extensions.Configuration;
|
|||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace DDNSUpdater.Services;
|
namespace DDNSUpdater.Services
|
||||||
|
|
||||||
public class TimerService : ITimerService
|
|
||||||
{
|
{
|
||||||
private Timer timer;
|
public class TimerService : ITimerService
|
||||||
private readonly ILogger<TimerService> _logger;
|
|
||||||
private readonly IServiceScopeFactory _factory;
|
|
||||||
private readonly int intervalMinutes;
|
|
||||||
|
|
||||||
public TimerService(ILogger<TimerService> logger,IServiceScopeFactory factory, IConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
_logger = logger;
|
private Timer timer;
|
||||||
_factory = factory;
|
private readonly ILogger<TimerService> _logger;
|
||||||
intervalMinutes = configuration.GetValue<int>("TimerIntervalMinutes");
|
private readonly IServiceScopeFactory _factory;
|
||||||
timer = new Timer(TimerCallback, null, TimeSpan.Zero, TimeSpan.FromMinutes(intervalMinutes));
|
private readonly int intervalMinutes;
|
||||||
}
|
|
||||||
|
|
||||||
private async void TimerCallback(Object o)
|
public TimerService(ILogger<TimerService> logger, IServiceScopeFactory factory, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
_logger.LogDebug("Timer callback executed at " + DateTime.Now);
|
_logger = logger;
|
||||||
await using var asyncScope = _factory.CreateAsyncScope();
|
_factory = factory;
|
||||||
var ddnsService = asyncScope.ServiceProvider.GetRequiredService<DDNSService>();
|
|
||||||
|
|
||||||
ddnsService.Update();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Start()
|
// Read the interval time for the timer from the appsettings.json file
|
||||||
{
|
intervalMinutes = configuration.GetValue<int>("TimerIntervalMinutes");
|
||||||
_logger.LogInformation("Timer service started.");
|
|
||||||
|
// Create a new Timer object that executes the TimerCallback method at intervals specified by intervalMinutes
|
||||||
|
timer = new Timer(TimerCallback, null, TimeSpan.Zero, TimeSpan.FromMinutes(intervalMinutes));
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method is called each time the timer ticks
|
||||||
|
private async void TimerCallback(object o)
|
||||||
|
{
|
||||||
|
_logger.LogDebug("Timer callback executed at " + DateTime.Now);
|
||||||
|
|
||||||
|
// Create a new service scope using the IServiceScopeFactory
|
||||||
|
await using var asyncScope = _factory.CreateAsyncScope();
|
||||||
|
|
||||||
|
// Retrieve an instance of the DDNSService from the service scope and call its Update method to perform the DDNS update
|
||||||
|
var ddnsService = asyncScope.ServiceProvider.GetRequiredService<DDNSService>();
|
||||||
|
ddnsService.Update();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method is called after the timer is initialized
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_logger.LogInformation("Timer service started.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
Tests/Tests.csproj
Normal file
21
Tests/Tests.csproj
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
|
||||||
|
<IsPackable>false</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Kiota.Abstractions" Version="1.1.0" />
|
||||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
|
||||||
|
<PackageReference Include="NUnit" Version="3.13.3" />
|
||||||
|
<PackageReference Include="NUnit3TestAdapter" Version="4.3.0" />
|
||||||
|
<PackageReference Include="NUnit.Analyzers" Version="3.5.0" />
|
||||||
|
<PackageReference Include="coverlet.collector" Version="3.1.2" />
|
||||||
|
<PackageReference Include="RestSharp" Version="109.0.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
15
Tests/UnitTest1.cs
Normal file
15
Tests/UnitTest1.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
namespace Tests;
|
||||||
|
|
||||||
|
public class Tests
|
||||||
|
{
|
||||||
|
[SetUp]
|
||||||
|
public void Setup()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Test1()
|
||||||
|
{
|
||||||
|
Assert.Pass();
|
||||||
|
}
|
||||||
|
}
|
||||||
1
Tests/Usings.cs
Normal file
1
Tests/Usings.cs
Normal file
@ -0,0 +1 @@
|
|||||||
|
global using NUnit.Framework;
|
||||||
Loading…
x
Reference in New Issue
Block a user