createPatchBaseline method

Future<CreatePatchBaselineResult> createPatchBaseline({
  1. required String name,
  2. PatchRuleGroup? approvalRules,
  3. List<String>? approvedPatches,
  4. PatchComplianceLevel? approvedPatchesComplianceLevel,
  5. bool? approvedPatchesEnableNonSecurity,
  6. String? clientToken,
  7. String? description,
  8. PatchFilterGroup? globalFilters,
  9. OperatingSystem? operatingSystem,
  10. List<String>? rejectedPatches,
  11. PatchAction? rejectedPatchesAction,
  12. List<PatchSource>? sources,
  13. List<Tag>? tags,
})

Creates a patch baseline.

May throw IdempotentParameterMismatch. May throw ResourceLimitExceededException. May throw InternalServerError.

Parameter name : The name of the patch baseline.

Parameter approvalRules : A set of rules used to include patches in the baseline.

Parameter approvedPatches : A list of explicitly approved patches for the baseline.

For information about accepted formats for lists of approved patches and rejected patches, see About package name formats for approved and rejected patch lists in the AWS Systems Manager User Guide.

Parameter approvedPatchesComplianceLevel : Defines the compliance level for approved patches. This means that if an approved patch is reported as missing, this is the severity of the compliance violation. The default value is UNSPECIFIED.

Parameter approvedPatchesEnableNonSecurity : Indicates whether the list of approved patches includes non-security updates that should be applied to the instances. The default value is 'false'. Applies to Linux instances only.

Parameter clientToken : User-provided idempotency token.

Parameter description : A description of the patch baseline.

Parameter globalFilters : A set of global filters used to include patches in the baseline.

Parameter operatingSystem : Defines the operating system the patch baseline applies to. The Default value is WINDOWS.

Parameter rejectedPatches : A list of explicitly rejected patches for the baseline.

For information about accepted formats for lists of approved patches and rejected patches, see About package name formats for approved and rejected patch lists in the AWS Systems Manager User Guide.

Parameter rejectedPatchesAction : The action for Patch Manager to take on patches included in the RejectedPackages list.

  • ALLOW_AS_DEPENDENCY: A package in the Rejected patches list is installed only if it is a dependency of another package. It is considered compliant with the patch baseline, and its status is reported as InstalledOther. This is the default action if no option is specified.
  • BLOCK: Packages in the RejectedPatches list, and packages that include them as dependencies, are not installed under any circumstances. If a package was installed before it was added to the Rejected patches list, it is considered non-compliant with the patch baseline, and its status is reported as InstalledRejected.

Parameter sources : Information about the patches to use to update the instances, including target operating systems and source repositories. Applies to Linux instances only.

Parameter tags : Optional metadata that you assign to a resource. Tags enable you to categorize a resource in different ways, such as by purpose, owner, or environment. For example, you might want to tag a patch baseline to identify the severity level of patches it specifies and the operating system family it applies to. In this case, you could specify the following key name/value pairs:

  • Key=PatchSeverity,Value=Critical
  • Key=OS,Value=Windows

Implementation

Future<CreatePatchBaselineResult> createPatchBaseline({
  required String name,
  PatchRuleGroup? approvalRules,
  List<String>? approvedPatches,
  PatchComplianceLevel? approvedPatchesComplianceLevel,
  bool? approvedPatchesEnableNonSecurity,
  String? clientToken,
  String? description,
  PatchFilterGroup? globalFilters,
  OperatingSystem? operatingSystem,
  List<String>? rejectedPatches,
  PatchAction? rejectedPatchesAction,
  List<PatchSource>? sources,
  List<Tag>? tags,
}) async {
  ArgumentError.checkNotNull(name, 'name');
  _s.validateStringLength(
    'name',
    name,
    3,
    128,
    isRequired: true,
  );
  _s.validateStringLength(
    'clientToken',
    clientToken,
    1,
    64,
  );
  _s.validateStringLength(
    'description',
    description,
    1,
    1024,
  );
  final headers = <String, String>{
    'Content-Type': 'application/x-amz-json-1.1',
    'X-Amz-Target': 'AmazonSSM.CreatePatchBaseline'
  };
  final jsonResponse = await _protocol.send(
    method: 'POST',
    requestUri: '/',
    exceptionFnMap: _exceptionFns,
    // TODO queryParams
    headers: headers,
    payload: {
      'Name': name,
      if (approvalRules != null) 'ApprovalRules': approvalRules,
      if (approvedPatches != null) 'ApprovedPatches': approvedPatches,
      if (approvedPatchesComplianceLevel != null)
        'ApprovedPatchesComplianceLevel':
            approvedPatchesComplianceLevel.toValue(),
      if (approvedPatchesEnableNonSecurity != null)
        'ApprovedPatchesEnableNonSecurity': approvedPatchesEnableNonSecurity,
      'ClientToken': clientToken ?? _s.generateIdempotencyToken(),
      if (description != null) 'Description': description,
      if (globalFilters != null) 'GlobalFilters': globalFilters,
      if (operatingSystem != null)
        'OperatingSystem': operatingSystem.toValue(),
      if (rejectedPatches != null) 'RejectedPatches': rejectedPatches,
      if (rejectedPatchesAction != null)
        'RejectedPatchesAction': rejectedPatchesAction.toValue(),
      if (sources != null) 'Sources': sources,
      if (tags != null) 'Tags': tags,
    },
  );

  return CreatePatchBaselineResult.fromJson(jsonResponse.body);
}