Skip to content

Commit

Permalink
api fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm360 committed Oct 11, 2024
1 parent 4cd1d7e commit 51fb1b6
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 deletions.
9 changes: 4 additions & 5 deletions src/BeeNet.Client/BeeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,12 @@ public Task CreatePinAsync(
generatedClient.PinsPostAsync((string)hash, cancellationToken);

public async Task<TagInfo> CreateTagAsync(
SwarmHash hash,
PostageBatchId postageBatchId,
CancellationToken cancellationToken = default)
{
var response = await generatedClient.TagsPostAsync(
new Body3 { Address = hash.ToString() },
postageBatchId.ToString(),
cancellationToken).ConfigureAwait(false);
return new TagInfo(
Expand Down Expand Up @@ -1128,10 +1130,7 @@ public Task SetWelcomeMessageAsync(
string welcomeMessage,
CancellationToken cancellationToken = default) =>
generatedClient.WelcomeMessagePostAsync(
new Body4
{
WelcomeMessage = welcomeMessage
},
new Body5 { WelcomeMessage = welcomeMessage },
cancellationToken);

public async Task StakeDeleteAsync(
Expand Down Expand Up @@ -1302,7 +1301,7 @@ public Task UpdateTagAsync(
generatedClient.TagsPatchAsync(
id.Value,
hash.HasValue ?
new Body3 { Address = hash.Value.ToString() } :
new Body4 { Address = hash.Value.ToString() } :
null,
cancellationToken);

Expand Down
41 changes: 33 additions & 8 deletions src/BeeNet.Client/Clients/BeeGeneratedClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ internal partial interface IBeeGeneratedClient
/// <param name="swarm_postage_batch_id">ID of Postage Batch that is used to upload data with</param>
/// <returns>New Tag Info</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<Response7> TagsPostAsync(string? swarm_postage_batch_id = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<Response7> TagsPostAsync(Body3 body, string? swarm_postage_batch_id = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>
Expand Down Expand Up @@ -257,7 +257,7 @@ internal partial interface IBeeGeneratedClient
/// <param name="body">Can contain swarm hash to use for the tag</param>
/// <returns>Ok</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<Response9> TagsPatchAsync(ulong uid, Body3? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<Response9> TagsPatchAsync(ulong uid, Body4? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>
Expand Down Expand Up @@ -619,7 +619,7 @@ internal partial interface IBeeGeneratedClient
/// </summary>
/// <returns>OK</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
System.Threading.Tasks.Task<Response41> WelcomeMessagePostAsync(Body4? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));
System.Threading.Tasks.Task<Response41> WelcomeMessagePostAsync(Body5? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken));

/// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param>
/// <summary>
Expand Down Expand Up @@ -2645,8 +2645,11 @@ public string BaseUrl
/// <param name="swarm_postage_batch_id">ID of Postage Batch that is used to upload data with</param>
/// <returns>New Tag Info</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<Response7> TagsPostAsync(string? swarm_postage_batch_id = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
public virtual async System.Threading.Tasks.Task<Response7> TagsPostAsync(Body3 body, string? swarm_postage_batch_id = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (body == null)
throw new System.ArgumentNullException("body");

var client_ = _httpClient;
var disposeClient_ = false;
try
Expand All @@ -2656,7 +2659,10 @@ public string BaseUrl

if (swarm_postage_batch_id != null)
request_.Headers.TryAddWithoutValidation("swarm-postage-batch-id", ConvertToString(swarm_postage_batch_id, System.Globalization.CultureInfo.InvariantCulture));
request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json");
var json_ = System.Text.Json.JsonSerializer.SerializeToUtf8Bytes(body, JsonSerializerSettings);
var content_ = new System.Net.Http.ByteArrayContent(json_);
content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json");
request_.Content = content_;
request_.Method = new System.Net.Http.HttpMethod("POST");
request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json"));

Expand Down Expand Up @@ -2947,7 +2953,7 @@ public string BaseUrl
/// <param name="body">Can contain swarm hash to use for the tag</param>
/// <returns>Ok</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<Response9> TagsPatchAsync(ulong uid, Body3? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
public virtual async System.Threading.Tasks.Task<Response9> TagsPatchAsync(ulong uid, Body4? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
if (uid == null)
throw new System.ArgumentNullException("uid");
Expand Down Expand Up @@ -6629,7 +6635,7 @@ public string BaseUrl
/// </summary>
/// <returns>OK</returns>
/// <exception cref="BeeNetApiException">A server side error occurred.</exception>
public virtual async System.Threading.Tasks.Task<Response41> WelcomeMessagePostAsync(Body4? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
public virtual async System.Threading.Tasks.Task<Response41> WelcomeMessagePostAsync(Body5? body = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken))
{
var client_ = _httpClient;
var disposeClient_ = false;
Expand Down Expand Up @@ -10159,6 +10165,25 @@ public System.Collections.Generic.IDictionary<string, object> AdditionalProperti

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
internal partial class Body4
{

[System.Text.Json.Serialization.JsonPropertyName("address")]
[System.ComponentModel.DataAnnotations.RegularExpression(@"^[A-Fa-f0-9]{64}$")]
public string Address { get; set; } = default!;

private System.Collections.Generic.IDictionary<string, object>? _additionalProperties;

[System.Text.Json.Serialization.JsonExtensionData]
public System.Collections.Generic.IDictionary<string, object> AdditionalProperties
{
get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary<string, object>()); }
set { _additionalProperties = value; }
}

}

[System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.1.0.0 (NJsonSchema v11.0.2.0 (Newtonsoft.Json v13.0.0.0))")]
internal partial class Body5
{

[System.Text.Json.Serialization.JsonPropertyName("welcomeMessage")]
Expand Down Expand Up @@ -10524,7 +10549,7 @@ internal partial class Response14
{

[System.Text.Json.Serialization.JsonPropertyName("references")]
public System.Collections.Generic.ICollection<string> References { get; set; } = default!;
public System.Collections.Generic.ICollection<string>? References { get; set; } = default!;

private System.Collections.Generic.IDictionary<string, object>? _additionalProperties;

Expand Down
1 change: 1 addition & 0 deletions src/BeeNet.Util/IBeeClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Task CreatePinAsync(
/// <returns>New Tag Info</returns>
/// <exception cref="BeeNetGatewayApiException">A server side error occurred.</exception>
Task<TagInfo> CreateTagAsync(
SwarmHash hash,
PostageBatchId postageBatchId,
CancellationToken cancellationToken = default);

Expand Down
13 changes: 12 additions & 1 deletion tools/GatewaySwarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -865,6 +865,17 @@ paths:
`Swarm-Deferred-Upload` header.
parameters:
- *a5
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
address:
type: string
pattern: ^[A-Fa-f0-9]{64}$
example: 36b7efd913ca4cf880b8eeac5093fa27b0825906c600685b6abdd6566e6cfe8f
responses:
"201":
description: New Tag Info
Expand Down Expand Up @@ -1095,7 +1106,7 @@ paths:
properties:
references:
type: array
nullable: false
nullable: true
items:
oneOf:
- type: string
Expand Down
12 changes: 12 additions & 0 deletions tools/openapi/Swarm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,12 @@ paths:
description: Tags can be thought of as upload sessions which can be tracked using the tags endpoint. It will keep track of the chunks that are uploaded as part of the tag and will push them out to the network once a done split is called on the Tag. This happens internally if you use the `Swarm-Deferred-Upload` header.
parameters:
- $ref: "SwarmCommon.yaml#/components/parameters/SwarmPostageBatchId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "SwarmCommon.yaml#/components/schemas/NewTagRequest"
responses:
"201":
description: New Tag Info
Expand Down Expand Up @@ -1268,6 +1274,12 @@ paths:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmReference"
required: true
description: Swarm address of chunk
- in: query
name: rootHash
schema:
$ref: "SwarmCommon.yaml#/components/schemas/SwarmReference"
required: false
description: Optional root hash to route the request
- in: header
schema:
$ref: "SwarmCommon.yaml#/components/parameters/SwarmCache"
Expand Down
2 changes: 1 addition & 1 deletion tools/openapi/SwarmCommon.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ components:
properties:
references:
type: array
nullable: false
nullable: true
items:
$ref: "#/components/schemas/SwarmOnlyReference"

Expand Down

0 comments on commit 51fb1b6

Please sign in to comment.