@using Amazon.Lambda.TestTool.Runtime;
@inject LocalLambdaOptions LambdaOptions
@code {
string _awsProfile;
public string AWSProfile
{
get => this._awsProfile;
set
{
this._awsProfile = value;
OnChangeAsync?.Invoke();
}
}
string _awsRegion;
public string AWSRegion
{
get => this._awsRegion;
set
{
this._awsRegion = value;
OnChangeAsync?.Invoke();
}
}
public Func OnChangeAsync { get; set; }
private string _configFile;
public string ConfigFile
{
get => this._configFile;
set
{
this._configFile = value;
UpdateConfigFileChange();
OnChangeAsync?.Invoke();
}
}
string _functionHandler;
public string FunctionHandler
{
get => this._functionHandler;
set
{
this._functionHandler = value;
OnChangeAsync?.Invoke();
}
}
IList AvailableAWSProfiles;
IList AvailableFunctions;
protected override Task OnInitializedAsync()
{
AvailableAWSProfiles = this.LambdaOptions.LambdaRuntime.AWSService.ListProfiles();
if(LambdaOptions.LambdaConfigFiles.Count > 0)
{
this.ConfigFile = LambdaOptions.LambdaConfigFiles[0];
}
return Task.CompletedTask;
}
void UpdateConfigFileChange()
{
var configInfo = LambdaDefaultsConfigFileParser.LoadFromFile(this.ConfigFile);
AvailableFunctions = this.LambdaOptions.LambdaRuntime.LoadLambdaFunctions(configInfo.FunctionInfos);
this.FunctionHandler = this.AvailableFunctions.First()?.FunctionInfo?.Handler;
if (configInfo.AWSProfile != null && this.AvailableAWSProfiles.Contains(configInfo.AWSProfile))
{
this.AWSProfile = configInfo.AWSProfile;
}
if(!string.IsNullOrEmpty(configInfo.AWSRegion))
{
this.AWSRegion = configInfo.AWSRegion;
}
this.StateHasChanged();
}
}