// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
// Standard Library
using System;
using System.Collections.Generic;
// GameKit
using AWS.GameKit.Common.Models;
using AWS.GameKit.Runtime.Models;
namespace AWS.GameKit.Runtime.Core
{
///
/// Interface for the AWS GameKit Core APIs.
///
public interface ICoreWrapperProvider
{
#if UNITY_EDITOR
#region GameKitAccount
///
/// Get the AWS Account ID which corresponds to the provided Access Key and Secret Key.
///
///
/// For more information about AWS access keys and secret keys, see: https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys
///
/// Struct containing an access key and secret key.
/// StringCallbackResults which contains a ChrPtr result containing the Account ID and the result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public StringCallbackResult GetAWSAccountId(GetAWSAccountIdDescription accountCredentials);
///
/// Gets (and creates if necessary) a GameKitAccount instance, which can be used to access the Core Account APIs.
///
///
/// Make sure to call AccountInstanceRelease() to destroy the returned object when finished with it.
///
/// Pointer to the new GameKitAccount instance.
public IntPtr GetAccountInstance();
///
/// Create a GameKitAccount instance, which can be used to access the GameKitAccount API.
///
///
/// Make sure to call AccountInstanceRelease() to destroy the returned object when finished with it.
///
/// Struct holding account id, game name, and deployment environment.
/// Struct holding account id, region, access key, and secret key.
/// Callback function for logging information and errors.
/// Pointer to the new GameKitAccount instance.
public IntPtr AccountInstanceCreate(AccountInfo accountInfo, AccountCredentials credentials, FuncLoggingCallback logCb);
///
/// Create a GameKitAccount instance, which can be used to access the GameKitAccount API. Also sets the plugin and game root paths.
///
///
/// Make sure to call AccountInstanceRelease() to destroy the returned object when finished with it.
///
/// Struct holding account id, game name, and deployment environment.
/// Struct holding account id, region, access key, and secret key.
/// New path for GAMEKIT_ROOT
/// New path for the plugin root directory.
/// Callback function for logging information and errors.
/// Pointer to the new GameKitAccount instance.
public IntPtr AccountInstanceCreateWithRootPaths(AccountInfo accountInfo, AccountCredentials credentials, string rootPath, string pluginRootPath, FuncLoggingCallback logCb);
///
/// Destroy the provided GameKitAccount instance.
///
public void AccountInstanceRelease();
///
/// Get the GAMEKIT_ROOT path where the "instance" templates and settings are going to be stored.
///
/// True if the credentials are valid, false otherwise.
public bool AccountHasValidCredentials();
///
/// Create a bootstrap bucket in the AWS account if it doesn't already exist.
///
///
/// The bootstrap bucket must be created before deploying any stacks or Lambda functions. There needs to be a unique bootstrap bucket for each combination of Environment, Account ID, and GameName.
///
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint AccountInstanceBootstrap();
///
/// Create or update a secret in AWS SecretsManager (https://aws.amazon.com/secrets-manager/).
///
///
/// The secret name will be "gamekit___", for example: "gamekit_dev_mygame_amazon_client_secret".
///
/// Name of the secret. Will be prefixed as described in the details.
/// Value of the secret.
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint GameKitAccountSaveSecret(string secretName, string secretValue);
///
/// Checks if a secret exists in AWS SecretsManager (https://aws.amazon.com/secrets-manager/).
///
///
/// The secret name will be "gamekit___", for example: "gamekit_dev_mygame_amazon_client_secret".
///
/// Name of the secret. Will be prefixed as described in the details.
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint GameKitAccountCheckSecretExists(string secretName);
///
/// Upload the dashboard configuration file for every feature to the bootstrap bucket.
///
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint GameKitAccountUploadAllDashboards();
#endregion
#region GameKitResources
///
/// Gets (and creates if necessary) a GameKitResources instance, which can be used to access the Core Account APIs.
///
///
/// Make sure to call ResourcesInstanceRelease() to destroy the returned object when finished with it.
///
/// Pointer to the new GameKitResources instance.
public IntPtr GetResourcesInstance();
///
/// Create a GameKitFeatureResources instance, which can be used to access the GameKitFeatureResources API.
///
///
/// Make sure to call GameKitResourcesInstanceRelease() to destroy the returned object when finished with it.
///
/// Struct holding account id, game name, and deployment environment.
/// Struct holding account id, region, access key, and secret key.
/// The GameKit feature to work with.
/// Callback function for logging information and errors.
/// Pointer to the new GameKitFeatureResources instance.
public IntPtr ResourcesInstanceCreate(AccountInfo accountInfo, AccountCredentials credentials, FeatureType featureType, FuncLoggingCallback logCb);
///
/// Create a GameKitFeatureResources instance, which can be used to access the GameKitFeatureResources API. Also sets the root and pluginRoot paths.
///
///
/// Make sure to call GameKitResourcesInstanceRelease() to destroy the returned object when finished with it.
///
/// Struct holding account id, game name, and deployment environment.
/// Struct holding account id, region, access key, and secret key.
/// The GameKit feature to work with.
/// New path for GAMEKIT_ROOT.
/// New path for the plugin root directory.
/// Callback function for logging information and errors.
/// Pointer to the new GameKitFeatureResources instance.
public IntPtr ResourcesInstanceCreateWithRootPaths(AccountInfo accountInfo, AccountCredentials credentials, FeatureType featureType, string rootPath, string pluginRootPath, FuncLoggingCallback logCb);
///
/// Destroy the provided GameKitFeatureResources instance.
///
public void ResourcesInstanceRelease();
///
/// Create an empty client configuration file in the current environment's instance files folder.
///
///
/// Call this to bootstrap a GameKit config file as soon as an environment has been selected.
///
/// The result status code of the operation (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful. The empty config file was created.
/// - GAMEKIT_ERROR_DIRECTORY_CREATE_FAILED: There was an error while creating missing directories in the filepath leading to the config file. Check the logs to see the root cause.
/// - GAMEKIT_ERROR_FILE_OPEN_FAILED: There was an error while opening an output stream for the new or existing config file. Check the logs to see the root cause.
/// - GAMEKIT_ERROR_FILE_WRITE_FAILED: There was an error while writing text to the config file.
///
public uint ResourcesCreateEmptyConfigFile();
#endregion
#region GameKitSettings
///
/// Gets a GameKitSettings instance, which can be used to access the Core Settings APIs.
///
///
/// Make sure to call Release() to destroy the returned object when finished with it.
///
/// Pointer to the new GameKitSessionManager instance.
public IntPtr GetSettingsInstance();
///
/// Create a GameKitSettings instance and load the settings from the GameKit Settings YAML file.
///
///
/// Make sure to call SettingsInstanceRelease() to destroy the returned object when finished with it.
///
/// The GAMEKIT_ROOT path where the "instance" templates and settings are stored.
/// The GameKit plugin version.
/// The current active environment based on what was selected in Environment and Credentials category eg "dev", "qa", custom
/// A shortened version of the game name.
/// Callback function for logging information and errors
/// Pointer to the new GameKitSettings instance.
public IntPtr SettingsInstanceCreate(string rootPath, string pluginVersion, string shortGameName, string currentEnvironment, FuncLoggingCallback logCb);
///
/// Destroy the provided GameKitSettings instance.
///
public void SettingsInstanceRelease();
///
/// Set the game's name.
///
/// The new game name.
public void SettingsSetGameName(string gameName);
///
/// Get the game's full name, example: "Stevie goes to the moon".
///
/// A string containing the name of the game.
public string SettingsGetGameName();
///
/// Set the last used region.
///
/// The region last used, example: "us-west-2".
public void SettingsSetLastUsedRegion(string region);
///
/// Get the developers last submitted region, example: "us-west-2".
///
/// A string containing the name of the last submitted region<./returns>
public string SettingsGetLastUsedRegion();
///
/// Set the last used environment.
///
/// The environment code.
public void SettingsSetLastUsedEnvironment(string envcode);
///
/// Get the developers last submitted environment code, example: "dev".
///
/// A string containing the last submitted environment code.
public string SettingsGetLastUsedEnvironment();
///
/// Get all the custom environment key-value pairs (ex: "gam", "Gamma").
///
/// The custom environments are returned through the callback and receiver.
/// The callback is invoked once for each custom environment.
/// The returned keys are 3-letter environment codes(ex: "gam"), and the values are corresponding environment descriptions(ex: "Gamma").
///
/// A result object containing a map of environment key value pairs
public Dictionary SettingsGetCustomEnvironments();
///
/// Get all of the feature's variables as key-value pairs.
///
/// The variables are returned through the callback and receiver.
/// The callback is invoked once for each variable.The variables are returned as key-value pairs of (variableName, variableValue).
/// The callback will not be invoked if the feature is missing from the settings file.
///
/// The feature to get the variables for
/// A result object containing a map of variable key value pairs
public Dictionary SettingsGetFeatureVariables(FeatureType featureType);
///
/// Add a custom deployment environment to the AWS GameKit settings menu.
///
///
/// This custom environment will be available to select from the dropdown menu in the Environment and Credentials section of the settings menu,
/// alongside the default environments of "Development", "QA", "Staging", and "Production".
///
/// Two to Three letter code for the environment name. This code will be prefixed on all AWS resources that are
/// deployed to this environment.Ex: "gam" for "Gamma".
/// envDescription The environment name that will be displayed in the Environment and Credentials section of the settings menu. Ex: "Gamma".
public void SettingsAddCustomEnvironment(string envCode, string envDescription);
///
/// Add key-value pairs to the feature's variables map, overwriting existing keys.
///
///
/// The parameters "varKeys", "varValues", and "numKeys" represent a map, where varKeys[N] maps to varValues[N], and numKeys is the total number of key-value pairs.
///
/// The feature to set the variables for.
/// The variable names.
/// The variable values.
/// The number of key-value pairs. The length of varKeys, varValues, and numKeys should be equal.
public void SettingsSetFeatureVariables(FeatureType featureType, string[] varKeys, string[] varValues, ulong numKeys);
///
/// Write the GAMEKIT Settings YAML file to disk.
///
///
/// Call this to persist any changes made through the "Set", "Add/Delete", "Activate/Deactivate" methods.
///
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint SettingsSave();
///
/// Set the Game's name, environment, and resion, then save settings
///
///
/// Use this method to create the settings file directory, set the game's name, set the games environment, set the games region, and then persist the settings.
///
/// The game's correctly formatted name
/// The 3-letter environment code to get the description for
/// The AWS deployment region
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult errors.h file for details.
public uint SettingsPopulateAndSave(string gameName, string envCode, string region);
///
/// Get the path to the "saveInfo.yml" settings file.
///
///
/// The path is equal to "GAMEKIT_ROOT/shortGameName/saveInfo.yml".
///
/// The path to "saveInfo.yml" as a string.
public string SettingsGetSettingsFilePath();
///
/// Save a new profile to the AWS credentials file.
///
/// The name of the profile we are saving or updating in the credentials ini file.
/// The access key of the AWS IAM role we are saving.
/// The secret key of the AWS IAM role we are saving.
/// Callback function for logging information and errors.
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint SaveAWSCredentials(string profileName, string accessKey, string secretKey, FuncLoggingCallback logCb);
///
/// Sets the AWS access key of an existing profile.
///
/// The name of the profile we are updating in the credentials ini file.
/// The new access key that will be assigned to this profile.
/// Callback function for logging information and errors.
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint SetAWSAccessKey(string profileName, string newAccessKey, FuncLoggingCallback logCb);
///
/// Sets the AWS secret key of an existing profile.
///
///
/// If the profile passed in does not exist, will not automatically create the profile and will return an error.
///
/// The name of the profile we are updating in the credentials ini file.
/// The new secret key that will be assigned to this profile.
/// Callback function for logging information and errors.
/// The result code of the operation. GAMEKIT_SUCCESS if successful, else a non-zero value in case of error. Consult GameKitErrors.cs file for details.
public uint SetAWSSecretKey(string profileName, string newSecretKey, FuncLoggingCallback logCb);
///
/// Gets the access key and secret key corresponding to a pre-existing profile in the AWS credentials file.
///
/// The name of the profile we are getting the access key and secret from.
/// Callback function for logging information and errors.
/// Callback function for logging information and errors.
public KeyValueStringCallbackResult GetAWSProfile(string profileName, FuncLoggingCallback logCb);
#endregion
#region Deployment Orchestrator
///
/// Get a pointer to an already initialized GameKitDeploymentOrchestrator instance.
///
/// This method will throw if DeploymentOrchestratorInstanceCreate was not called prior to calling this method.
/// Pointer to the existing GameKitDeploymentOrchestrator instance.
public IntPtr GetDeploymentOrchestratorInstance();
///
/// Create a GameKitDeploymentOrchestrator instance.
///
/// The folder where the "base" templates are stored. The base templates are the cloud formation templates, lambda functions, etc. which are copied to make the instance files (see next parameter).
/// The folder where the "instance" files and settings are going to be stored. The instance files are copied from the base templates, and are intended to be modified by the user.
/// Pointer to the new GameKitDeploymentOrchestrator instance.
public IntPtr DeploymentOrchestratorInstanceCreate(string baseTemplatesFolder, string instanceFilesFolder);
///
/// Destroy the provided GameKitDeploymentOrchestrator instance.
///
public void DeploymentOrchestratorInstanceRelease();
///
/// Set account credentials.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// Object holding the AccountInfo and AccountCredentials.
///
/// The result status code of the operation (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_ORCHESTRATION_DEPLOYMENT_IN_PROGRESS: Cannot change credentials while a deployment is in progress.
/// - GAMEKIT_ERROR_REGION_CODE_CONVERSION_FAILED: Could not retrieve the short region code from the mappings file. See the log for details on how to fix this.
///
public uint DeploymentOrchestratorSetCredentials(SetCredentialsDesc setCredentialsDesc);
///
/// Get the status of a requested feature.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
/// FeatureStatus enum related to the status of the requested feature.
public FeatureStatus DeploymentOrchestratorGetFeatureStatus(FeatureType feature);
///
/// Get an abridged status of a requested feature.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
/// FeatureStatusSummary enum related to the abridged status of the requested feature.
public FeatureStatusSummary DeploymentOrchestratorGetFeatureStatusSummary(FeatureType feature);
///
/// Check if the requested feature is currently being created, redeployed, or deleted.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// Unlike DeploymentOrchestratorIsFeatureUpdating, this method returns true while the Main stack is being deployed (before the feature itself is created or redeployed).
///
/// The GameKit feature to work with.
/// true if the requested feature is being created, redeployed, or deleted.
public bool DeploymentOrchestratorIsFeatureDeploymentInProgress(FeatureType feature);
///
/// Check if the requested feature is currently updating (i.e. it's FeatureStatus is not Deployed, Undeployed, Error, or RollbackComplete).
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
/// true if the requested feature is updating.
public bool DeploymentOrchestratorIsFeatureUpdating(FeatureType feature);
///
/// Check if any GameKit feature is currently updating (i.e. has a FeatureStatus other than Deployed, Undeployed, Error, or RollbackComplete).
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// true if any feature is updating.
public bool DeploymentOrchestratorIsAnyFeatureUpdating();
///
/// Refresh the status of a requested feature.
///
///
/// This is a long running operation.
///
/// The GameKit feature to work with.
///
/// The of all features and the result status code of the operation.
///
/// The result status code will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
///
public DeploymentResponseResult DeploymentOrchestratorRefreshFeatureStatus(FeatureType feature);
///
/// Refresh the status of all features.
///
///
/// This is a long running operation.
///
///
/// The of all features and the result status code of the operation.
///
/// The result status code will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
///
public DeploymentResponseResult DeploymentOrchestratorRefreshFeatureStatuses();
///
/// Request if a feature is in a state to be created.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
///
/// A object describing whether the feature can be created.
/// A and list of blocking are provided in cases where the feature cannot be created.
///
public CanExecuteDeploymentActionResult DeploymentOrchestratorCanCreateFeature(FeatureType feature);
///
/// Request if a feature can be re-deployed.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
///
/// A object describing whether the feature can be redeployed.
/// A and list of blocking are provided in cases where the feature cannot be redeployed.
///
public CanExecuteDeploymentActionResult DeploymentOrchestratorCanRedeployFeature(FeatureType feature);
///
/// Request if a feature is in a state where it can be deleted.
///
///
/// This is a fast method. It does not invoke any networked procedures.
///
/// The GameKit feature to work with.
///
/// A object describing whether the feature can be deleted.
/// A and list of blocking are provided in cases where the feature cannot be deleted.
///
public CanExecuteDeploymentActionResult DeploymentOrchestratorCanDeleteFeature(FeatureType feature);
///
/// Create a requested feature.
///
///
/// This is a long running operation.
///
/// The GameKit feature to work with.
///
/// The of all features and the result status code of the operation.
///
/// The result status code will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_ORCHESTRATION_INVALID_FEATURE_STATE: Cannot create feature as it or one of its dependencies are in an invalid state for deployment.
///
public DeploymentResponseResult DeploymentOrchestratorCreateFeature(FeatureType feature);
///
/// Re-deploy a requested feature.
///
///
/// This is a long running operation.
///
/// The GameKit feature to work with.
///
/// The of all features and the result status code of the operation.
///
/// The result status code will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_ORCHESTRATION_INVALID_FEATURE_STATE: Cannot redeploy feature as it or one of its dependencies are in an invalid state for deployment.
///
public DeploymentResponseResult DeploymentOrchestratorRedeployFeature(FeatureType feature);
///
/// Delete a requested feature.
///
///
/// This is a long running operation.
///
/// The GameKit feature to work with.
///
/// The of all features and the result status code of the operation.
///
/// The result status code will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_CLOUDFORMATION_STACK_DELETE_FAILED: Failed to delete the stack, check output log for exact reason.
/// - GAMEKIT_ERROR_ORCHESTRATION_INVALID_FEATURE_STATE: Cannot delete feature as it or one of its downstream dependencies are in an invalid state for deletion.
///
public DeploymentResponseResult DeploymentOrchestratorDeleteFeature(FeatureType feature);
///
/// Gets the deployment status of each AWS resource within the specified feature.
///
///
/// This is a long running operation.
///
/// The GameKit feature to work with.
///
/// The resource id, resource type, and resource status of each AWS resource within the specified feature.
///
/// Also returns the result status code of the operation, which will be one of (from GameKitErrors.cs):
/// - GAMEKIT_SUCCESS: The API call was successful.
/// - GAMEKIT_ERROR_CLOUDFORMATION_DESCRIBE_RESOURCE_FAILED: If status of the resources could not be determined.
///
public MultiResourceInfoCallbackResult DeploymentOrchestratorDescribeFeatureResources(FeatureType feature);
#endregion
#endif
}
}