public override async Task Execute() { var alias = CommandArgumentValue.GetArgumentScalarValue <string>(_alias); var type = CommandArgumentValue.GetArgumentScalarValue <IdentityProviderTypesDto>(_type); Logger.Info($"Creating identity provider '{@alias}' at '{ServiceClient.ServiceUri}'"); if (type == IdentityProviderTypesDto.Google) { var identityProviderDto = new GoogleIdentityProviderDto { IsEnabled = CommandArgumentValue.GetArgumentScalarValue <bool>(_enabled), ClientId = CommandArgumentValue.GetArgumentScalarValue <string>(_clientId), ClientSecret = CommandArgumentValue.GetArgumentScalarValueOrDefault <string>(_clientSecret), Alias = alias }; await ServiceClient.CreateIdentityProvider(identityProviderDto); } else if (type == IdentityProviderTypesDto.Microsoft) { var identityProviderDto = new MicrosoftIdentityProviderDto { IsEnabled = CommandArgumentValue.GetArgumentScalarValue <bool>(_enabled), ClientId = CommandArgumentValue.GetArgumentScalarValue <string>(_clientId), ClientSecret = CommandArgumentValue.GetArgumentScalarValueOrDefault <string>(_clientSecret), Alias = alias }; await ServiceClient.CreateIdentityProvider(identityProviderDto); } Logger.Info($"ServiceClient '{alias}' at '{ServiceClient.ServiceUri}' created."); }
public override async Task Execute() { var id = CommandArgumentValue.GetArgumentScalarValue <string>(_id); Logger.Info($"Updating identity provider '{id}' at '{ServiceClient.ServiceUri}'"); var identityProviderDto = await ServiceClient.GetIdentityProvider(id); if (identityProviderDto == null) { Logger.Error($"Identity provider '{id}' at '{ServiceClient.ServiceUri}' not found."); return; } if (identityProviderDto is GoogleIdentityProviderDto) { var newIdentityProviderDto = new GoogleIdentityProviderDto { Id = identityProviderDto.Id, IsEnabled = CommandArgumentValue.GetArgumentScalarValue <bool>(_enabled), ClientId = CommandArgumentValue.GetArgumentScalarValue <string>(_clientId), ClientSecret = CommandArgumentValue.GetArgumentScalarValueOrDefault <string>(_clientSecret), Alias = CommandArgumentValue.GetArgumentScalarValue <string>(_alias) }; await ServiceClient.UpdateIdentityProvider(id, identityProviderDto); } else if (identityProviderDto is MicrosoftIdentityProviderDto) { var newIdentityProviderDto = new MicrosoftIdentityProviderDto { IsEnabled = CommandArgumentValue.GetArgumentScalarValue <bool>(_enabled), ClientId = CommandArgumentValue.GetArgumentScalarValue <string>(_clientId), ClientSecret = CommandArgumentValue.GetArgumentScalarValueOrDefault <string>(_clientSecret), Alias = CommandArgumentValue.GetArgumentScalarValue <string>(_alias), }; await ServiceClient.UpdateIdentityProvider(id, newIdentityProviderDto); } Logger.Info($"Identity provider '{id}' at '{ServiceClient.ServiceUri}' updated."); }