:doc:`CloudDirectory <../../clouddirectory>` / Client / create_facet

************
create_facet
************



.. py:method:: CloudDirectory.Client.create_facet(**kwargs)

  

  Creates a new  Facet in a schema. Facet creation is allowed only in development or applied schemas.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/clouddirectory-2017-01-11/CreateFacet>`_  


  **Request Syntax**
  ::

    response = client.create_facet(
        SchemaArn='string',
        Name='string',
        Attributes=[
            {
                'Name': 'string',
                'AttributeDefinition': {
                    'Type': 'STRING'|'BINARY'|'BOOLEAN'|'NUMBER'|'DATETIME'|'VARIANT',
                    'DefaultValue': {
                        'StringValue': 'string',
                        'BinaryValue': b'bytes',
                        'BooleanValue': True|False,
                        'NumberValue': 'string',
                        'DatetimeValue': datetime(2015, 1, 1)
                    },
                    'IsImmutable': True|False,
                    'Rules': {
                        'string': {
                            'Type': 'BINARY_LENGTH'|'NUMBER_COMPARISON'|'STRING_FROM_SET'|'STRING_LENGTH',
                            'Parameters': {
                                'string': 'string'
                            }
                        }
                    }
                },
                'AttributeReference': {
                    'TargetFacetName': 'string',
                    'TargetAttributeName': 'string'
                },
                'RequiredBehavior': 'REQUIRED_ALWAYS'|'NOT_REQUIRED'
            },
        ],
        ObjectType='NODE'|'LEAF_NODE'|'POLICY'|'INDEX',
        FacetStyle='STATIC'|'DYNAMIC'
    )
    
  :type SchemaArn: string
  :param SchemaArn: **[REQUIRED]** 

    The schema ARN in which the new  Facet will be created. For more information, see  arns.

    

  
  :type Name: string
  :param Name: **[REQUIRED]** 

    The name of the  Facet, which is unique for a given schema.

    

  
  :type Attributes: list
  :param Attributes: 

    The attributes that are associated with the  Facet.

    

  
    - *(dict) --* 

      An attribute that is associated with the  Facet.

      

    
      - **Name** *(string) --* **[REQUIRED]** 

        The name of the facet attribute.

        

      
      - **AttributeDefinition** *(dict) --* 

        A facet attribute consists of either a definition or a reference. This structure contains the attribute definition. See `Attribute References <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html>`__ for more information.

        

      
        - **Type** *(string) --* **[REQUIRED]** 

          The type of the attribute.

          

        
        - **DefaultValue** *(dict) --* 

          The default value of the attribute (if configured).

          

        
          - **StringValue** *(string) --* 

            A string data value.

            

          
          - **BinaryValue** *(bytes) --* 

            A binary data value.

            

          
          - **BooleanValue** *(boolean) --* 

            A Boolean data value.

            

          
          - **NumberValue** *(string) --* 

            A number data value.

            

          
          - **DatetimeValue** *(datetime) --* 

            A date and time value.

            

          
        
        - **IsImmutable** *(boolean) --* 

          Whether the attribute is mutable or not.

          

        
        - **Rules** *(dict) --* 

          Validation rules attached to the attribute definition.

          

        
          - *(string) --* 

          
            - *(dict) --* 

              Contains an Amazon Resource Name (ARN) and parameters that are associated with the rule.

              

            
              - **Type** *(string) --* 

                The type of attribute validation rule.

                

              
              - **Parameters** *(dict) --* 

                The minimum and maximum parameters that are associated with the rule.

                

              
                - *(string) --* 

                
                  - *(string) --* 

                  
            
          
            
      
    
      
      - **AttributeReference** *(dict) --* 

        An attribute reference that is associated with the attribute. See `Attribute References <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html>`__ for more information.

        

      
        - **TargetFacetName** *(string) --* **[REQUIRED]** 

          The target facet name that is associated with the facet reference. See `Attribute References <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html>`__ for more information.

          

        
        - **TargetAttributeName** *(string) --* **[REQUIRED]** 

          The target attribute name that is associated with the facet reference. See `Attribute References <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/schemas_attributereferences.html>`__ for more information.

          

        
      
      - **RequiredBehavior** *(string) --* 

        The required behavior of the ``FacetAttribute``.

        

      
    

  :type ObjectType: string
  :param ObjectType: 

    Specifies whether a given object created from this facet is of type node, leaf node, policy or index.

     

    
    * Node: Can have multiple children but one parent.
    

     

    
    * Leaf node: Cannot have children but can have multiple parents.
    

     

    
    * Policy: Allows you to store a policy document and policy type. For more information, see `Policies <https://docs.aws.amazon.com/clouddirectory/latest/developerguide/key_concepts_directory.html#key_concepts_policies>`__.
    

     

    
    * Index: Can be created with the Index API.
    

    

  
  :type FacetStyle: string
  :param FacetStyle: 

    There are two different styles that you can define on any given facet, ``Static`` and ``Dynamic``. For static facets, all attributes must be defined in the schema. For dynamic facets, attributes can be defined during data plane operations.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {}
      
    **Response Structure**

    

    - *(dict) --* 
  
  **Exceptions**
  
  *   :py:class:`CloudDirectory.Client.exceptions.InternalServiceException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.InvalidArnException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.RetryableConflictException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.ValidationException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.LimitExceededException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.AccessDeniedException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.ResourceNotFoundException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.FacetAlreadyExistsException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.InvalidRuleException`

  
  *   :py:class:`CloudDirectory.Client.exceptions.FacetValidationException`

  