From 4a7cdeb27ada0aa1202c0b4e245234dba6339479 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Wed, 6 Sep 2023 19:08:41 +0530 Subject: [PATCH 1/5] 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" } } From 00198092e016e54130c53c2795321e5cf00f8356 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 12 Sep 2023 19:07:54 +0530 Subject: [PATCH 2/5] support of region and include metadata support of region and include metadata --- .../Contentstack.AspNetCore.csproj | 6 +++--- Contentstack.Core.Tests/AssetTest.cs | 7 ++----- .../Contentstack.Core.Tests.csproj | 2 +- Contentstack.Core.Tests/EntryTest.cs | 2 +- Contentstack.Core.Tests/QueryTest.cs | 1 + Contentstack.Core.Tests/StackConfig.cs | 1 + Contentstack.Core/Configuration/Config.cs | 14 ++------------ Contentstack.Core/Contentstack.Core.csproj | 6 +++--- Contentstack.Core/Internals/HttpRequestHandler.cs | 2 +- Contentstack.Core/Models/AssetLibrary.cs | 3 ++- Contentstack.Net.sln | 2 +- 11 files changed, 18 insertions(+), 28 deletions(-) diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj index 8f984d4..8d19bfb 100644 --- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj +++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj @@ -6,12 +6,12 @@ contentstack.aspnetcore Contentstack Contentstack - 2.10.0 + 2.11.0 Main release Copyright (c) 2012-2023 Contentstack (http://app.contentstack.com). All Rights Reserved https://github.com/contentstack/contentstack-dotnet - v2.10.0 - 2.10.0 + v2.11.0 + 2.11.0 Release;Debug diff --git a/Contentstack.Core.Tests/AssetTest.cs b/Contentstack.Core.Tests/AssetTest.cs index 32f6a12..88bc5d4 100644 --- a/Contentstack.Core.Tests/AssetTest.cs +++ b/Contentstack.Core.Tests/AssetTest.cs @@ -2,13 +2,9 @@ using Xunit; using Contentstack.Core.Models; using System.Threading.Tasks; -using Contentstack.Core.Configuration; using System.Collections.Generic; using System.Linq; -using System.Text.RegularExpressions; -using System.Collections; using Newtonsoft.Json.Linq; -using Contentstack.Utils; namespace Contentstack.Core.Tests { public class AssetTest @@ -128,7 +124,8 @@ public async Task FetchAssetsIncludeRelativeURL() [Fact] public async Task FetchAssetCountAsync() { - AssetLibrary assetLibrary = client.AssetLibrary().SetLocale("en-us"); + AssetLibrary assetLibrary = client.AssetLibrary(). + IncludeMetadata().SetLocale("en-us"); JObject jObject = await assetLibrary.Count(); if (jObject == null) { diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index 0ec08d0..e7fbfab 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -4,7 +4,7 @@ net7.0 false - 2.10.0 + 2.11.0 diff --git a/Contentstack.Core.Tests/EntryTest.cs b/Contentstack.Core.Tests/EntryTest.cs index 819d3d6..17e5491 100644 --- a/Contentstack.Core.Tests/EntryTest.cs +++ b/Contentstack.Core.Tests/EntryTest.cs @@ -48,7 +48,7 @@ public async Task FetchByUid() { ContentType contenttype = client.ContentType(source); string uid = await GetUID("source1"); Entry sourceEntry = contenttype.Entry(uid); - + sourceEntry.IncludeMetadata(); await sourceEntry.Fetch().ContinueWith((t) => { Entry result = t.Result; diff --git a/Contentstack.Core.Tests/QueryTest.cs b/Contentstack.Core.Tests/QueryTest.cs index a7906f6..c8ea1ab 100644 --- a/Contentstack.Core.Tests/QueryTest.cs +++ b/Contentstack.Core.Tests/QueryTest.cs @@ -61,6 +61,7 @@ public async Task FetchEntriesPublishFallback() ContentstackCollection entries = await client.ContentType(source).Query() .SetLocale("ja-jp") .IncludeFallback() + .IncludeMetadata() .Find(); ; Assert.True(entries.Items.Count() > 0); diff --git a/Contentstack.Core.Tests/StackConfig.cs b/Contentstack.Core.Tests/StackConfig.cs index 8a0e67a..4cb8eb0 100644 --- a/Contentstack.Core.Tests/StackConfig.cs +++ b/Contentstack.Core.Tests/StackConfig.cs @@ -37,6 +37,7 @@ public static ContentstackClient GetStack() DeliveryToken = delivery_token, Environment = environment, Host = host, + }; ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper(contentstackOptions)); diff --git a/Contentstack.Core/Configuration/Config.cs b/Contentstack.Core/Configuration/Config.cs index cd0566b..50af06b 100644 --- a/Contentstack.Core/Configuration/Config.cs +++ b/Contentstack.Core/Configuration/Config.cs @@ -98,25 +98,15 @@ internal string regionCode() { if (Region == ContentstackRegion.US) return ""; ContentstackRegionCode[] regionCodes = Enum.GetValues(typeof(ContentstackRegionCode)).Cast().ToArray(); - return string.Format("{0}-", regionCodes[(int)Region].ToString()); + return string.Format("{0}-", regionCodes[(int)Region].ToString().Replace("_", "-")); } internal string HostURL { get { - if (Region == ContentstackRegion.EU) + if (Region == ContentstackRegion.EU || Region == ContentstackRegion.AZURE_EU || Region == ContentstackRegion.AZURE_NA) 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 eb358ae..2dc5722 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -5,15 +5,15 @@ contentstack.csharp Contentstack .NET SDK for the Contentstack Content Delivery API. - 2.10.0 + 2.11.0 Contentstack Reference in entry Live preview support added Copyright © 2012-2023 Contentstack. All Rights Reserved true - v2.10.0 + v2.11.0 https://github.com/contentstack/contentstack-dotnet LICENSE.txt - 2.10.0 + 2.11.0 diff --git a/Contentstack.Core/Internals/HttpRequestHandler.cs b/Contentstack.Core/Internals/HttpRequestHandler.cs index 3a4f6da..6ecd2c5 100644 --- a/Contentstack.Core/Internals/HttpRequestHandler.cs +++ b/Contentstack.Core/Internals/HttpRequestHandler.cs @@ -48,7 +48,7 @@ public async Task ProcessRequest(string Url, Dictionary var request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.ContentType = "application/json"; - request.Headers["x-user-agent"]="contentstack-dotnet/2.10.0"; + request.Headers["x-user-agent"]="contentstack-dotnet/2.11.0"; if (Branch != null) { request.Headers["branch"] = Branch; diff --git a/Contentstack.Core/Models/AssetLibrary.cs b/Contentstack.Core/Models/AssetLibrary.cs index 588cc58..9c1a072 100644 --- a/Contentstack.Core/Models/AssetLibrary.cs +++ b/Contentstack.Core/Models/AssetLibrary.cs @@ -200,7 +200,7 @@ public void IncludeCount() /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); /// /// - public void IncludeMetadata() + public AssetLibrary IncludeMetadata() { try { @@ -210,6 +210,7 @@ public void IncludeMetadata() { throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); } + return this; } diff --git a/Contentstack.Net.sln b/Contentstack.Net.sln index 61b1d93..625ca2b 100644 --- a/Contentstack.Net.sln +++ b/Contentstack.Net.sln @@ -132,6 +132,6 @@ Global $0.XmlFormattingPolicy = $9 $9.scope = application/xml $0.StandardHeader = $10 - version = 2.10.0 + version = 2.11.0 EndGlobalSection EndGlobal From 68d18e765fb3f77afa0e956a523795f9af54d7e6 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 12 Sep 2023 19:10:24 +0530 Subject: [PATCH 3/5] removed SAST file --- .github/workflows/sast-scan.yml | 11 ----------- .github/workflows/sca-scan.yml | 23 ----------------------- global.json | 2 +- 3 files changed, 1 insertion(+), 35 deletions(-) delete mode 100644 .github/workflows/sast-scan.yml delete mode 100644 .github/workflows/sca-scan.yml diff --git a/.github/workflows/sast-scan.yml b/.github/workflows/sast-scan.yml deleted file mode 100644 index f931630..0000000 --- a/.github/workflows/sast-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: SAST Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Horusec Scan - run: docker run -v /var/run/docker.sock:/var/run/docker.sock -v $(pwd):/src horuszup/horusec-cli:latest horusec start -p /src -P $(pwd) \ No newline at end of file diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml deleted file mode 100644 index b11e368..0000000 --- a/.github/workflows/sca-scan.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: Source Composition Analysis Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - name: Checkout repository - uses: actions/checkout@master - - name: Setup .NET Core @ Latest - uses: actions/setup-dotnet@v1 - with: - dotnet-version: '3.1.x' - - name: Run Dotnet Restore - run: | - dotnet restore - - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/dotnet@master - env: - SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} - with: - args: --file=Contentstack.Core/obj/project.assets.json --fail-on=all diff --git a/global.json b/global.json index d8f262e..79893f3 100644 --- a/global.json +++ b/global.json @@ -1,5 +1,5 @@ { "sdk": { - "version": "7.0.400" + "version": "3.1.404" } } From 55efc3ad6ded25c1928edbead01fc0b33907e8bc Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 12 Sep 2023 19:12:16 +0530 Subject: [PATCH 4/5] secrets-scan removed --- .github/workflows/sca-scan.yml | 23 +++++++++++++++++++++++ .github/workflows/secrets-scan.yml | 11 ----------- 2 files changed, 23 insertions(+), 11 deletions(-) create mode 100644 .github/workflows/sca-scan.yml delete mode 100644 .github/workflows/secrets-scan.yml diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml new file mode 100644 index 0000000..b11e368 --- /dev/null +++ b/.github/workflows/sca-scan.yml @@ -0,0 +1,23 @@ +name: Source Composition Analysis Scan +on: + pull_request: + types: [opened, synchronize, reopened] +jobs: + security: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@master + - name: Setup .NET Core @ Latest + uses: actions/setup-dotnet@v1 + with: + dotnet-version: '3.1.x' + - name: Run Dotnet Restore + run: | + dotnet restore + - name: Run Snyk to check for vulnerabilities + uses: snyk/actions/dotnet@master + env: + SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} + with: + args: --file=Contentstack.Core/obj/project.assets.json --fail-on=all diff --git a/.github/workflows/secrets-scan.yml b/.github/workflows/secrets-scan.yml deleted file mode 100644 index 1e8f176..0000000 --- a/.github/workflows/secrets-scan.yml +++ /dev/null @@ -1,11 +0,0 @@ -name: Secrets Scan -on: - pull_request: - types: [opened, synchronize, reopened] -jobs: - security: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Gittyleaks - uses: gupy-io/gittyleaks-action@v0.1 \ No newline at end of file From e932a093d0092faacc9905282d4541a9f9f06c08 Mon Sep 17 00:00:00 2001 From: Shailesh Mishra Date: Tue, 12 Sep 2023 19:18:20 +0530 Subject: [PATCH 5/5] updated dotnet version --- .github/workflows/sca-scan.yml | 4 ++-- global.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/sca-scan.yml b/.github/workflows/sca-scan.yml index b11e368..e7acba9 100644 --- a/.github/workflows/sca-scan.yml +++ b/.github/workflows/sca-scan.yml @@ -11,12 +11,12 @@ jobs: - name: Setup .NET Core @ Latest uses: actions/setup-dotnet@v1 with: - dotnet-version: '3.1.x' + dotnet-version: "7.0.x" - name: Run Dotnet Restore run: | dotnet restore - name: Run Snyk to check for vulnerabilities - uses: snyk/actions/dotnet@master + uses: snyk/actions/dotnet@master env: SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} with: 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" } }