Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up code7 #736

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions Client/Api/Builder/IAccessTokenSupplier.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
using Google.Apis.Auth.OAuth2;

namespace Zeebe.Client.Api.Builder
{
/// <summary>
/// Supplies access tokens to communicate with the gateway.
/// </summary>
public interface IAccessTokenSupplier : ITokenAccess
{
}
}
namespace Zeebe.Client.Api.Builder;

/// <summary>
/// Supplies access tokens to communicate with the gateway.
/// </summary>
public interface IAccessTokenSupplier : ITokenAccess;
157 changes: 78 additions & 79 deletions Client/Api/Builder/ICamundaCloudClientBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,92 +1,91 @@
using Microsoft.Extensions.Logging;

namespace Zeebe.Client.Api.Builder
namespace Zeebe.Client.Api.Builder;

/// <summary>
/// Simplifies the setup of an IZeebeClient which targets Camunda Cloud.
/// </summary>
public interface ICamundaCloudClientBuilder
{
/// <summary>
/// Simplifies the setup of an IZeebeClient which targets Camunda Cloud.
/// Defines the client id, which should be used to communicate with the Camunda Cloud cluster.
///
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client id there.
/// </summary>
public interface ICamundaCloudClientBuilder
{
/// <summary>
/// Defines the client id, which should be used to communicate with the Camunda Cloud cluster.
///
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client id there.
/// </summary>
/// <param name="clientId">the client id, which is supplied by the Camunda Cloud</param>
/// <returns>the next step in building a ICamundaCloudClient</returns>
ICamundaCloudClientBuilderStep1 UseClientId(string clientId);
/// <param name="clientId">the client id, which is supplied by the Camunda Cloud.</param>
/// <returns>the next step in building a ICamundaCloudClient.</returns>
ICamundaCloudClientBuilderStep1 UseClientId(string clientId);

/// <summary>
/// Short cut operation.
/// Reads from the environment all necessary information, to communicate with the camunda cloud cluster.
///
/// Following environment variables are expected:
/// <list type="bullet">
/// <item>ZEEBE_ADDRESS</item>
/// <item>ZEEBE_CLIENT_ID</item>
/// <item>ZEEBE_CLIENT_SECRET</item>
/// </list>
///
/// Optional the authorization server url can be set via: ZEEBE_AUTHORIZATION_SERVER_URL
/// </summary>
/// <returns>the final ICamundaCloudClientBuilder step</returns>
ICamundaCloudClientBuilderFinalStep FromEnv();
}
/// <summary>
/// Short cut operation.
/// Reads from the environment all necessary information, to communicate with the camunda cloud cluster.
///
/// Following environment variables are expected:
/// <list type="bullet">
/// <item>ZEEBE_ADDRESS</item>
/// <item>ZEEBE_CLIENT_ID</item>
/// <item>ZEEBE_CLIENT_SECRET</item>
/// </list>
///
/// Optional the authorization server url can be set via: ZEEBE_AUTHORIZATION_SERVER_URL.
/// </summary>
/// <returns>the final ICamundaCloudClientBuilder step.</returns>
ICamundaCloudClientBuilderFinalStep FromEnv();
}

public interface ICamundaCloudClientBuilderStep1
{
/// <summary>
/// Defines the client secret, which should be used to communicate with the Camunda Cloud cluster.
///
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client secret there.
/// </summary>
/// <param name="clientSecret">the client secret, which is supplied by the Camunda Cloud</param>
/// <returns>the next step in building a ICamundaCloudClient</returns>
ICamundaCloudClientBuilderStep2 UseClientSecret(string clientSecret);
}
public interface ICamundaCloudClientBuilderStep1
{
/// <summary>
/// Defines the client secret, which should be used to communicate with the Camunda Cloud cluster.
///
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client secret there.
/// </summary>
/// <param name="clientSecret">the client secret, which is supplied by the Camunda Cloud.</param>
/// <returns>the next step in building a ICamundaCloudClient.</returns>
ICamundaCloudClientBuilderStep2 UseClientSecret(string clientSecret);
}

public interface ICamundaCloudClientBuilderStep2
{
/// <summary>
/// The Camunda Cloud Cluster contact point, which should be used to communicate with.
/// It is equal to the 'ZEEBE_ADDRESS' which you get from the Camunda Cloud Credentials.
/// This will be used internally as OAuth audience as well.
/// </summary>
/// <param name="contactPoint">the audience, which is normally a domain name</param>
/// <returns>the next step in building a ICamundaCloudClient</returns>
ICamundaCloudClientBuilderFinalStep UseContactPoint(string contactPoint);
}
public interface ICamundaCloudClientBuilderStep2
{
/// <summary>
/// The Camunda Cloud Cluster contact point, which should be used to communicate with.
/// It is equal to the 'ZEEBE_ADDRESS' which you get from the Camunda Cloud Credentials.
/// This will be used internally as OAuth audience as well.
/// </summary>
/// <param name="contactPoint">the audience, which is normally a domain name.</param>
/// <returns>the next step in building a ICamundaCloudClient.</returns>
ICamundaCloudClientBuilderFinalStep UseContactPoint(string contactPoint);
}

public interface ICamundaCloudClientBuilderFinalStep
{
/// <summary>
/// Defines the logger factory which should be used by the client.
/// *This is optional and no messages are logged if this method is not called.*
/// </summary>
/// <param name="loggerFactory">the factory to create an ILogger</param>
/// <returns>the fluent ICamundaCloudClientBuilderFinalStep</returns>
ICamundaCloudClientBuilderFinalStep UseLoggerFactory(ILoggerFactory loggerFactory);
public interface ICamundaCloudClientBuilderFinalStep
{
/// <summary>
/// Defines the logger factory which should be used by the client.
/// *This is optional and no messages are logged if this method is not called.*.
/// </summary>
/// <param name="loggerFactory">the factory to create an ILogger.</param>
/// <returns>the fluent ICamundaCloudClientBuilderFinalStep.</returns>
ICamundaCloudClientBuilderFinalStep UseLoggerFactory(ILoggerFactory loggerFactory);

/// <summary>
/// Defines the authorization server, from which the access token should be requested.
/// </summary>
/// <param name="url">an url, which points to the authorization server, if null it uses the default https://login.cloud.camunda.io/oauth/token.</param>
/// <returns>the next step in building a ICamundaCloudClient</returns>
ICamundaCloudClientBuilderFinalStep UseAuthServer(string url);
/// <summary>
/// Defines the authorization server, from which the access token should be requested.
/// </summary>
/// <param name="url">an url, which points to the authorization server, if null it uses the default https://login.cloud.camunda.io/oauth/token.</param>
/// <returns>the next step in building a ICamundaCloudClient.</returns>
ICamundaCloudClientBuilderFinalStep UseAuthServer(string url);

/// <summary>
/// Sets the given path to store credentials on disk.
/// </summary>
/// <param name="path">the path where to store the credentials, if null it uses the default "~/.zeebe" .</param>
/// <returns>the fluent ICamundaCloudClientBuilderFinalStep.</returns>
ICamundaCloudClientBuilderFinalStep UsePersistedStoragePath(string path);
/// <summary>
/// Sets the given path to store credentials on disk.
/// </summary>
/// <param name="path">the path where to store the credentials, if null it uses the default "~/.zeebe" .</param>
/// <returns>the fluent ICamundaCloudClientBuilderFinalStep.</returns>
ICamundaCloudClientBuilderFinalStep UsePersistedStoragePath(string path);

/// <summary>
/// The IZeebeClient, which is setup entirely to talk with the defined Camunda Cloud cluster.
/// </summary>
/// <returns>the IZeebeClient</returns>
IZeebeClient Build();
}
/// <summary>
/// The IZeebeClient, which is setup entirely to talk with the defined Camunda Cloud cluster.
/// </summary>
/// <returns>the IZeebeClient.</returns>
IZeebeClient Build();
}
130 changes: 64 additions & 66 deletions Client/Api/Builder/ICamundaCloudTokenProviderBuilder.cs
Original file line number Diff line number Diff line change
@@ -1,77 +1,75 @@
using Microsoft.Extensions.Logging;
using Zeebe.Client.Impl.Builder;

namespace Zeebe.Client.Api.Builder
{
public interface ICamundaCloudTokenProviderBuilder
{
/// <summary>
/// Defines the logger factory which should be used by the token provider
/// to log messages.
/// *This is optional and no messages are logged if this method is not called.*
/// </summary>
/// <param name="loggerFactory">the factory to create an ILogger</param>
/// <returns>the fluent ICamundaCloudTokenProviderBuilder</returns>
ICamundaCloudTokenProviderBuilder UseLoggerFactory(ILoggerFactory loggerFactory);
namespace Zeebe.Client.Api.Builder;

/// <summary>
/// Defines the authorization server, from which the access token should be requested.
/// </summary>
/// <param name="url">an url, which points to the authorization server</param>
/// <returns>the next step in building a CamundaCloudTokenProvider</returns>
ICamundaCloudTokenProviderBuilderStep2 UseAuthServer(string url);
}
public interface ICamundaCloudTokenProviderBuilder
{
/// <summary>
/// Defines the logger factory which should be used by the token provider
/// to log messages.
/// *This is optional and no messages are logged if this method is not called.*.
/// </summary>
/// <param name="loggerFactory">the factory to create an ILogger.</param>
/// <returns>the fluent ICamundaCloudTokenProviderBuilder.</returns>
ICamundaCloudTokenProviderBuilder UseLoggerFactory(ILoggerFactory loggerFactory);

public interface ICamundaCloudTokenProviderBuilderStep2
{
/// <summary>
/// Defines the client id, which should be used to create the access token.
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client id there.
/// </summary>
/// <param name="clientId">the client id, which is supplied by the Camunda Cloud</param>
/// <returns>the next step in building a CamundaCloudTokenProvider</returns>
ICamundaCloudTokenProviderBuilderStep3 UseClientId(string clientId);
}
/// <summary>
/// Defines the authorization server, from which the access token should be requested.
/// </summary>
/// <param name="url">an url, which points to the authorization server.</param>
/// <returns>the next step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderStep2 UseAuthServer(string url);
}

public interface ICamundaCloudTokenProviderBuilderStep3
{
/// <summary>
/// Defines the client secret, which should be used to create the access token.
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client secret there.
/// </summary>
/// <param name="clientSecret">the client secret, which is supplied by the Camunda Cloud</param>
/// <returns>the next step in building a CamundaCloudTokenProvider</returns>
ICamundaCloudTokenProviderBuilderStep4 UseClientSecret(string clientSecret);
}
public interface ICamundaCloudTokenProviderBuilderStep2
{
/// <summary>
/// Defines the client id, which should be used to create the access token.
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client id there.
/// </summary>
/// <param name="clientId">the client id, which is supplied by the Camunda Cloud.</param>
/// <returns>the next step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderStep3 UseClientId(string clientId);
}

public interface ICamundaCloudTokenProviderBuilderStep4
{
/// <summary>
/// Defines the audience for which the token provider should create tokens.
/// </summary>
/// <param name="audience">the audience, which is normally a domain name</param>
/// <returns>the next step in building a CamundaCloudTokenProvider</returns>
ICamundaCloudTokenProviderBuilderFinalStep UseAudience(string audience);
}
public interface ICamundaCloudTokenProviderBuilderStep3
{
/// <summary>
/// Defines the client secret, which should be used to create the access token.
/// You need to create a client in the Camunda Cloud, after that you can find a newly
/// generated client secret there.
/// </summary>
/// <param name="clientSecret">the client secret, which is supplied by the Camunda Cloud.</param>
/// <returns>the next step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderStep4 UseClientSecret(string clientSecret);
}

public interface ICamundaCloudTokenProviderBuilderFinalStep
{
public interface ICamundaCloudTokenProviderBuilderStep4
{
/// <summary>
/// Defines the audience for which the token provider should create tokens.
/// </summary>
/// <param name="audience">the audience, which is normally a domain name.</param>
/// <returns>the next step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderFinalStep UseAudience(string audience);
}

/// <summary>
/// Use given path to store credentials on disk.
/// </summary>
/// Per default credentials are stored in the home directory.
/// <param name="path">The path where to store the credentials.</param>
/// <returns>The final step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderFinalStep UsePath(string path);
public interface ICamundaCloudTokenProviderBuilderFinalStep
{
/// <summary>
/// Use given path to store credentials on disk.
/// </summary>
/// Per default credentials are stored in the home directory.
/// <param name="path">The path where to store the credentials.</param>
/// <returns>The final step in building a CamundaCloudTokenProvider.</returns>
ICamundaCloudTokenProviderBuilderFinalStep UsePath(string path);

/// <summary>
/// Builds the CamundaCloudTokenProvider, which can be used by the ZeebeClient to
/// communicate with the Camunda Cloud.
/// </summary>
/// <returns>the CamundaCloudTokenProvider</returns>
CamundaCloudTokenProvider Build();
}
/// <summary>
/// Builds the CamundaCloudTokenProvider, which can be used by the ZeebeClient to
/// communicate with the Camunda Cloud.
/// </summary>
/// <returns>the CamundaCloudTokenProvider.</returns>
CamundaCloudTokenProvider Build();
}
Loading
Loading