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

6.2 Deployment #109

Merged
merged 8 commits into from
Jun 21, 2023
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
6 changes: 3 additions & 3 deletions CarbonQueryDatabase_Adapter/CRUD/Read.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ private List<EnvironmentalProductDeclaration> 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();
Expand All @@ -84,7 +84,7 @@ private List<EnvironmentalProductDeclaration> 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
Expand Down
10 changes: 5 additions & 5 deletions CarbonQueryDatabase_Adapter/CarbonQueryDatabase_Adapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,23 +41,23 @@ public partial class CarbonQueryDatabaseAdapter : BHoMAdapter
/**** Constructors ****/
/***************************************************/

[PreviousVersion("6.2", "BH.Adapter.CarbonQueryDatabaseAdapter(System.String, System.String, System.Bool)")]
[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;
}
}

/***************************************************/
/*** Private Fields ***/
/***************************************************/

private static string m_bearerToken = null;
private static string m_apiToken = null;

}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
Expand Down Expand Up @@ -125,4 +125,4 @@
<PostBuildEvent>xcopy "$(TargetDir)$(TargetFileName)" "C:\ProgramData\BHoM\Assemblies" /Y
</PostBuildEvent>
</PropertyGroup>
</Project>
</Project>
12 changes: 4 additions & 8 deletions CarbonQueryDatabase_Adapter/Convert/ToBHoM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,9 @@ public static EnvironmentalProductDeclaration ToEnvironmentalProductDeclaration(
jurisdictionNames = jurisdictionNames.Trim();
}

EnvironmentalMetric metric = new EnvironmentalMetric
{
Field = EnvironmentalProductDeclarationField.GlobalWarmingPotential,
Phases = new List<LifeCycleAssessmentPhases>() { 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
{
Expand All @@ -117,9 +114,8 @@ public static EnvironmentalProductDeclaration ToEnvironmentalProductDeclaration(
EnvironmentalProductDeclaration epd = new EnvironmentalProductDeclaration
{
Type = config.Type,
EnvironmentalMetric = new List<EnvironmentalMetric> { metric },
EnvironmentalMetrics = new List<EnvironmentalMetric> { metric },
QuantityType = quantityType,
QuantityTypeValue = 1,
Name = obj.PropertyValue("name")?.ToString() ?? "",
};

Expand Down
2 changes: 1 addition & 1 deletion CarbonQueryDatabase_Adapter/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]



16 changes: 8 additions & 8 deletions CarbonQueryDatabase_Engine/CarbonQueryDatabase_Engine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Adapter_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\Adapter_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM">
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="BHoM_Engine">
<SpecificVersion>False</SpecificVersion>
<HintPath>C:\ProgramData\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\BHoM_Engine.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="Data_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\Data_oM.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\Data_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="HTTP_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\HTTP_oM.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\HTTP_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="LifeCycleAssessment_oM">
<HintPath>C:\ProgramData\BHoM\Assemblies\LifeCycleAssessment_oM.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\LifeCycleAssessment_oM.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
<Reference Include="Reflection_Engine">
<HintPath>C:\ProgramData\BHoM\Assemblies\Reflection_Engine.dll</HintPath>
<HintPath>$(ProgramData)\BHoM\Assemblies\Reflection_Engine.dll</HintPath>
<Private>False</Private>
<SpecificVersion>False</SpecificVersion>
</Reference>
Expand All @@ -76,11 +76,11 @@
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Compute\BearerToken.cs" />
<Compile Include="Create\GetRequest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="Compute\" />
<Folder Include="Modify\" />
<Folder Include="Query\" />
</ItemGroup>
Expand Down
85 changes: 0 additions & 85 deletions CarbonQueryDatabase_Engine/Compute/BearerToken.cs

This file was deleted.

11 changes: 6 additions & 5 deletions CarbonQueryDatabase_Engine/Create/GetRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ public static partial class Create
/***************************************************/
/**** Public Method ****/
/***************************************************/

[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<string, object> param = new Dictionary<string, object>();
if(parameters.Count > 0)
Expand All @@ -50,10 +51,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<string, object>()
{
{ "Authorization", "Bearer " + bearerToken }
{ "Authorization", "Bearer " + apiToken }
},
Parameters = param
};
Expand Down
2 changes: 1 addition & 1 deletion CarbonQueryDatabase_Engine/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]



36 changes: 36 additions & 0 deletions CarbonQueryDatabase_Engine/Versioning_62.json
Original file line number Diff line number Diff line change
@@ -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": {

}
}
4 changes: 2 additions & 2 deletions CarbonQueryDatabase_Toolkit.sln
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion CarbonQueryDatabase_oM/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]