Skip to content

Commit

Permalink
GetEnvironmentVariable support for Secret datatype
Browse files Browse the repository at this point in the history
  • Loading branch information
drivardxrm committed Jan 22, 2022
1 parent 150a297 commit 9b2b65c
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 13 deletions.
11 changes: 8 additions & 3 deletions Driv.CustomApis.Code/API/GetEnvironmentVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public void Execute(LocalPluginContext localcontext)
{
case environmentvariabledefinition_type.Boolean:

outputparameters["ValueBool"] = overridenvalue != null ?
overridenvalue.Value == "yes" :
definition.DefaultValue == "yes";
outputparameters["ValueBool"] = overridenvalue != null ?
overridenvalue.Value == "yes" :
definition.DefaultValue == "yes";
break;

case environmentvariabledefinition_type.Number:
Expand All @@ -63,6 +63,11 @@ public void Execute(LocalPluginContext localcontext)
decimal.Parse(definition.DefaultValue);

break;
case environmentvariabledefinition_type.Secret:
var secretresponse = service.GetEnvironmentVariableSecretValue(key);
outputparameters["ValueSecret"] = secretresponse.EnvironmentVariableSecretValue;

break;

}
}
Expand Down
94 changes: 94 additions & 0 deletions Driv.CustomApis.Code/Entities/XrmContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,15 @@ public enum sharepointdocumentlocation_locationtype
DedicatedforOneNoteIntegration = 1,
}

[System.Runtime.Serialization.DataContractAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public enum onlinemeetingtype
{

[System.Runtime.Serialization.EnumMemberAttribute()]
TeamsMeeting = 1,
}

[System.Runtime.Serialization.DataContractAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public enum activitypointer_deliveryprioritycode
Expand All @@ -671,6 +680,33 @@ public enum activitypointer_deliveryprioritycode
High = 2,
}

[System.Runtime.Serialization.DataContractAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public enum msdyn_numberofsearchresults
{

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_10 = 0,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_15 = 1,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_20 = 2,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_25 = 3,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_30 = 4,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_40 = 5,

[System.Runtime.Serialization.EnumMemberAttribute()]
Number_50 = 6,
}

[System.Runtime.Serialization.DataContractAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public enum connectortype
Expand Down Expand Up @@ -12044,4 +12080,62 @@ public System.Linq.IQueryable<Driv.CustomApis.UserSettings> UserSettingsSet
}
}
}

[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.RequestProxyAttribute("RetrieveEnvironmentVariableSecretValue")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public partial class RetrieveEnvironmentVariableSecretValueRequest : Microsoft.Xrm.Sdk.OrganizationRequest
{

public string EnvironmentVariableName
{
get
{
if (this.Parameters.Contains("EnvironmentVariableName"))
{
return ((string)(this.Parameters["EnvironmentVariableName"]));
}
else
{
return default(string);
}
}
set
{
this.Parameters["EnvironmentVariableName"] = value;
}
}

public RetrieveEnvironmentVariableSecretValueRequest()
{
this.RequestName = "RetrieveEnvironmentVariableSecretValue";
this.EnvironmentVariableName = default(string);
}
}

[System.Runtime.Serialization.DataContractAttribute(Namespace="http://schemas.microsoft.com/xrm/2011/new/")]
[Microsoft.Xrm.Sdk.Client.ResponseProxyAttribute("RetrieveEnvironmentVariableSecretValue")]
[System.CodeDom.Compiler.GeneratedCodeAttribute("CrmSvcUtil", "9.1.0.67")]
public partial class RetrieveEnvironmentVariableSecretValueResponse : Microsoft.Xrm.Sdk.OrganizationResponse
{

public RetrieveEnvironmentVariableSecretValueResponse()
{
}

public string EnvironmentVariableSecretValue
{
get
{
if (this.Results.Contains("EnvironmentVariableSecretValue"))
{
return ((string)(this.Results["EnvironmentVariableSecretValue"]));
}
else
{
return default(string);
}
}
}
}
}
13 changes: 12 additions & 1 deletion Driv.CustomApis.Code/Helpers/EnvironmentVariableHelper.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using Microsoft.Xrm.Sdk;
using System.Linq;

namespace Driv.CustomApis.Helpers
{
Expand All @@ -10,5 +11,15 @@ public static EnvironmentVariableDefinition GetEnvironmentVariableDefinition(thi
public static EnvironmentVariableValue GetEnvironmentVariableValue(this XrmContext xrmcontext, EnvironmentVariableDefinition definition)
=> xrmcontext.EnvironmentVariableValueSet.SingleOrDefault(v => v.EnvironmentVariableDefinitionId != null &&
v.EnvironmentVariableDefinitionId.Id == definition.Id);

public static RetrieveEnvironmentVariableSecretValueResponse GetEnvironmentVariableSecretValue(this IOrganizationService service, string key)
{
var request = new RetrieveEnvironmentVariableSecretValueRequest
{
EnvironmentVariableName = key
};
return (RetrieveEnvironmentVariableSecretValueResponse)service.Execute(request);
}

}
}
2 changes: 1 addition & 1 deletion Driv.CustomApis.Entities/spkl.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

{
"entities": "environmentvariabledefinition,environmentvariablevalue,systemuser,timezonedefinition,usersettings,settingdefinition,organizationsetting,appsetting,appmodule",
"actions": "",
"actions": "RetrieveEnvironmentVariableSecretValue",
"generateOptionsetEnums": true,
"generateGlobalOptionsets": true,
"generateStateEnums": true,
Expand Down
2 changes: 1 addition & 1 deletion Driv.CustomApis.Solution/Solution/Other/Solution.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ImportExportXml version="9.2.21113.126" SolutionPackageVersion="9.2" languagecode="1033" generatedBy="CrmLive" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ImportExportXml version="9.2.21122.140" SolutionPackageVersion="9.2" languagecode="1033" generatedBy="CrmLive" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SolutionManifest>
<UniqueName>DataverseCustomApis</UniqueName>
<LocalizedNames>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<customapiresponseproperty uniquename="ValueDecimal">
<description default="Environment variable when type is Decimal">
<label description="Environment variable when type is Decimal" languagecode="1033" />
<description default="Value when type is Decimal">
<label description="Value when type is Decimal" languagecode="1033" />
</description>
<displayname default="GetEnvironmentVariable-Out-ValueDecimal">
<label description="GetEnvironmentVariable-Out-ValueDecimal" languagecode="1033" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<customapiresponseproperty uniquename="ValueSecret">
<description default="Secret Value from Key Vault">
<label description="Secret Value from Key Vault" languagecode="1033" />
</description>
<displayname default="GetEnvironmentVariable-Out-ValueSecret">
<label description="GetEnvironmentVariable-Out-ValueSecret" languagecode="1033" />
</displayname>
<iscustomizable>1</iscustomizable>
<name>GetEnvironmentVariable-Out-ValueSecret</name>
<type>10</type>
</customapiresponseproperty>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<ImportExportXml version="9.2.21113.126" SolutionPackageVersion="9.2" languagecode="1033" generatedBy="CrmLive" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ImportExportXml version="9.2.21122.140" SolutionPackageVersion="9.2" languagecode="1033" generatedBy="CrmLive" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SolutionManifest>
<UniqueName>DataverseCustomApis</UniqueName>
<LocalizedNames>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<customapiresponseproperty uniquename="ValueDecimal">
<description default="Environment variable when type is Decimal">
<label description="Environment variable when type is Decimal" languagecode="1033" />
<description default="Value when type is Decimal">
<label description="Value when type is Decimal" languagecode="1033" />
</description>
<displayname default="GetEnvironmentVariable-Out-ValueDecimal">
<label description="GetEnvironmentVariable-Out-ValueDecimal" languagecode="1033" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<customapiresponseproperty uniquename="ValueSecret">
<description default="Secret Value from Key Vault">
<label description="Secret Value from Key Vault" languagecode="1033" />
</description>
<displayname default="GetEnvironmentVariable-Out-ValueSecret">
<label description="GetEnvironmentVariable-Out-ValueSecret" languagecode="1033" />
</displayname>
<iscustomizable>1</iscustomizable>
<name>GetEnvironmentVariable-Out-ValueSecret</name>
<type>10</type>
</customapiresponseproperty>
4 changes: 2 additions & 2 deletions Driv.CustomApis.Solution/packages.config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.CrmSdk.CoreTools" version="9.1.0.64" targetFramework="net40" />
<package id="spkl" version="1.0.440" targetFramework="net40" />
<package id="Microsoft.CrmSdk.CoreTools" version="9.1.0.92" targetFramework="net40" />
<package id="spkl" version="1.0.640" targetFramework="net40" />
</packages>

0 comments on commit 9b2b65c

Please sign in to comment.