Cloud Code Admin SDKs Release

We are excited to announce the release of version 0.0.12 of our Cloud Code Apis NuGet package. This update introduces Admin capabilities for various services, including:

  • Cloud Save Data
  • Cloud Save Files
  • Leaderboards
  • Triggers
  • Scheduler

For existing users, we recommend updating the NuGet package used by your modules to the latest version (0.0.12). Notably, this release empowers developers with enhanced admin capabilities, for example, allowing them to create and manage leaderboards seamlessly from their C# modules.

Here is an example of how you would create a leaderboard using this admin functionality:

Add the AdminApiClient to your DI setup

public class ModuleConfig : ICloudCodeSetup
{
    public void Setup(ICloudCodeConfig config)
    {
        config.Dependencies.AddSingleton(AdminApiClient.Create());
    }
}

Import the Leaderboards Admin Model

using Unity.Services.Leaderboards.Admin.Model;

Create a Cloud Code function with the functionality

[CloudCodeFunction("CreateLeaderboard")]
public void CreateLeaderboard(
    IExecutionContext context,
    IAdminApiClient adminApiClient
)
{
    adminApiClient.Leaderboards.CreateLeaderboardAsync(
        executionContext: context,
        serviceAccountKey: "YOUR_SERVICE_ACCOUNT_KEY",
        serviceAccountSecret: "YOUR_SERVICE_ACCOUNT_SECRET",
        projectId: Guid.Parse(context.ProjectId),
        environmentId: Guid.Parse(context.EnvironmentId),
        leaderboardIdConfig: new LeaderboardIdConfig(
            id: "new-leaderboard",
            name: "new-leaderboard",
            sortOrder: SortOrder.Asc,
            updateType: UpdateType.KeepBest
        )
    );
}

We will follow up with documentation soon. We are also working on secret management functionality which would take care of your service account credential handling.

If you have any feedback let us know in the comments.

4 Likes

Documentation is now available here!

3 Likes