class_docstr: Sets up an Amazon SageMaker Collection.
docstr: Creates a Collection.
  
  Args:
      collection_name (str): The name of the Collection to create.
      parent_collection_name (str): The name of the parent Collection.
          Is ``None`` if the Collection is created at the root level.
docstr_tok: ["Creates","a","Collection",".","Args",":","collection_name","(","str",")",":","The","name","of","the","Collection","to","create",".","parent_collection_name","(","str",")",":","The","name","of","the","parent","Collection",".","Is","``","None","``","if","the","Collection","is","created","at","the","root","level","."]
code: def create(
      self, collection_name: str, parent_collection_name: str = None
  ):
      """Creates a Collection.
  
      Args:
          collection_name (str): The name of the Collection to create.
          parent_collection_name (str): The name of the parent Collection.
              Is ``None`` if the Collection is created at the root level.
      """
  
      tag_rule_key = (
          f"sagemaker:collection-path:{int(time.time() * 1000)}"
      )
      tags_on_collection = {
          "sagemaker:collection": "true",
          "sagemaker:collection-path:root": "true",
      }
      tag_rule_values = [collection_name]
  
      if parent_collection_name is not None:
          parent_tag_rules = self._get_collection_tag_rule(
              collection_name=parent_collection_name
          )
          parent_tag_rule_key = parent_tag_rules["tag_rule_key"]
          parent_tag_value = parent_tag_rules["tag_rule_value"]
          tags_on_collection = {
              parent_tag_rule_key: parent_tag_value,
              "sagemaker:collection": "true",
          }
          tag_rule_values = [f"{parent_tag_value}/{collection_name}"]
      try:
          resource_filters = [
              "AWS::SageMaker::ModelPackageGroup",
              "AWS::ResourceGroups::Group",
          ]
  
          tag_filters = [
              {
                  "Key": tag_rule_key,
                  "Values": tag_rule_values,
              }
          ]
          resource_query = {
              "Query": json.dumps(
                  {
                      "ResourceTypeFilters": resource_filters,
                      "TagFilters": tag_filters,
                  }
              ),
              "Type": "TAG_FILTERS_1_0",
          }
          collection_create_response = (
              self.sagemaker_session.create_group(
                  collection_name, resource_query, tags_on_collection
              )
          )
          return {
              "Name": collection_create_response["Group"]["Name"],
              "Arn": collection_create_response["Group"]["GroupArn"],
          }
      except ClientError as e:
          message = e.response["Error"]["Message"]
          error_code = e.response["Error"]["Code"]
  
          if (
              error_code == "BadRequestException"
              and "group already exists" in message
          ):
              raise ValueError(
                  "Collection with the given name already exists"
              )
          self._check_access_error(err=e)
          raise
  
imports: from __future__ import absolute_import
  import json
  import time
  from typing import List
  from botocore.exceptions import ClientError
  from sagemaker.session import Session
label_desc: Use image node_id 5 for calling the Collection obj's underlying member method code with example usage: obj.create(collection_name, parent_collection_name) and returns: dict