def create_from_yaml(
        k8s_client,
        yaml_file,
        verbose=False,
        **kwargs):
    """
    Perform an action from a yaml file. Pass True for verbose to
    print confirmation information.
    Input:
    yaml_file: string. Contains the path to yaml file.
    k8s_client: an ApiClient object, initialized with the client args.
    verbose: If True, print confirmation from the create action.
        Default is False.

    Returns:
    An k8s api object or list of apis objects created from YAML.
    When a single object is generated, return type is dependent
    on output_list.

    Throws a FailToCreateError exception if creation of any object
    fails with helpful messages from the server.

    Available parameters for creating <kind>:
    :param async_req bool
    :param bool include_uninitialized: If true, partially initialized
        resources are included in the response.
    :param str pretty: If 'true', then the output is pretty printed.
    :param str dry_run: When present, indicates that modifications
        should not be persisted. An invalid or unrecognized dryRun
        directive will result in an error response and no further
        processing of the request.
        Valid values are: - All: all dry run stages will be processed
    """

    with open(path.abspath(yaml_file)) as f:
        yml_document_all = yaml.safe_load_all(f)
        api_exceptions = []
        # Load all documents from a single YAML file
        for yml_document in yml_document_all:
            # If it is a list type, will need to iterate its items
            if "List" in yml_document["kind"]:
                # Could be "List" or "Pod/Service/...List"
                # This is a list type. iterate within its items
                kind = yml_document["kind"].replace("List", "")
                for yml_object in yml_document["items"]:
                    # Mitigate cases when server returns a xxxList object
                    # See kubernetes-client/python#586
                    if kind is not "":
                        yml_object["apiVersion"] = yml_document["apiVersion"]
                        yml_object["kind"] = kind
                    try:
                        create_from_yaml_single_item(
                            k8s_client, yml_object, verbose, **kwargs)
                    except client.rest.ApiException as api_exception:
                        api_exceptions.append(api_exception)
            else:
                # This is a single object. Call the single item method
                try:
                    create_from_yaml_single_item(
                        k8s_client, yml_document, verbose, **kwargs)
                except client.rest.ApiException as api_exception:
                    api_exceptions.append(api_exception)
    # In case we have exceptions waiting for us, raise them
    if api_exceptions:
        raise FailToCreateError(api_exceptions)
def create_from_yaml ( k8s_client , yaml_file , verbose = False , ** kwargs ) : with open ( path . abspath ( yaml_file ) ) as f : yml_document_all = yaml . safe_load_all ( f ) api_exceptions = [ ] for yml_document in yml_document_all : if "List" in yml_document [ "kind" ] : kind = yml_document [ "kind" ] . replace ( "List" , "" ) for yml_object in yml_document [ "items" ] : if kind is not "" : yml_object [ "apiVersion" ] = yml_document [ "apiVersion" ] yml_object [ "kind" ] = kind try : create_from_yaml_single_item ( k8s_client , yml_object , verbose , ** kwargs ) except client . rest . ApiException as api_exception : api_exceptions . append ( api_exception ) else : try : create_from_yaml_single_item ( k8s_client , yml_document , verbose , ** kwargs ) except client . rest . ApiException as api_exception : api_exceptions . append ( api_exception ) if api_exceptions : raise FailToCreateError ( api_exceptions )
Perform an action from a yaml file. Pass True for verbose to
    print confirmation information.
    Input:
    yaml_file: string. Contains the path to yaml file.
    k8s_client: an ApiClient object, initialized with the client args.
    verbose: If True, print confirmation from the create action.
        Default is False.

    Returns:
    An k8s api object or list of apis objects created from YAML.
    When a single object is generated, return type is dependent
    on output_list.

    Throws a FailToCreateError exception if creation of any object
    fails with helpful messages from the server.

    Available parameters for creating <kind>:
    :param async_req bool
    :param bool include_uninitialized: If true, partially initialized
        resources are included in the response.
    :param str pretty: If 'true', then the output is pretty printed.
    :param str dry_run: When present, indicates that modifications
        should not be persisted. An invalid or unrecognized dryRun
        directive will result in an error response and no further
        processing of the request.
        Valid values are: - All: all dry run stages will be processed