public static (bool success, AppResponse response) CreateApp(this ICakeContext context, string apiToken, AppSettings settings) { var token = apiToken ?? context.Environment.GetEnvironmentVariable(ENV_VAR_API_TOKEN); // Guard against missing required properties if (string.IsNullOrEmpty(token)) { throw new NoNullAllowedException($"AppCenter API token is required. Pass in or set at {ENV_VAR_API_TOKEN}"); } if (string.IsNullOrEmpty(settings.Name)) { throw new NoNullAllowedException("App name is required."); } if (string.IsNullOrEmpty(settings.DisplayName)) { throw new NoNullAllowedException("App display name is required."); } var appCenterClient = new AppCenterClientApi(token); var result = appCenterClient.CreateApp(settings); if (!result.success) { context.Log.Error("Error creating app."); } return(result); }
public static (bool success, List <AppResponse> response) GetApps(this ICakeContext context, string apiToken) { var token = apiToken ?? context.Environment.GetEnvironmentVariable(ENV_VAR_API_TOKEN); // Guard against missing required properties if (string.IsNullOrEmpty(token)) { throw new NoNullAllowedException($"AppCenter API token is required. Pass in or set at {ENV_VAR_API_TOKEN}"); } var appCenterClient = new AppCenterClientApi(token); var result = appCenterClient.GetApps(); if (!result.success) { context.Log.Error("Error retrieving apps."); } return(result); }
public static bool DeleteApp(this ICakeContext context, string apiToken, string appName, string ownerName) { var token = apiToken ?? context.Environment.GetEnvironmentVariable(ENV_VAR_API_TOKEN); // Guard against missing required properties if (string.IsNullOrEmpty(token)) { throw new NoNullAllowedException($"AppCenter API token is required. Pass in or set at {ENV_VAR_API_TOKEN}"); } if (string.IsNullOrEmpty(appName) || string.IsNullOrEmpty(ownerName)) { throw new NoNullAllowedException("App and Owner name are required."); } var appCenterClient = new AppCenterClientApi(token); var result = appCenterClient.DeleteApp(appName, ownerName); if (!result) { context.Log.Error($"Error deleting '{appName}'"); } return(result); }