From 35270f9c50cbd9b1bd03943430f085acae1d5e3a Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Tue, 28 Mar 2023 15:24:38 +0100 Subject: [PATCH 1/8] Upgrade AssemblyFileVersion to 6.2.0.0 --- CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs | 2 +- CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs | 2 +- CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs b/CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs index af12ba1..8e8ecb8 100644 --- a/CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs +++ b/CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs @@ -55,7 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.1.0.0")] +[assembly: AssemblyFileVersion("6.2.0.0")] diff --git a/CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs b/CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs index 5a2593f..836902c 100644 --- a/CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs +++ b/CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs @@ -55,7 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.1.0.0")] +[assembly: AssemblyFileVersion("6.2.0.0")] diff --git a/CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs b/CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs index 20649bb..d3fedd4 100644 --- a/CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs +++ b/CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs @@ -55,7 +55,7 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("6.0.0.0")] -[assembly: AssemblyFileVersion("6.1.0.0")] +[assembly: AssemblyFileVersion("6.2.0.0")] From 46c132bd272bfc166a6a5da3ff69f0b915559890 Mon Sep 17 00:00:00 2001 From: Isak Naslund Date: Tue, 23 May 2023 08:21:16 +0200 Subject: [PATCH 2/8] Update convert method to compile with changes to LCA_oM --- CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs b/CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs index 68d2302..a2bbd5a 100644 --- a/CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs +++ b/CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs @@ -87,12 +87,9 @@ public static EnvironmentalProductDeclaration ToEnvironmentalProductDeclaration( jurisdictionNames = jurisdictionNames.Trim(); } - EnvironmentalMetric metric = new EnvironmentalMetric - { - Field = EnvironmentalProductDeclarationField.GlobalWarmingPotential, - Phases = new List() { LifeCycleAssessmentPhases.A1, LifeCycleAssessmentPhases.A2, LifeCycleAssessmentPhases.A3}, - Quantity = gwpVal, - }; + double nan = double.NaN; + + ClimateChangeTotalMetric metric = new ClimateChangeTotalMetric(nan, nan, nan, gwpVal, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan, nan); AdditionalEPDData data = new AdditionalEPDData { @@ -117,9 +114,8 @@ public static EnvironmentalProductDeclaration ToEnvironmentalProductDeclaration( EnvironmentalProductDeclaration epd = new EnvironmentalProductDeclaration { Type = config.Type, - EnvironmentalMetric = new List { metric }, + EnvironmentalMetrics = new List { metric }, QuantityType = quantityType, - QuantityTypeValue = 1, Name = obj.PropertyValue("name")?.ToString() ?? "", }; From 012b5087cc376d3821db3a7f5aa4f671b5aad430 Mon Sep 17 00:00:00 2001 From: Michael Hoehn Date: Thu, 8 Jun 2023 14:19:14 -0400 Subject: [PATCH 3/8] switch auth methods to api token and updated all api call urls --- CarbonQueryDatabase_Adapter/CRUD/Read.cs | 6 +++--- .../CarbonQueryDatabase_Adapter.cs | 10 +++++----- .../CarbonQueryDatabase_Adapter.csproj | 4 ++-- .../CarbonQueryDatabase_Engine.csproj | 6 +++--- .../Compute/{BearerToken.cs => APIToken.cs} | 15 ++++++++------- CarbonQueryDatabase_Engine/Create/GetRequest.cs | 12 +++++++----- CarbonQueryDatabase_Toolkit.sln | 4 ++-- 7 files changed, 30 insertions(+), 27 deletions(-) rename CarbonQueryDatabase_Engine/Compute/{BearerToken.cs => APIToken.cs} (83%) diff --git a/CarbonQueryDatabase_Adapter/CRUD/Read.cs b/CarbonQueryDatabase_Adapter/CRUD/Read.cs index 780d125..76959e8 100644 --- a/CarbonQueryDatabase_Adapter/CRUD/Read.cs +++ b/CarbonQueryDatabase_Adapter/CRUD/Read.cs @@ -71,11 +71,11 @@ private List ReadEnvironmentalProductDeclaratio GetRequest epdGetRequest; if (id == null) { - epdGetRequest = BH.Engine.Adapters.CarbonQueryDatabase.Create.CarbonQueryDatabaseRequest("epds", m_bearerToken, config); + epdGetRequest = BH.Engine.Adapters.CarbonQueryDatabase.Create.CarbonQueryDatabaseRequest("epds", m_apiToken, config); } else { - epdGetRequest = BH.Engine.Adapters.CarbonQueryDatabase.Create.CarbonQueryDatabaseRequest("epds/" + id, m_bearerToken, config); + epdGetRequest = BH.Engine.Adapters.CarbonQueryDatabase.Create.CarbonQueryDatabaseRequest("epds/" + id, m_apiToken, config); } string reqString = epdGetRequest.ToUrlString(); @@ -84,7 +84,7 @@ private List ReadEnvironmentalProductDeclaratio if (response == null) { - BH.Engine.Base.Compute.RecordWarning("No response received, check bearer token and connection."); + BH.Engine.Base.Compute.RecordWarning("No response received, API token and connection."); return null; } //Check if the response is a valid json diff --git a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs index 619ad77..3dd1027 100644 --- a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs +++ b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs @@ -41,15 +41,15 @@ public partial class CarbonQueryDatabaseAdapter : BHoMAdapter /**** Constructors ****/ /***************************************************/ + [PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabase(string username = \"\", string password = \"\", bool active = false)")] [Description("Adapter to connect to CarbonQueryDatabase.")] - [Input("username", "Provide EC3 Username")] - [Input("password", "Provide EC3 Password")] + [Input("apiToken", "Provide EC3 API Token")] [Output("adapter", "Adapter results")] - public CarbonQueryDatabaseAdapter(string username = "", string password = "", bool active = false) + public CarbonQueryDatabaseAdapter(string apiToken = "", bool active = false) { if (active) { - m_bearerToken = Compute.CQDBearerToken(username, password); + m_apiToken = apiToken; } } @@ -57,7 +57,7 @@ public CarbonQueryDatabaseAdapter(string username = "", string password = "", bo /*** Private Fields ***/ /***************************************************/ - private static string m_bearerToken = null; + private static string m_apiToken = null; } } diff --git a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.csproj b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.csproj index 9e9649f..75d4bab 100644 --- a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.csproj +++ b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.csproj @@ -1,4 +1,4 @@ - + @@ -125,4 +125,4 @@ xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y - + \ No newline at end of file diff --git a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj index 3fcc743..534f253 100644 --- a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj +++ b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj @@ -1,4 +1,4 @@ - + @@ -76,7 +76,7 @@ - + @@ -103,4 +103,4 @@ --> - + \ No newline at end of file diff --git a/CarbonQueryDatabase_Engine/Compute/BearerToken.cs b/CarbonQueryDatabase_Engine/Compute/APIToken.cs similarity index 83% rename from CarbonQueryDatabase_Engine/Compute/BearerToken.cs rename to CarbonQueryDatabase_Engine/Compute/APIToken.cs index 909353e..3406535 100644 --- a/CarbonQueryDatabase_Engine/Compute/BearerToken.cs +++ b/CarbonQueryDatabase_Engine/Compute/APIToken.cs @@ -34,15 +34,16 @@ namespace BH.Engine.Adapters.CarbonQueryDatabase { public static partial class Compute { - [Description("Returns a bearer token for the CarbonQueryDatabase system from the provided username and password")] + [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CQDBearerToken(string username = \"\", string password = \"\")")] + [Description("Returns a temporary, session-based APItoken for the CarbonQueryDatabase system from the provided username and password")] [Input("username", "Your username for the system")] [Input("password", "Your password for the system - case sensitive, do not share scripts with this saved")] - [Output("bearerToken", "The bearer token to use the database system or the full response string if there was an error")] - public static string CQDBearerToken(string username, string password) + [Output("APIToken", "The bearer token to use the database system or the full response string if there was an error")] + public static string APIToken(string username, string password) { - string apiAddress = "https://etl-api.cqd.io/api/rest-auth/login"; - - System.Net.ServicePointManager.SecurityProtocol = + string apiAddress = "https://buildingtransparency.org/api/rest-auth/login"; + + System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | @@ -53,7 +54,7 @@ public static string CQDBearerToken(string username, string password) //Add headers per api auth requirements client.DefaultRequestHeaders.Add("accept", "application/json"); - //Post login auth request and return token to m_bearerKey + //Post login auth request and return token to m_APIToken HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, apiAddress); string loginString = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}"; diff --git a/CarbonQueryDatabase_Engine/Create/GetRequest.cs b/CarbonQueryDatabase_Engine/Create/GetRequest.cs index a72b96e..e805c23 100644 --- a/CarbonQueryDatabase_Engine/Create/GetRequest.cs +++ b/CarbonQueryDatabase_Engine/Create/GetRequest.cs @@ -34,12 +34,14 @@ public static partial class Create /***************************************************/ /**** Public Method ****/ /***************************************************/ + + [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CarbonQuery(string username = \"\", string password = \"\"), BH.oM.Adapters.CarbonQueryDatabase.CQDConfig parameters = null")] [Description("Create a GetRequest for the CarbonQueryDatabase")] - [Input("apiCommand", "The CarbonQueryDatabase REST API command to create a GetRequest with")] - [Input("bearerToken", "The CarbonQueryDatabase bearerToken (this can be acquired using Compute BearerToken with your EC3 username and password)")] + [Input("apiCommand", "The CarbonQueryDatabase API command to create a GetRequest with")] + [Input("apiToken", "The user's CarbonQueryDatabase APIToken")] [Input("parameters", "An optional config object with properties representing parameters to create the GetRequest with (ie count, name_like, etc)")] [Output("GetRequest", "A GetRequest with CarbonQueryDatabase specific headers and uri")] - public static GetRequest CarbonQueryDatabaseRequest(string apiCommand, string bearerToken, CQDConfig parameters = null) + public static GetRequest CarbonQueryDatabaseRequest(string apiCommand, string apiToken, CQDConfig parameters = null) { Dictionary param = new Dictionary(); if(parameters.Count > 0) @@ -50,10 +52,10 @@ public static GetRequest CarbonQueryDatabaseRequest(string apiCommand, string be return new BH.oM.Adapters.HTTP.GetRequest { - BaseUrl = "https://etl-api.cqd.io/api/" + apiCommand, + BaseUrl = "https://buildingtransparency.org/api/" + apiCommand, Headers = new Dictionary() { - { "Authorization", "Bearer " + bearerToken } + { "Authorization", "Bearer " + apiToken } }, Parameters = param }; diff --git a/CarbonQueryDatabase_Toolkit.sln b/CarbonQueryDatabase_Toolkit.sln index e7642e0..3917977 100644 --- a/CarbonQueryDatabase_Toolkit.sln +++ b/CarbonQueryDatabase_Toolkit.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Express 14 for Windows Desktop -VisualStudioVersion = 14.0.25420.1 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.33627.172 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CarbonQueryDatabase_Adapter", "CarbonQueryDatabase_Adapter\CarbonQueryDatabase_Adapter.csproj", "{C265DA93-8AAB-4B9A-865B-2AA764EB291F}" ProjectSection(ProjectDependencies) = postProject From 8fe623a9b496a6461199976453f02fa8cf930efb Mon Sep 17 00:00:00 2001 From: Michael Hoehn Date: Thu, 8 Jun 2023 14:44:00 -0400 Subject: [PATCH 4/8] Apply suggestions from code review Co-authored-by: Fraser Greenroyd --- CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs | 2 +- CarbonQueryDatabase_Engine/Compute/APIToken.cs | 2 +- CarbonQueryDatabase_Engine/Create/GetRequest.cs | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs index 3dd1027..6847eb6 100644 --- a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs +++ b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs @@ -41,7 +41,7 @@ public partial class CarbonQueryDatabaseAdapter : BHoMAdapter /**** Constructors ****/ /***************************************************/ - [PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabase(string username = \"\", string password = \"\", bool active = false)")] + [PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabase(System.String, System.String, System.Bool)")] [Description("Adapter to connect to CarbonQueryDatabase.")] [Input("apiToken", "Provide EC3 API Token")] [Output("adapter", "Adapter results")] diff --git a/CarbonQueryDatabase_Engine/Compute/APIToken.cs b/CarbonQueryDatabase_Engine/Compute/APIToken.cs index 3406535..dcb1ce2 100644 --- a/CarbonQueryDatabase_Engine/Compute/APIToken.cs +++ b/CarbonQueryDatabase_Engine/Compute/APIToken.cs @@ -34,7 +34,7 @@ namespace BH.Engine.Adapters.CarbonQueryDatabase { public static partial class Compute { - [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CQDBearerToken(string username = \"\", string password = \"\")")] + [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CQDBearerToken(System.String, System.String)")] [Description("Returns a temporary, session-based APItoken for the CarbonQueryDatabase system from the provided username and password")] [Input("username", "Your username for the system")] [Input("password", "Your password for the system - case sensitive, do not share scripts with this saved")] diff --git a/CarbonQueryDatabase_Engine/Create/GetRequest.cs b/CarbonQueryDatabase_Engine/Create/GetRequest.cs index e805c23..c9d614c 100644 --- a/CarbonQueryDatabase_Engine/Create/GetRequest.cs +++ b/CarbonQueryDatabase_Engine/Create/GetRequest.cs @@ -35,7 +35,6 @@ public static partial class Create /**** Public Method ****/ /***************************************************/ - [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CarbonQuery(string username = \"\", string password = \"\"), BH.oM.Adapters.CarbonQueryDatabase.CQDConfig parameters = null")] [Description("Create a GetRequest for the CarbonQueryDatabase")] [Input("apiCommand", "The CarbonQueryDatabase API command to create a GetRequest with")] [Input("apiToken", "The user's CarbonQueryDatabase APIToken")] From 06802cdd4e496ed911ef87dfe1e16b720b80aca0 Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 8 Jun 2023 20:31:39 +0100 Subject: [PATCH 5/8] Update CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs --- CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs index 6847eb6..8621409 100644 --- a/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs +++ b/CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs @@ -41,7 +41,7 @@ public partial class CarbonQueryDatabaseAdapter : BHoMAdapter /**** Constructors ****/ /***************************************************/ - [PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabase(System.String, System.String, System.Bool)")] + [PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabaseAdapter(System.String, System.String, System.Bool)")] [Description("Adapter to connect to CarbonQueryDatabase.")] [Input("apiToken", "Provide EC3 API Token")] [Output("adapter", "Adapter results")] From 3bc52e27708c1094fb976c8abfed7866103a5ec5 Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Thu, 8 Jun 2023 20:31:46 +0100 Subject: [PATCH 6/8] Update CarbonQueryDatabase_Engine/Compute/APIToken.cs --- CarbonQueryDatabase_Engine/Compute/APIToken.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CarbonQueryDatabase_Engine/Compute/APIToken.cs b/CarbonQueryDatabase_Engine/Compute/APIToken.cs index dcb1ce2..e94fe7b 100644 --- a/CarbonQueryDatabase_Engine/Compute/APIToken.cs +++ b/CarbonQueryDatabase_Engine/Compute/APIToken.cs @@ -34,7 +34,7 @@ namespace BH.Engine.Adapters.CarbonQueryDatabase { public static partial class Compute { - [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.CQDBearerToken(System.String, System.String)")] + [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.Compute.CQDBearerToken(System.String, System.String)")] [Description("Returns a temporary, session-based APItoken for the CarbonQueryDatabase system from the provided username and password")] [Input("username", "Your username for the system")] [Input("password", "Your password for the system - case sensitive, do not share scripts with this saved")] From 845ed39a8efc452d2b503510d24daeec27cd9adb Mon Sep 17 00:00:00 2001 From: Fraser Greenroyd Date: Fri, 16 Jun 2023 14:14:22 +0100 Subject: [PATCH 7/8] Remove API Token method for Security --- .../CarbonQueryDatabase_Engine.csproj | 2 +- .../Compute/APIToken.cs | 86 ------------------- CarbonQueryDatabase_Engine/Versioning_62.json | 36 ++++++++ 3 files changed, 37 insertions(+), 87 deletions(-) delete mode 100644 CarbonQueryDatabase_Engine/Compute/APIToken.cs create mode 100644 CarbonQueryDatabase_Engine/Versioning_62.json diff --git a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj index 534f253..a000ccd 100644 --- a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj +++ b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj @@ -76,11 +76,11 @@ - + diff --git a/CarbonQueryDatabase_Engine/Compute/APIToken.cs b/CarbonQueryDatabase_Engine/Compute/APIToken.cs deleted file mode 100644 index e94fe7b..0000000 --- a/CarbonQueryDatabase_Engine/Compute/APIToken.cs +++ /dev/null @@ -1,86 +0,0 @@ -/* - * This file is part of the Buildings and Habitats object Model (BHoM) - * Copyright (c) 2015 - 2023, the respective contributors. All rights reserved. - * - * Each contributor holds copyright over their respective contributions. - * The project versioning (Git) records all such contribution source information. - * - * - * The BHoM is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License as published by - * the Free Software Foundation, either version 3.0 of the License, or - * (at your option) any later version. - * - * The BHoM is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this code. If not, see . - */ - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Net; -using System.Net.Http; -using System.ComponentModel; -using BH.oM.Base.Attributes; - -namespace BH.Engine.Adapters.CarbonQueryDatabase -{ - public static partial class Compute - { - [PreviousVersion("6.2", "BH.Engine.Adapters.CarbonQueryDatabase.Compute.CQDBearerToken(System.String, System.String)")] - [Description("Returns a temporary, session-based APItoken for the CarbonQueryDatabase system from the provided username and password")] - [Input("username", "Your username for the system")] - [Input("password", "Your password for the system - case sensitive, do not share scripts with this saved")] - [Output("APIToken", "The bearer token to use the database system or the full response string if there was an error")] - public static string APIToken(string username, string password) - { - string apiAddress = "https://buildingtransparency.org/api/rest-auth/login"; - - System.Net.ServicePointManager.SecurityProtocol = - SecurityProtocolType.Ssl3 | - SecurityProtocolType.Tls12 | - SecurityProtocolType.Tls11 | - SecurityProtocolType.Tls; - - HttpClient client = new HttpClient(); - - //Add headers per api auth requirements - client.DefaultRequestHeaders.Add("accept", "application/json"); - - //Post login auth request and return token to m_APIToken - HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, apiAddress); - - string loginString = "{\"username\":\"" + username + "\",\"password\":\"" + password + "\"}"; - request.Content = new StringContent(loginString, Encoding.UTF8, "application/json"); - - HttpResponseMessage response = client.SendAsync(request).Result; - if (response.IsSuccessStatusCode) - { - - string responseAuthString = response.Content.ReadAsStringAsync().Result; - if (responseAuthString.Split('"').Length >= 3) - return responseAuthString.Split('"')[3]; - else - { - BH.Engine.Base.Compute.RecordError("We did not receive the response we expected. The response was '" + responseAuthString + "'"); - return null; - } - } - else - { - BH.Engine.Base.Compute.RecordError("Request failed with code '" + response.StatusCode.ToString() + "'. Please check credentials and try again."); - return null; - } - } - } -} - - - diff --git a/CarbonQueryDatabase_Engine/Versioning_62.json b/CarbonQueryDatabase_Engine/Versioning_62.json new file mode 100644 index 0000000..090e47f --- /dev/null +++ b/CarbonQueryDatabase_Engine/Versioning_62.json @@ -0,0 +1,36 @@ +{ + "Namespace": { + "ToNew": { + }, + "ToOld": { + } + }, + "Type": { + "ToNew": { + + }, + "ToOld": { + + } + }, + "Method": { + "ToNew": { + + }, + "ToOld": { + } + }, + "Property": { + "ToNew": { + + }, + "ToOld": { + + } + }, + "MessageForDeleted": { + "BH.Engine.Adapters.CarbonQueryDatabase.Compute.CQDBearerToken(System.String, System.String)" : "This method has been removed following a refactor to utilise API keys rather than usernames and passwords for security purposes. Please obtain an API key from the provider and plug that into the Adapter to use this toolkit.",}, + "MessageForNoUpgrade": { + + } +} \ No newline at end of file From ee7cae12eea8f56c4afcde15f621bd4e03d36bb5 Mon Sep 17 00:00:00 2001 From: BHoMBot Date: Fri, 16 Jun 2023 14:17:05 +0100 Subject: [PATCH 8/8] Update project compliance --- .../CarbonQueryDatabase_Engine.csproj | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj index a000ccd..27a1033 100644 --- a/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj +++ b/CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj @@ -1,4 +1,4 @@ - + @@ -32,37 +32,37 @@ - C:\ProgramData\BHoM\Assemblies\Adapter_oM.dll + $(ProgramData)\BHoM\Assemblies\Adapter_oM.dll False False - C:\ProgramData\BHoM\Assemblies\BHoM.dll + $(ProgramData)\BHoM\Assemblies\BHoM.dll False False False - C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll + $(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll False - C:\ProgramData\BHoM\Assemblies\Data_oM.dll + $(ProgramData)\BHoM\Assemblies\Data_oM.dll False False - C:\ProgramData\BHoM\Assemblies\HTTP_oM.dll + $(ProgramData)\BHoM\Assemblies\HTTP_oM.dll False False - C:\ProgramData\BHoM\Assemblies\LifeCycleAssessment_oM.dll + $(ProgramData)\BHoM\Assemblies\LifeCycleAssessment_oM.dll False False - C:\ProgramData\BHoM\Assemblies\Reflection_Engine.dll + $(ProgramData)\BHoM\Assemblies\Reflection_Engine.dll False False @@ -103,4 +103,4 @@ --> - \ No newline at end of file +