Skip to content

Commit

Permalink
[RELEASE] 2.0.10
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Aug 14, 2024
1 parent 6527932 commit 8bb0b83
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 2 deletions.
2 changes: 1 addition & 1 deletion automation-api-clients/typescript-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"form-data": "^4.0.0",
"node-fetch": "^3.3.1"
},
"version": "2.0.9"
"version": "2.0.10"
}
34 changes: 34 additions & 0 deletions player-api-clients/csharp/spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -1648,6 +1648,40 @@
"beam-api-key": []
}
]
},
"delete": {
"operationId": "unlinkUser",
"summary": "Unlinks an entity ID from a user",
"parameters": [
{
"name": "entityId",
"required": true,
"in": "path",
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PlayerGetUserResponse"
}
}
}
}
},
"tags": [
"Users"
],
"security": [
{
"beam-api-key": []
}
]
}
},
"/v1/player/operation/{opId}": {
Expand Down
282 changes: 282 additions & 0 deletions player-api-clients/csharp/src/BeamPlayerClient/Api/UsersApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,29 @@ public interface IPlayerUsersApi : IPlayerApi
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IGetUserApiResponse"/>?&gt;</returns>
Task<IGetUserApiResponse?> GetUserOrDefaultAsync(string entityId, System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Unlinks an entity ID from a user
/// </summary>
/// <remarks>
///
/// </remarks>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="entityId"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IUnlinkUserApiResponse"/>&gt;</returns>
Task<IUnlinkUserApiResponse> UnlinkUserAsync(string entityId, System.Threading.CancellationToken cancellationToken = default);

/// <summary>
/// Unlinks an entity ID from a user
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="entityId"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IUnlinkUserApiResponse"/>?&gt;</returns>
Task<IUnlinkUserApiResponse?> UnlinkUserOrDefaultAsync(string entityId, System.Threading.CancellationToken cancellationToken = default);
}

/// <summary>
Expand All @@ -108,6 +131,18 @@ public interface IGetUserApiResponse : BeamPlayerClient.Client.IApiResponse, IOk
bool IsOk { get; }
}

/// <summary>
/// The <see cref="IUnlinkUserApiResponse"/>
/// </summary>
public interface IUnlinkUserApiResponse : BeamPlayerClient.Client.IApiResponse, IOk<BeamPlayerClient.Model.PlayerGetUserResponse?>
{
/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
bool IsOk { get; }
}

/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
Expand Down Expand Up @@ -152,6 +187,26 @@ internal void ExecuteOnErrorGetUser(Exception exception)
{
OnErrorGetUser?.Invoke(this, new ExceptionEventArgs(exception));
}

/// <summary>
/// The event raised after the server response
/// </summary>
public event EventHandler<ApiResponseEventArgs>? OnUnlinkUser;

/// <summary>
/// The event raised after an error querying the server
/// </summary>
public event EventHandler<ExceptionEventArgs>? OnErrorUnlinkUser;

internal void ExecuteOnUnlinkUser(PlayerUsersApi.UnlinkUserApiResponse apiResponse)
{
OnUnlinkUser?.Invoke(this, new ApiResponseEventArgs(apiResponse));
}

internal void ExecuteOnErrorUnlinkUser(Exception exception)
{
OnErrorUnlinkUser?.Invoke(this, new ExceptionEventArgs(exception));
}
}

/// <summary>
Expand Down Expand Up @@ -656,5 +711,232 @@ private void OnDeserializationErrorDefaultImplementation(Exception exception, Ht

partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}

partial void FormatUnlinkUser(ref string entityId);

/// <summary>
/// Validates the request parameters
/// </summary>
/// <param name="entityId"></param>
/// <returns></returns>
private void ValidateUnlinkUser(string entityId)
{
if (entityId == null)
throw new ArgumentNullException(nameof(entityId));
}

/// <summary>
/// Processes the server response
/// </summary>
/// <param name="apiResponseLocalVar"></param>
/// <param name="entityId"></param>
private void AfterUnlinkUserDefaultImplementation(IUnlinkUserApiResponse apiResponseLocalVar, string entityId)
{
bool suppressDefaultLog = false;
AfterUnlinkUser(ref suppressDefaultLog, apiResponseLocalVar, entityId);
if (!suppressDefaultLog)
Logger.LogInformation("{0,-9} | {1} | {3}", (apiResponseLocalVar.DownloadedAt - apiResponseLocalVar.RequestedAt).TotalSeconds, apiResponseLocalVar.StatusCode, apiResponseLocalVar.Path);
}

/// <summary>
/// Processes the server response
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="apiResponseLocalVar"></param>
/// <param name="entityId"></param>
partial void AfterUnlinkUser(ref bool suppressDefaultLog, IUnlinkUserApiResponse apiResponseLocalVar, string entityId);

/// <summary>
/// Logs exceptions that occur while retrieving the server response
/// </summary>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
/// <param name="entityId"></param>
private void OnErrorUnlinkUserDefaultImplementation(Exception exception, string pathFormat, string path, string entityId)
{
bool suppressDefaultLog = false;
OnErrorUnlinkUser(ref suppressDefaultLog, exception, pathFormat, path, entityId);
if (!suppressDefaultLog)
Logger.LogError(exception, "An error occurred while sending the request to the server.");
}

/// <summary>
/// A partial method that gives developers a way to provide customized exception handling
/// </summary>
/// <param name="suppressDefaultLog"></param>
/// <param name="exception"></param>
/// <param name="pathFormat"></param>
/// <param name="path"></param>
/// <param name="entityId"></param>
partial void OnErrorUnlinkUser(ref bool suppressDefaultLog, Exception exception, string pathFormat, string path, string entityId);

/// <summary>
/// Unlinks an entity ID from a user
/// </summary>
/// <param name="entityId"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IUnlinkUserApiResponse"/>&gt;</returns>
public async Task<IUnlinkUserApiResponse?> UnlinkUserOrDefaultAsync(string entityId, System.Threading.CancellationToken cancellationToken = default)
{
try
{
return await UnlinkUserAsync(entityId, cancellationToken).ConfigureAwait(false);
}
catch (Exception)
{
return null;
}
}

/// <summary>
/// Unlinks an entity ID from a user
/// </summary>
/// <exception cref="ApiException">Thrown when fails to make API call</exception>
/// <param name="entityId"></param>
/// <param name="cancellationToken">Cancellation Token to cancel the request.</param>
/// <returns><see cref="Task"/>&lt;<see cref="IUnlinkUserApiResponse"/>&gt;</returns>
public async Task<IUnlinkUserApiResponse> UnlinkUserAsync(string entityId, System.Threading.CancellationToken cancellationToken = default)
{
UriBuilder uriBuilderLocalVar = new UriBuilder();

try
{
ValidateUnlinkUser(entityId);

FormatUnlinkUser(ref entityId);

using (HttpRequestMessage httpRequestMessageLocalVar = new HttpRequestMessage())
{
uriBuilderLocalVar.Host = HttpClient.BaseAddress!.Host;
uriBuilderLocalVar.Port = HttpClient.BaseAddress.Port;
uriBuilderLocalVar.Scheme = HttpClient.BaseAddress.Scheme;
uriBuilderLocalVar.Path = ClientUtils.CONTEXT_PATH + "/v1/player/users/{entityId}";
uriBuilderLocalVar.Path = uriBuilderLocalVar.Path.Replace("%7BentityId%7D", Uri.EscapeDataString(entityId.ToString()));

List<TokenBase> tokenBaseLocalVars = new List<TokenBase>();
PlayerApiKeyToken apiKeyTokenLocalVar1 = (PlayerApiKeyToken) await ApiKeyProvider.GetAsync("x-api-key", cancellationToken).ConfigureAwait(false);
tokenBaseLocalVars.Add(apiKeyTokenLocalVar1);
apiKeyTokenLocalVar1.UseInHeader(httpRequestMessageLocalVar);

httpRequestMessageLocalVar.RequestUri = uriBuilderLocalVar.Uri;

string[] acceptLocalVars = new string[] {
"application/json"
};

string? acceptLocalVar = ClientUtils.SelectHeaderAccept(acceptLocalVars);

if (acceptLocalVar != null)
httpRequestMessageLocalVar.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue(acceptLocalVar));

httpRequestMessageLocalVar.Method = HttpMethod.Delete;

DateTime requestedAtLocalVar = DateTime.UtcNow;

using (HttpResponseMessage httpResponseMessageLocalVar = await HttpClient.SendAsync(httpRequestMessageLocalVar, cancellationToken).ConfigureAwait(false))
{
string responseContentLocalVar = await httpResponseMessageLocalVar.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false);

ILogger<UnlinkUserApiResponse> apiResponseLoggerLocalVar = LoggerFactory.CreateLogger<UnlinkUserApiResponse>();

UnlinkUserApiResponse apiResponseLocalVar = new(apiResponseLoggerLocalVar, httpRequestMessageLocalVar, httpResponseMessageLocalVar, responseContentLocalVar, "/v1/player/users/{entityId}", requestedAtLocalVar, _jsonSerializerOptions);

AfterUnlinkUserDefaultImplementation(apiResponseLocalVar, entityId);

Events.ExecuteOnUnlinkUser(apiResponseLocalVar);

if (apiResponseLocalVar.StatusCode == (HttpStatusCode) 429)
foreach(TokenBase tokenBaseLocalVar in tokenBaseLocalVars)
tokenBaseLocalVar.BeginRateLimit();

return apiResponseLocalVar;
}
}
}
catch(Exception e)
{
OnErrorUnlinkUserDefaultImplementation(e, "/v1/player/users/{entityId}", uriBuilderLocalVar.Path, entityId);
Events.ExecuteOnErrorUnlinkUser(e);
throw;
}
}

/// <summary>
/// The <see cref="UnlinkUserApiResponse"/>
/// </summary>
public partial class UnlinkUserApiResponse : BeamPlayerClient.Client.ApiResponse, IUnlinkUserApiResponse
{
/// <summary>
/// The logger
/// </summary>
public ILogger<UnlinkUserApiResponse> Logger { get; }

/// <summary>
/// The <see cref="UnlinkUserApiResponse"/>
/// </summary>
/// <param name="logger"></param>
/// <param name="httpRequestMessage"></param>
/// <param name="httpResponseMessage"></param>
/// <param name="rawContent"></param>
/// <param name="path"></param>
/// <param name="requestedAt"></param>
/// <param name="jsonSerializerOptions"></param>
public UnlinkUserApiResponse(ILogger<UnlinkUserApiResponse> logger, System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage, string rawContent, string path, DateTime requestedAt, System.Text.Json.JsonSerializerOptions jsonSerializerOptions) : base(httpRequestMessage, httpResponseMessage, rawContent, path, requestedAt, jsonSerializerOptions)
{
Logger = logger;
OnCreated(httpRequestMessage, httpResponseMessage);
}

partial void OnCreated(System.Net.Http.HttpRequestMessage httpRequestMessage, System.Net.Http.HttpResponseMessage httpResponseMessage);

/// <summary>
/// Returns true if the response is 200 Ok
/// </summary>
/// <returns></returns>
public bool IsOk => 200 == (int)StatusCode;

/// <summary>
/// Deserializes the response if the response is 200 Ok
/// </summary>
/// <returns></returns>
public BeamPlayerClient.Model.PlayerGetUserResponse? Ok()
{
// This logic may be modified with the AsModel.mustache template
return IsOk
? System.Text.Json.JsonSerializer.Deserialize<BeamPlayerClient.Model.PlayerGetUserResponse>(RawContent, _jsonSerializerOptions)
: null;
}

/// <summary>
/// Returns true if the response is 200 Ok and the deserialized response is not null
/// </summary>
/// <param name="result"></param>
/// <returns></returns>
public bool TryOk([NotNullWhen(true)]out BeamPlayerClient.Model.PlayerGetUserResponse? result)
{
result = null;

try
{
result = Ok();
} catch (Exception e)
{
OnDeserializationErrorDefaultImplementation(e, (HttpStatusCode)200);
}

return result != null;
}

private void OnDeserializationErrorDefaultImplementation(Exception exception, HttpStatusCode httpStatusCode)
{
bool suppressDefaultLog = false;
OnDeserializationError(ref suppressDefaultLog, exception, httpStatusCode);
if (!suppressDefaultLog)
Logger.LogError(exception, "An error occurred while deserializing the {code} response.", httpStatusCode);
}

partial void OnDeserializationError(ref bool suppressDefaultLog, Exception exception, HttpStatusCode httpStatusCode);
}
}
}
2 changes: 1 addition & 1 deletion player-api-clients/typescript-node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
"form-data": "^4.0.0",
"node-fetch": "^3.3.1"
},
"version": "2.0.9"
"version": "2.0.10"
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@ export class UsersService {
},
});
}

/**
* Unlinks an entity ID from a user
* @param entityId
* @returns GetUserResponse
* @throws ApiError
*/
public unlinkUser(entityId: string): CancelablePromise<GetUserResponse> {
return this.httpRequest.request({
method: 'DELETE',
url: '/v1/player/users/{entityId}',
path: {
entityId: entityId,
},
});
}
}

0 comments on commit 8bb0b83

Please sign in to comment.