From 4a7cdeb27ada0aa1202c0b4e245234dba6339479 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 6 Sep 2023 19:08:41 +0530 Subject: [PATCH] Azure-EU, Azure-NA and Include Metadata Azure-EU, Azure-NA and Include Metadata support added --- .../Contentstack.AspNetCore.csproj | 2 +- .../Contentstack.Core.Tests.csproj | 10 +++--- Contentstack.Core/Configuration/Config.cs | 10 ++++++ Contentstack.Core/Contentstack.Core.csproj | 4 +-- .../Internals/ContentstackRegion.cs | 18 +++++++++-- Contentstack.Core/Models/Asset.cs | 30 ++++++++++++++++++ Contentstack.Core/Models/AssetLibrary.cs | 29 +++++++++++++++++ Contentstack.Core/Models/Entry.cs | 31 +++++++++++++++++++ Contentstack.Core/Models/Query.cs | 29 +++++++++++++++++ global.json | 2 +- 10 files changed, 154 insertions(+), 11 deletions(-) diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj index e09e0eb..8f984d4 100644 --- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj +++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj @@ -29,6 +29,6 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index 3606c0a..0ec08d0 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -1,21 +1,21 @@  - netcoreapp3.1 + net7.0 false 2.10.0 - - - runtime; build; native; contentfiles; analyzers; buildtransitive + + + runtime; build; native; contentfiles; analyzers; buildtransitive all - + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/Contentstack.Core/Configuration/Config.cs b/Contentstack.Core/Configuration/Config.cs index 88041d4..cd0566b 100644 --- a/Contentstack.Core/Configuration/Config.cs +++ b/Contentstack.Core/Configuration/Config.cs @@ -107,6 +107,16 @@ internal string HostURL { if (Region == ContentstackRegion.EU) return "cdn.contentstack.com"; + if (Region == ContentstackRegion.AZURE_EU || Region == ContentstackRegion.AZURE_NA) { + if (Region == ContentstackRegion.AZURE_NA) { + return "azure-na-cdn.contentstack.com"; + } + if (Region == ContentstackRegion.AZURE_EU) + { + return "azure-eu-cdn.contentstack.com"; + } + } + return "cdn.contentstack.io"; } } diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index b4ea183..eb358ae 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -26,9 +26,9 @@ - + - + diff --git a/Contentstack.Core/Internals/ContentstackRegion.cs b/Contentstack.Core/Internals/ContentstackRegion.cs index 28b4edd..fa0bec1 100644 --- a/Contentstack.Core/Internals/ContentstackRegion.cs +++ b/Contentstack.Core/Internals/ContentstackRegion.cs @@ -13,7 +13,16 @@ public enum ContentstackRegion /// /// To specify EU region. /// - EU + EU, + /// + /// To specify EU region. + /// + AZURE_EU, + + /// + /// To specify EU region. + /// + AZURE_NA } @@ -21,6 +30,11 @@ internal enum ContentstackRegionCode { us, - eu + eu, + + azure_eu, + + azure_na + } } diff --git a/Contentstack.Core/Models/Asset.cs b/Contentstack.Core/Models/Asset.cs index 9fa04ce..ad91aa8 100644 --- a/Contentstack.Core/Models/Asset.cs +++ b/Contentstack.Core/Models/Asset.cs @@ -178,6 +178,36 @@ public Asset includeFallback() return this; } + + + /// + /// This call includes metadata in the response. + /// + /// Current instance of Asset, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); + /// asset.IncludeMetadata(); + /// asset.Fetch<Product>().ContinueWith((assetResult) => { + /// //Your callback code. + /// }); + /// + /// + public Asset IncludeMetadata() + { + try + { + this.UrlQueries.Add("include_metadata", "true"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } + + /// /// Include branch for publish content. /// diff --git a/Contentstack.Core/Models/AssetLibrary.cs b/Contentstack.Core/Models/AssetLibrary.cs index 387ff95..588cc58 100644 --- a/Contentstack.Core/Models/AssetLibrary.cs +++ b/Contentstack.Core/Models/AssetLibrary.cs @@ -185,6 +185,35 @@ public void IncludeCount() UrlQueries.Add("include_count", "true"); } + + + + /// + /// This call includes metadata in the response. + /// + /// Current instance of AssetLibrary, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// AssetLibrary assetLibrary = stack.AssetLibrary(); + /// assetLibrary.IncludeMetadata(); + /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// + /// + public void IncludeMetadata() + { + try + { + UrlQueries.Add("include_metadata", "true"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + } + + + /// /// This method includes the relative url of assets. /// diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs index a5338dc..123845d 100644 --- a/Contentstack.Core/Models/Entry.cs +++ b/Contentstack.Core/Models/Entry.cs @@ -1054,6 +1054,37 @@ public Entry IncludeFallback() return this; } + + /// + /// Include metadata includes metadata. + /// + /// Current instance of Entry, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.IncludeMetadata(); + /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// //Your Metadata code. + /// }); + /// + /// + public Entry IncludeMetadata() + { + try + { + UrlQueries.Add("include_metadata", "true"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } + + + + /// /// Include branch for publish content. /// diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 4038d96..5166d14 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -1154,6 +1154,35 @@ public Query IncludeCount() return this; } + + + /// + /// This call includes metadata in the response. + /// + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.IncludeMetadata(); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your metadata code. + /// }); + /// + /// + public Query IncludeMetadata() + { + try + { + UrlQueries.Add("include_metadata", "true"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } + /// /// This method also includes owner information for all the entries returned in the response. /// diff --git a/global.json b/global.json index 79893f3..d8f262e 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "3.1.404" + "version": "7.0.400" } }