Skip to content

Commit

Permalink
Merge pull request #46 from microsoft/users/annautiy/PreDownloadV2
Browse files Browse the repository at this point in the history
Added support for PreDownload
  • Loading branch information
Annautiy authored Jun 10, 2024
2 parents 8e346c5 + 984ac4a commit 9faf3df
Show file tree
Hide file tree
Showing 18 changed files with 207 additions and 79 deletions.
6 changes: 6 additions & 0 deletions Operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
- **availabilityDate**: optional - if informed it will configure custom availability date for your XVC/MSIXVC packages [Learn more](http://go.microsoft.com/fwlink/?LinkId=825239)
- **isEnabled**: optional (default false) - it will enable/disable custom availability date
- **effectiveDate**: optional - if informed it will set the package availability date (date format example: "2021-10-24T21:00:00.000Z")
- **preDownloadDate**: optional (default is equivalent to availabilityDate) - it will configure when package will be available for download for your XVC/MSIXVC packages
- **isEnabled**: optional (default false) - it will enable/disable custom pre-download date
- **effectiveDate**: optional - if informed it will set the package pre-download date (date format example: "2021-10-24T21:00:00.000Z")
- **uploadConfig**: optional - httpClient configuration to be used to upload the files
- **httpTimeoutMs**: (default and recommended: 5000)
- **httpUploadTimeoutMs**: (default and recommended: 300000)
Expand Down Expand Up @@ -143,6 +146,9 @@
- **mandatoryDate**: optional - if informed it will configure custom mandatory date for your UWP market groups in the destination branch/flight [Learn more](https://docs.microsoft.com/en-gb/windows/uwp/publish/upload-app-packages#mandatory-update)
- **isEnabled**: optional (default false) - it will enable/disable custom mandatory date
- **effectiveDate**: optional - if informed it will set the mandatory date (date format example: "2021-10-24T21:00:00.000Z")
- **preDownloadDate**: optional (default is equivalent to availabilityDate) - it will configure when package will be available for download for your XVC/MSIXVC packages
- **isEnabled**: optional (default false) - it will enable/disable custom pre-download date
- **effectiveDate**: optional - if informed it will set the package pre-download date (date format example: "2021-10-24T21:00:00.000Z")
- **gradualRollout**: optional - if informed it will configure gradual rollout for your UWP packages in the destination branch/flight [Learn more](https://docs.microsoft.com/en-gb/windows/uwp/publish/upload-app-packages#gradual-package-rollout)
- **isEnabled**: optional (default false) - it will enable/disable gradual rollout
- **percentage**: optional - rollout to start with
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ internal class ImportPackagesOperationConfig : PackageBranchOperationConfig, IGa
public string DestinationFlightName { get; set; }

public GamePackageDate AvailabilityDate { get; set; }
public GamePackageDate PreDownloadDate { get; set; }
public GamePackageDate MandatoryDate { get; set; }
public GameGradualRolloutInfo GradualRollout { get; set; }

public bool Overwrite { get; set; }

protected override void Validate(IList<ValidationResult> validationResults)
Expand All @@ -35,5 +35,15 @@ protected override void Validate(IList<ValidationResult> validationResults)
{
validationResults.Add(new ValidationResult($"Only one {nameof(DestinationBranchFriendlyName)} or {nameof(DestinationFlightName)} field is allowed.", new[] { nameof(DestinationBranchFriendlyName), nameof(DestinationFlightName) }));
}
}

if (PreDownloadDate?.IsEnabled == true && (AvailabilityDate?.IsEnabled != true))
{
validationResults.Add(new ValidationResult($"{nameof(PreDownloadDate)} needs {nameof(AvailabilityDate)}.", new[] { nameof(PreDownloadDate), nameof(AvailabilityDate) }));
}

if (PreDownloadDate?.IsEnabled == true && AvailabilityDate?.IsEnabled == true && PreDownloadDate.EffectiveDate > AvailabilityDate.EffectiveDate)
{
validationResults.Add(new ValidationResult($"{nameof(PreDownloadDate)} needs to be before {nameof(AvailabilityDate)}.", new[] { nameof(PreDownloadDate), nameof(AvailabilityDate) }));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace PackageUploader.Application.Config;

internal class UploadUwpPackageOperationConfig : UploadPackageOperationConfig, IGameConfiguration
internal class UploadUwpPackageOperationConfig : UploadPackageOperationConfig, IUwpGameConfiguration
{
internal override string GetOperationName() => "UploadUwpPackage";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using PackageUploader.ClientApi.Models;

namespace PackageUploader.Application.Config;

internal class UploadXvcPackageOperationConfig : UploadPackageOperationConfig
internal class UploadXvcPackageOperationConfig : UploadPackageOperationConfig, IXvcGameConfiguration
{
internal override string GetOperationName() => "UploadXvcPackage";

[Required]
public GameAssets GameAssets { get; set; }

public bool DeltaUpload { get; set; } = false;

public GamePackageDate PreDownloadDate { get; set; }

protected override void Validate(IList<ValidationResult> validationResults)
{
base.Validate(validationResults);

if (PreDownloadDate?.IsEnabled == true && (AvailabilityDate?.IsEnabled != true))
{
validationResults.Add(new ValidationResult($"{nameof(PreDownloadDate)} needs {nameof(AvailabilityDate)}.", new[] { nameof(PreDownloadDate), nameof(AvailabilityDate) }));
}

if (PreDownloadDate?.IsEnabled == true && AvailabilityDate?.IsEnabled == true && PreDownloadDate.EffectiveDate > AvailabilityDate.EffectiveDate)
{
validationResults.Add(new ValidationResult($"{nameof(PreDownloadDate)} needs to be before {nameof(AvailabilityDate)}.", new[] { nameof(PreDownloadDate), nameof(AvailabilityDate) }));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ protected override async Task ProcessAsync(CancellationToken ct)
var gamePackage = await _storeBrokerService.UploadGamePackageAsync(product, packageBranch, marketGroupPackage, _config.PackageFilePath, _config.GameAssets, _config.MinutesToWaitForProcessing, _config.DeltaUpload, isXvc: true, ct).ConfigureAwait(false);
_logger.LogInformation("Uploaded package with id: {gamePackageId}", gamePackage.Id);

if (_config.AvailabilityDate is not null)
if (_config.AvailabilityDate is not null || _config.PreDownloadDate is not null)
{
await _storeBrokerService.SetXvcAvailabilityDateAsync(product, packageBranch, gamePackage, _config.MarketGroupName, _config.AvailabilityDate, ct).ConfigureAwait(false);
_logger.LogInformation("Availability date set");
await _storeBrokerService.SetXvcConfigurationAsync(product, packageBranch, gamePackage, _config.MarketGroupName, _config, ct).ConfigureAwait(false);
_logger.LogInformation("Configuration set for Xvc packages");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ private static GameMarketGroupPackage Map(this IngestionMarketGroupPackage inges
MandatoryUpdateInfo = ingestionMarketGroupPackage.MandatoryUpdateInfo.Map(),
AvailabilityDate = ingestionMarketGroupPackage.AvailabilityDate,
PackageAvailabilityDates = ingestionMarketGroupPackage.PackageAvailabilityDates,
PackageIdToMetadataMap = ingestionMarketGroupPackage.PackageIdToMetadataMap?.ToDictionary(a => a.Key, a => a.Value?.Map()),
};

private static GameMandatoryUpdateInfo Map(this IngestionMandatoryUpdateInfo ingestionMandatoryUpdateInfo) =>
Expand Down Expand Up @@ -209,6 +210,7 @@ private static IngestionMarketGroupPackage Map(this GameMarketGroupPackage gameM
Markets = gameMarketGroupPackage.Markets,
Name = gameMarketGroupPackage.Name,
PackageAvailabilityDates = gameMarketGroupPackage.PackageAvailabilityDates?.ToDictionary(a => a.Key, a => a.Value?.ToUniversalTime()),
PackageIdToMetadataMap = gameMarketGroupPackage.PackageIdToMetadataMap?.ToDictionary(a => a.Key, a => a.Value?.Map()),
PackageIds = gameMarketGroupPackage.PackageIds,
};

Expand Down Expand Up @@ -258,4 +260,16 @@ public static GamePackageFlight Map(this IngestionFlight ingestionFlight, GamePa
Name = ingestionFlight.Name,
CurrentDraftInstanceId = gamePackageBranch.CurrentDraftInstanceId,
};

private static GameMarketGroupPackageMetadata Map(this IngestionMarketGroupPackageMetadata ingestionMarketGroupPackageMetadata) =>
ingestionMarketGroupPackageMetadata is null ? null : new()
{
PreDownloadDate = ingestionMarketGroupPackageMetadata.PreDownloadDate,
};

private static IngestionMarketGroupPackageMetadata Map(this GameMarketGroupPackageMetadata marketGroupPackageMetadata) =>
marketGroupPackageMetadata is null ? null : new()
{
PreDownloadDate = marketGroupPackageMetadata.PreDownloadDate,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,9 @@ public sealed class GameMarketGroupPackage
/// Dictionary of per region, per package scheduled release dates for XVC and MSIXVC packages
/// </summary>
public Dictionary<string, DateTime?> PackageAvailabilityDates { get; set; }

/// <summary>
/// Dictionary of per package metadata (e.g. predownload date) for XVC and MSIXVC packages
/// </summary>
public Dictionary<string, GameMarketGroupPackageMetadata> PackageIdToMetadataMap { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

namespace PackageUploader.ClientApi.Client.Ingestion.Models;

public class GameMarketGroupPackageMetadata
{
public DateTime? PreDownloadDate { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,22 @@ internal class IngestionMarketGroupPackage
public List<string> PackageIds { get; set; }

/// <summary>
/// Mandatory update
/// Mandatory update for UWP packages
/// </summary>
public IngestionMandatoryUpdateInfo MandatoryUpdateInfo { get; set; }

/// <summary>
/// Schedule release date per region
/// Schedule release date per region for UWP packages
/// </summary>
public DateTime? AvailabilityDate { get; set; }

/// <summary>
/// Dictionary of per region, per package scheduled release dates for XVC and MSIXVC packages
/// </summary>
public Dictionary<string, DateTime?> PackageAvailabilityDates { get; set; }

/// <summary>
/// Dictionary of per package metadata (e.g. predownload date) for XVC and MSIXVC packages
/// </summary>
public Dictionary<string, IngestionMarketGroupPackageMetadata> PackageIdToMetadataMap { get; set; }
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using System;

namespace PackageUploader.ClientApi.Client.Ingestion.Models.Internal;

internal class IngestionMarketGroupPackageMetadata
{
public DateTime? PreDownloadDate { get; set; }
}
4 changes: 2 additions & 2 deletions src/PackageUploader.ClientApi/IPackageUploaderService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ public interface IPackageUploaderService
Task<GamePackageConfiguration> UpdatePackageConfigurationAsync(GameProduct product, GamePackageConfiguration packageConfiguration, CancellationToken ct);
Task<GamePackage> UploadGamePackageAsync(GameProduct product, IGamePackageBranch packageBranch, GameMarketGroupPackage marketGroupPackage, string packageFilePath, GameAssets gameAssets, int minutesToWaitForProcessing, bool deltaUpload, bool isXvc, CancellationToken ct);
Task<GamePackageConfiguration> RemovePackagesAsync(GameProduct product, IGamePackageBranch packageBranch, string marketGroupName, string packageFileName, CancellationToken ct);
Task<GamePackageConfiguration> SetXvcAvailabilityDateAsync(GameProduct product, IGamePackageBranch packageBranch, GamePackage gamePackage, string marketGroupName, GamePackageDate availabilityDate, CancellationToken ct);
Task<GamePackageConfiguration> SetUwpConfigurationAsync(GameProduct product, IGamePackageBranch packageBranch, string marketGroupId, IGameConfiguration gameConfiguration, CancellationToken ct);
Task<GamePackageConfiguration> SetXvcConfigurationAsync(GameProduct product, IGamePackageBranch packageBranch, GamePackage gamePackage, string marketGroupName, IXvcGameConfiguration gameConfiguration, CancellationToken ct);
Task<GamePackageConfiguration> SetUwpConfigurationAsync(GameProduct product, IGamePackageBranch packageBranch, string marketGroupId, IUwpGameConfiguration gameConfiguration, CancellationToken ct);
Task<GamePackageConfiguration> ImportPackagesAsync(GameProduct product, IGamePackageBranch originPackageBranch, IGamePackageBranch destinationPackageBranch, string marketGroupName, bool overwrite, CancellationToken ct);
Task<GamePackageConfiguration> ImportPackagesAsync(GameProduct product, IGamePackageBranch originPackageBranch, IGamePackageBranch destinationPackageBranch, string marketGroupName, bool overwrite, IGameConfiguration gameConfiguration, CancellationToken ct);
Task<GameSubmission> PublishPackagesToSandboxAsync(GameProduct product, GamePackageBranch originPackageBranch, string destinationSandboxName, int minutesToWaitForPublishing, CancellationToken ct);
Expand Down
24 changes: 0 additions & 24 deletions src/PackageUploader.ClientApi/Models/GameConfiguration.cs

This file was deleted.

1 change: 1 addition & 0 deletions src/PackageUploader.ClientApi/Models/IGameConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace PackageUploader.ClientApi.Models;
public interface IGameConfiguration
{
GamePackageDate AvailabilityDate { get; set; }
GamePackageDate PreDownloadDate { get; set; }
GamePackageDate MandatoryDate { get; set; }
GameGradualRolloutInfo GradualRollout { get; set; }
}
13 changes: 13 additions & 0 deletions src/PackageUploader.ClientApi/Models/IUwpGameConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

using PackageUploader.ClientApi.Client.Ingestion.Models;

namespace PackageUploader.ClientApi.Models;

public interface IUwpGameConfiguration
{
GamePackageDate AvailabilityDate { get; set; }
GamePackageDate MandatoryDate { get; set; }
GameGradualRolloutInfo GradualRollout { get; set; }
}
10 changes: 10 additions & 0 deletions src/PackageUploader.ClientApi/Models/IXvcGameConfiguration.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

namespace PackageUploader.ClientApi.Models;

public interface IXvcGameConfiguration
{
GamePackageDate AvailabilityDate { get; set; }
GamePackageDate PreDownloadDate { get; set; }
}
Loading

0 comments on commit 9faf3df

Please sign in to comment.