Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrated CustomerLicense to SoftwareLicense #84

Merged
merged 2 commits into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Common/CustomerPortalClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -392,15 +392,15 @@ public async Task<bool> CheckCustomerEnvironmentConnectionStatus(long? definitio
}

/// <inheritdoc/>
public async Task<CustomerEnvironmentApplicationPackage> CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string customerLicenseName)
public async Task<CustomerEnvironmentApplicationPackage> CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string softwareLicenseName)
{
return (await new CreateOrUpdateAppInstallationInput()
{
CustomerEnvironmentId = customerEnvironmentId,
ApplicationPackageName = appName,
AppVersion = appVersion,
Parameters = parameters,
CustomerLicenseName = customerLicenseName
SoftwareLicenseName = softwareLicenseName
}.CreateOrUpdateAppInstallationAsync(true)).CustomerEnvironmentApplicationPackage;
}

Expand Down
10 changes: 5 additions & 5 deletions src/Common/Handlers/NewEnvironmentHandler.cs
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Cmf.CustomerPortal.BusinessObjects;
using Cmf.CustomerPortal.Common.Deployment;
using Cmf.CustomerPortal.Orchestration.CustomerEnvironmentManagement.InputObjects;
using Cmf.CustomerPortal.Sdk.Common.Services;
using Cmf.Foundation.BusinessObjects;
using Cmf.Foundation.BusinessOrchestration.EntityTypeManagement.InputObjects;
using Cmf.Foundation.BusinessOrchestration.GenericServiceManagement.InputObjects;
using Cmf.Foundation.Common.Licenses.Enums;
using Cmf.LightBusinessObjects.Infrastructure.Errors;
using System.Linq;
using Cmf.CustomerPortal.Common.Deployment;

namespace Cmf.CustomerPortal.Sdk.Common.Handlers
{
Expand Down Expand Up @@ -92,8 +92,8 @@
environment.Description = description;
}

environment.DeploymentPackage = isInfrastructureAgent || string.IsNullOrWhiteSpace(deploymentPackageName) ? environment.DeploymentPackage : await _customerPortalClient.GetObjectByName<DeploymentPackage>(deploymentPackageName);

Check warning on line 95 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete

Check warning on line 95 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete

Check warning on line 95 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete

Check warning on line 95 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete
environment.CustomerLicense = isInfrastructureAgent || string.IsNullOrWhiteSpace(licenseName) ? environment.CustomerLicense : await _customerPortalClient.GetObjectByName<CustomerLicense>(licenseName);
environment.SoftwareLicense = isInfrastructureAgent || string.IsNullOrWhiteSpace(licenseName) ? environment.SoftwareLicense : await Utils.GetLicenseByUniqueName(licenseName);

Check warning on line 96 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete

Check warning on line 96 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete

Check warning on line 96 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete

Check warning on line 96 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete
environment.DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target);
environment.ChangeSet = null;

Expand Down Expand Up @@ -190,10 +190,10 @@
Description = description,
Parameters = rawParameters,
EnvironmentType = environmentType.ToString(),
DeploymentPackage = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName<DeploymentPackage>(deploymentPackageName),

Check warning on line 193 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete

Check warning on line 193 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete
DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target),
Site = environmentSite,
CustomerLicense = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName<CustomerLicense>(licenseName)
SoftwareLicense = isInfrastructureAgent ? null : await Utils.GetLicenseByUniqueName(licenseName)

Check warning on line 196 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete

Check warning on line 196 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete
};

// check environment connection
Expand All @@ -218,8 +218,8 @@
EnvironmentType = environmentType.ToString(),
Site = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName<ProductSite>(siteName),
Name = name,
DeploymentPackage = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName<DeploymentPackage>(deploymentPackageName),

Check warning on line 221 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete

Check warning on line 221 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.DeploymentPackage' is obsolete
CustomerLicense = isInfrastructureAgent ? null : await _customerPortalClient.GetObjectByName<CustomerLicense>(licenseName),
SoftwareLicense = isInfrastructureAgent ? null : await Utils.GetLicenseByUniqueName(licenseName),

Check warning on line 222 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete

Check warning on line 222 in src/Common/Handlers/NewEnvironmentHandler.cs

View workflow job for this annotation

GitHub Actions / Build

'CustomerEnvironment.SoftwareLicense' is obsolete
DeploymentTarget = _newEnvironmentUtilities.GetDeploymentTargetValue(target),
Parameters = rawParameters
};
Expand Down
4 changes: 2 additions & 2 deletions src/Common/ICustomerPortalClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ public interface ICustomerPortalClient
/// <param name="appName">Name of the ApplicationPackage.</param>
/// <param name="appVersion">Version of the ApplicationPackage.</param>
/// <param name="parameters">Deployment parameters for the CustomerEnvironmentApplicationPackage.</param>
/// <param name="customerLicenseName">Name of a CustomerLicense.</param>
/// <param name="softwareLicenseName">Name of a SoftwareLicense.</param>
/// <returns>The CustomerEnvironmentApplicationPackage relation.</returns>
Task<CustomerEnvironmentApplicationPackage> CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string customerLicenseName);
Task<CustomerEnvironmentApplicationPackage> CreateOrUpdateAppInstallation(long customerEnvironmentId, string appName, string appVersion, string parameters, string softwareLicenseName);

/// <summary>
/// Check the Deployment connection to verify if the deployment of an environment/app can occur.
Expand Down
35 changes: 34 additions & 1 deletion src/Common/Utils.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using Cmf.CustomerPortal.BusinessObjects;
using Cmf.Foundation.BusinessObjects.QueryObject;
using Cmf.Foundation.BusinessOrchestration.GenericServiceManagement.InputObjects;
using Cmf.Foundation.Common;

namespace Cmf.CustomerPortal.Sdk.Common
{
Expand Down Expand Up @@ -85,5 +90,33 @@
return tokens;
});
}

/// <summary>
/// Name of SoftwareLicense is not unique, since it is a versioned entity
/// To load a license by name, we need to get it by the LicenseUniqueName
/// </summary>
/// <param name="licenseUniqueName"></param>
/// <returns></returns>
public static async Task<CPSoftwareLicense> GetLicenseByUniqueName(string licenseUniqueName)

Check warning on line 100 in src/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 100 in src/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.

Check warning on line 100 in src/Common/Utils.cs

View workflow job for this annotation

GitHub Actions / Build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
FilterCollection fcCollection = new FilterCollection()
{
new Filter()
{
Name = "LicenseUniqueName",
LogicalOperator = LogicalOperator.AND,
Operator = FieldOperator.IsEqualTo,
Value = licenseUniqueName
}
};

GetObjectsByFilterInput gobfiInput = new GetObjectsByFilterInput
{
Filter = fcCollection,
Type = Activator.CreateInstance<CPSoftwareLicense>()
};

return (CPSoftwareLicense)gobfiInput.GetObjectsByFilterSync().Instance[0];
}
}
}
Binary file modified src/Common/libs/Cmf.LightBusinessObjects.dll
Binary file not shown.
Binary file modified src/Common/libs/Cmf.LoadBalancing.dll
Binary file not shown.
Binary file modified src/Common/libs/Cmf.MessageBus.Client.dll
Binary file not shown.
Loading