Skip to content

Commit a0fa0b6

Browse files
Automated Reasoning checks in Amazon Bedrock Guardrails is capable of generating policy scenarios to validate policies. The GetAutomatedReasoningPolicyBuildWorkflowResultAssets API now adds POLICY SCENARIO asset type, allowing customers to retrieve scenarios generated by the build workflow.
1 parent c454e90 commit a0fa0b6

File tree

8 files changed

+242
-13
lines changed

8 files changed

+242
-13
lines changed

generator/ServiceModels/bedrock/bedrock-2023-04-20.api.json

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2356,7 +2356,8 @@
23562356
"BUILD_LOG",
23572357
"QUALITY_REPORT",
23582358
"POLICY_DEFINITION",
2359-
"GENERATED_TEST_CASES"
2359+
"GENERATED_TEST_CASES",
2360+
"POLICY_SCENARIOS"
23602361
]
23612362
},
23622363
"AutomatedReasoningPolicyBuildResultAssets":{
@@ -2365,7 +2366,8 @@
23652366
"policyDefinition":{"shape":"AutomatedReasoningPolicyDefinition"},
23662367
"qualityReport":{"shape":"AutomatedReasoningPolicyDefinitionQualityReport"},
23672368
"buildLog":{"shape":"AutomatedReasoningPolicyBuildLog"},
2368-
"generatedTestCases":{"shape":"AutomatedReasoningPolicyGeneratedTestCases"}
2369+
"generatedTestCases":{"shape":"AutomatedReasoningPolicyGeneratedTestCases"},
2370+
"policyScenarios":{"shape":"AutomatedReasoningPolicyScenarios"}
23692371
},
23702372
"union":true
23712373
},
@@ -2858,14 +2860,14 @@
28582860
"required":[
28592861
"expression",
28602862
"alternateExpression",
2861-
"ruleIds",
2862-
"expectedResult"
2863+
"expectedResult",
2864+
"ruleIds"
28632865
],
28642866
"members":{
28652867
"expression":{"shape":"AutomatedReasoningPolicyScenarioExpression"},
28662868
"alternateExpression":{"shape":"AutomatedReasoningPolicyScenarioAlternateExpression"},
2867-
"ruleIds":{"shape":"AutomatedReasoningPolicyDefinitionRuleIdList"},
2868-
"expectedResult":{"shape":"AutomatedReasoningCheckResult"}
2869+
"expectedResult":{"shape":"AutomatedReasoningCheckResult"},
2870+
"ruleIds":{"shape":"AutomatedReasoningPolicyDefinitionRuleIdList"}
28692871
}
28702872
},
28712873
"AutomatedReasoningPolicyScenarioAlternateExpression":{
@@ -2880,6 +2882,17 @@
28802882
"min":0,
28812883
"sensitive":true
28822884
},
2885+
"AutomatedReasoningPolicyScenarioList":{
2886+
"type":"list",
2887+
"member":{"shape":"AutomatedReasoningPolicyScenario"}
2888+
},
2889+
"AutomatedReasoningPolicyScenarios":{
2890+
"type":"structure",
2891+
"required":["policyScenarios"],
2892+
"members":{
2893+
"policyScenarios":{"shape":"AutomatedReasoningPolicyScenarioList"}
2894+
}
2895+
},
28832896
"AutomatedReasoningPolicySummaries":{
28842897
"type":"list",
28852898
"member":{"shape":"AutomatedReasoningPolicySummary"},

generator/ServiceModels/bedrock/bedrock-2023-04-20.docs.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,6 +1099,7 @@
10991099
"AutomatedReasoningPolicyScenario": {
11001100
"base": "<p>Represents a test scenario used to validate an Automated Reasoning policy, including the test conditions and expected outcomes.</p>",
11011101
"refs": {
1102+
"AutomatedReasoningPolicyScenarioList$member": null,
11021103
"GetAutomatedReasoningPolicyNextScenarioResponse$scenario": "<p>The next test scenario to validate, including the test expression and expected results.</p>"
11031104
}
11041105
},
@@ -1115,6 +1116,18 @@
11151116
"AutomatedReasoningPolicyUpdateFromScenarioFeedbackAnnotation$scenarioExpression": "<p>The logical expression that defines the test scenario that generated this feedback.</p>"
11161117
}
11171118
},
1119+
"AutomatedReasoningPolicyScenarioList": {
1120+
"base": null,
1121+
"refs": {
1122+
"AutomatedReasoningPolicyScenarios$policyScenarios": "<p>Represents a collection of generated policy scenarios.</p>"
1123+
}
1124+
},
1125+
"AutomatedReasoningPolicyScenarios": {
1126+
"base": "<p>Contains a comprehensive entity encompassing all the scenarios generated by the build workflow, which can be used to validate an Automated Reasoning policy.</p>",
1127+
"refs": {
1128+
"AutomatedReasoningPolicyBuildResultAssets$policyScenarios": "<p>An entity encompassing all the policy scenarios generated by the build workflow, which can be used to validate an Automated Reasoning policy. </p>"
1129+
}
1130+
},
11181131
"AutomatedReasoningPolicySummaries": {
11191132
"base": null,
11201133
"refs": {

generator/ServiceModels/bedrock/bedrock-2023-04-20.normal.json

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,8 @@
27542754
"BUILD_LOG",
27552755
"QUALITY_REPORT",
27562756
"POLICY_DEFINITION",
2757-
"GENERATED_TEST_CASES"
2757+
"GENERATED_TEST_CASES",
2758+
"POLICY_SCENARIOS"
27582759
]
27592760
},
27602761
"AutomatedReasoningPolicyBuildResultAssets":{
@@ -2775,6 +2776,10 @@
27752776
"generatedTestCases":{
27762777
"shape":"AutomatedReasoningPolicyGeneratedTestCases",
27772778
"documentation":"<p>A comprehensive test suite generated by the build workflow, providing validation capabilities for automated reasoning policies.</p>"
2779+
},
2780+
"policyScenarios":{
2781+
"shape":"AutomatedReasoningPolicyScenarios",
2782+
"documentation":"<p>An entity encompassing all the policy scenarios generated by the build workflow, which can be used to validate an Automated Reasoning policy. </p>"
27782783
}
27792784
},
27802785
"documentation":"<p>Contains the various assets generated during a policy build workflow, including logs, quality reports, test cases, and the final policy definition.</p>",
@@ -3510,8 +3515,8 @@
35103515
"required":[
35113516
"expression",
35123517
"alternateExpression",
3513-
"ruleIds",
3514-
"expectedResult"
3518+
"expectedResult",
3519+
"ruleIds"
35153520
],
35163521
"members":{
35173522
"expression":{
@@ -3522,13 +3527,13 @@
35223527
"shape":"AutomatedReasoningPolicyScenarioAlternateExpression",
35233528
"documentation":"<p>An alternative way to express the same test scenario, used for validation and comparison purposes.</p>"
35243529
},
3525-
"ruleIds":{
3526-
"shape":"AutomatedReasoningPolicyDefinitionRuleIdList",
3527-
"documentation":"<p>The list of rule identifiers that are expected to be triggered or evaluated by this test scenario.</p>"
3528-
},
35293530
"expectedResult":{
35303531
"shape":"AutomatedReasoningCheckResult",
35313532
"documentation":"<p>The expected outcome when this scenario is evaluated against the policy (e.g., PASS, FAIL, VIOLATION).</p>"
3533+
},
3534+
"ruleIds":{
3535+
"shape":"AutomatedReasoningPolicyDefinitionRuleIdList",
3536+
"documentation":"<p>The list of rule identifiers that are expected to be triggered or evaluated by this test scenario.</p>"
35323537
}
35333538
},
35343539
"documentation":"<p>Represents a test scenario used to validate an Automated Reasoning policy, including the test conditions and expected outcomes.</p>"
@@ -3545,6 +3550,21 @@
35453550
"min":0,
35463551
"sensitive":true
35473552
},
3553+
"AutomatedReasoningPolicyScenarioList":{
3554+
"type":"list",
3555+
"member":{"shape":"AutomatedReasoningPolicyScenario"}
3556+
},
3557+
"AutomatedReasoningPolicyScenarios":{
3558+
"type":"structure",
3559+
"required":["policyScenarios"],
3560+
"members":{
3561+
"policyScenarios":{
3562+
"shape":"AutomatedReasoningPolicyScenarioList",
3563+
"documentation":"<p>Represents a collection of generated policy scenarios.</p>"
3564+
}
3565+
},
3566+
"documentation":"<p>Contains a comprehensive entity encompassing all the scenarios generated by the build workflow, which can be used to validate an Automated Reasoning policy.</p>"
3567+
},
35483568
"AutomatedReasoningPolicySummaries":{
35493569
"type":"list",
35503570
"member":{"shape":"AutomatedReasoningPolicySummary"},

sdk/src/Services/Bedrock/Generated/Model/AutomatedReasoningPolicyBuildResultAssets.cs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public partial class AutomatedReasoningPolicyBuildResultAssets
3838
private AutomatedReasoningPolicyBuildLog _buildLog;
3939
private AutomatedReasoningPolicyGeneratedTestCases _generatedTestCases;
4040
private AutomatedReasoningPolicyDefinition _policyDefinition;
41+
private AutomatedReasoningPolicyScenarios _policyScenarios;
4142
private AutomatedReasoningPolicyDefinitionQualityReport _qualityReport;
4243

4344
/// <summary>
@@ -97,6 +98,25 @@ internal bool IsSetPolicyDefinition()
9798
return this._policyDefinition != null;
9899
}
99100

101+
/// <summary>
102+
/// Gets and sets the property PolicyScenarios.
103+
/// <para>
104+
/// An entity encompassing all the policy scenarios generated by the build workflow, which
105+
/// can be used to validate an Automated Reasoning policy.
106+
/// </para>
107+
/// </summary>
108+
public AutomatedReasoningPolicyScenarios PolicyScenarios
109+
{
110+
get { return this._policyScenarios; }
111+
set { this._policyScenarios = value; }
112+
}
113+
114+
// Check to see if PolicyScenarios property is set
115+
internal bool IsSetPolicyScenarios()
116+
{
117+
return this._policyScenarios != null;
118+
}
119+
100120
/// <summary>
101121
/// Gets and sets the property QualityReport.
102122
/// <para>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the bedrock-2023-04-20.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Xml.Serialization;
22+
using System.Text;
23+
using System.IO;
24+
using System.Net;
25+
26+
using Amazon.Runtime;
27+
using Amazon.Runtime.Internal;
28+
29+
#pragma warning disable CS0612,CS0618,CS1570
30+
namespace Amazon.Bedrock.Model
31+
{
32+
/// <summary>
33+
/// Contains a comprehensive entity encompassing all the scenarios generated by the build
34+
/// workflow, which can be used to validate an Automated Reasoning policy.
35+
/// </summary>
36+
public partial class AutomatedReasoningPolicyScenarios
37+
{
38+
private List<AutomatedReasoningPolicyScenario> _policyScenarios = AWSConfigs.InitializeCollections ? new List<AutomatedReasoningPolicyScenario>() : null;
39+
40+
/// <summary>
41+
/// Gets and sets the property PolicyScenarios.
42+
/// <para>
43+
/// Represents a collection of generated policy scenarios.
44+
/// </para>
45+
/// </summary>
46+
[AWSProperty(Required=true)]
47+
public List<AutomatedReasoningPolicyScenario> PolicyScenarios
48+
{
49+
get { return this._policyScenarios; }
50+
set { this._policyScenarios = value; }
51+
}
52+
53+
// Check to see if PolicyScenarios property is set
54+
internal bool IsSetPolicyScenarios()
55+
{
56+
return this._policyScenarios != null && (this._policyScenarios.Count > 0 || !AWSConfigs.InitializeCollections);
57+
}
58+
59+
}
60+
}

sdk/src/Services/Bedrock/Generated/Model/Internal/MarshallTransformations/AutomatedReasoningPolicyBuildResultAssetsUnmarshaller.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ public AutomatedReasoningPolicyBuildResultAssets Unmarshall(JsonUnmarshallerCont
8484
unmarshalledObject.PolicyDefinition = unmarshaller.Unmarshall(context);
8585
continue;
8686
}
87+
if (context.TestExpression("policyScenarios", targetDepth))
88+
{
89+
var unmarshaller = AutomatedReasoningPolicyScenariosUnmarshaller.Instance;
90+
unmarshalledObject.PolicyScenarios = unmarshaller.Unmarshall(context);
91+
continue;
92+
}
8793
if (context.TestExpression("qualityReport", targetDepth))
8894
{
8995
var unmarshaller = AutomatedReasoningPolicyDefinitionQualityReportUnmarshaller.Instance;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
/*
17+
* Do not modify this file. This file is generated from the bedrock-2023-04-20.normal.json service model.
18+
*/
19+
using System;
20+
using System.Collections.Generic;
21+
using System.Globalization;
22+
using System.IO;
23+
using System.Net;
24+
using System.Text;
25+
using System.Xml.Serialization;
26+
27+
using Amazon.Bedrock.Model;
28+
using Amazon.Runtime;
29+
using Amazon.Runtime.Internal;
30+
using Amazon.Runtime.Internal.Transform;
31+
using Amazon.Runtime.Internal.Util;
32+
using ThirdParty.Json.LitJson;
33+
34+
#pragma warning disable CS0612,CS0618
35+
namespace Amazon.Bedrock.Model.Internal.MarshallTransformations
36+
{
37+
/// <summary>
38+
/// Response Unmarshaller for AutomatedReasoningPolicyScenarios Object
39+
/// </summary>
40+
public class AutomatedReasoningPolicyScenariosUnmarshaller : IUnmarshaller<AutomatedReasoningPolicyScenarios, XmlUnmarshallerContext>, IUnmarshaller<AutomatedReasoningPolicyScenarios, JsonUnmarshallerContext>
41+
{
42+
/// <summary>
43+
/// Unmarshaller the response from the service to the response class.
44+
/// </summary>
45+
/// <param name="context"></param>
46+
/// <returns></returns>
47+
AutomatedReasoningPolicyScenarios IUnmarshaller<AutomatedReasoningPolicyScenarios, XmlUnmarshallerContext>.Unmarshall(XmlUnmarshallerContext context)
48+
{
49+
throw new NotImplementedException();
50+
}
51+
52+
/// <summary>
53+
/// Unmarshaller the response from the service to the response class.
54+
/// </summary>
55+
/// <param name="context"></param>
56+
/// <returns>The unmarshalled object</returns>
57+
public AutomatedReasoningPolicyScenarios Unmarshall(JsonUnmarshallerContext context)
58+
{
59+
AutomatedReasoningPolicyScenarios unmarshalledObject = new AutomatedReasoningPolicyScenarios();
60+
if (context.IsEmptyResponse)
61+
return null;
62+
context.Read();
63+
if (context.CurrentTokenType == JsonToken.Null)
64+
return null;
65+
66+
int targetDepth = context.CurrentDepth;
67+
while (context.ReadAtDepth(targetDepth))
68+
{
69+
if (context.TestExpression("policyScenarios", targetDepth))
70+
{
71+
var unmarshaller = new ListUnmarshaller<AutomatedReasoningPolicyScenario, AutomatedReasoningPolicyScenarioUnmarshaller>(AutomatedReasoningPolicyScenarioUnmarshaller.Instance);
72+
unmarshalledObject.PolicyScenarios = unmarshaller.Unmarshall(context);
73+
continue;
74+
}
75+
}
76+
return unmarshalledObject;
77+
}
78+
79+
80+
private static AutomatedReasoningPolicyScenariosUnmarshaller _instance = new AutomatedReasoningPolicyScenariosUnmarshaller();
81+
82+
/// <summary>
83+
/// Gets the singleton.
84+
/// </summary>
85+
public static AutomatedReasoningPolicyScenariosUnmarshaller Instance
86+
{
87+
get
88+
{
89+
return _instance;
90+
}
91+
}
92+
}
93+
}

sdk/src/Services/Bedrock/Generated/ServiceEnumerations.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -533,6 +533,10 @@ public class AutomatedReasoningPolicyBuildResultAssetType : ConstantClass
533533
/// </summary>
534534
public static readonly AutomatedReasoningPolicyBuildResultAssetType POLICY_DEFINITION = new AutomatedReasoningPolicyBuildResultAssetType("POLICY_DEFINITION");
535535
/// <summary>
536+
/// Constant POLICY_SCENARIOS for AutomatedReasoningPolicyBuildResultAssetType
537+
/// </summary>
538+
public static readonly AutomatedReasoningPolicyBuildResultAssetType POLICY_SCENARIOS = new AutomatedReasoningPolicyBuildResultAssetType("POLICY_SCENARIOS");
539+
/// <summary>
536540
/// Constant QUALITY_REPORT for AutomatedReasoningPolicyBuildResultAssetType
537541
/// </summary>
538542
public static readonly AutomatedReasoningPolicyBuildResultAssetType QUALITY_REPORT = new AutomatedReasoningPolicyBuildResultAssetType("QUALITY_REPORT");

0 commit comments

Comments
 (0)