Skip to main content

Create a library

POST 

/libraries

The operation allows you to create a new library. A library constitutes a collection of pre-written and reusable code components, functions, and modules that enhance software development efficiency.

Request

Header Parameters

    X-Codenow-Api-Key anyrequired

    CodeNOW API Key

Body

required

    name stringrequired

    Possible values: >= 3 characters and <= 170 characters


    Human readable name of the component.
    CodeNOW will generate an ID for the library based on this name.

    description string


    The detailed textual description of the library. Allows users to add additional context, notes, or any relevant information about the purpose, usage, or characteristics of the library.

    template

    object

    required


    Defines the template used for scaffolding the library.


    Example:


    1. List available templates at /templates/libraries endpoint and choose the one desired.

    1. Depending on the template, it may be necessary to attach required/optional properties in the request body. For example, a template property defined as:

       "properties": [
    {
    "name": "groupId",
    "description": "Base Java package",
    "type": "string",
    "required": true
    }
    ]

    is mandatory and will be used like this:


       "properties": {
    "groupId": "com.example"
    }

    1. Assemble and send final request, for example:

       {
    "name": "example-lib1",
    "description": "example-lib1",
    "scm": {
    "action": "CREATE",
    "providerId": "codenow",
    "providerType": "codenow",
    "existingRepository": false,
    "monoRepository": false,
    "spaceId": "codenow"
    },
    "template": {
    "id": "java-maven-library",
    "version": "3.1.0",
    "custom": false,
    "properties": {
    "groupId": "com.example"
    }
    }
    }
    1. Any omitted optional parameters will be replaced with default values.

    id stringrequired

    Possible values: non-empty


    An internal identifier of the scaffold selected for library creation.
    It includes information about the selected language, build tool and framework, if specified.
    Available templates can be obtained through the:
    /templates/application_components endpoint for application component or
    /templates/libraries endpoint for library

    version stringrequired

    Possible values: non-empty


    The desired version of the selected template.

    Available templates can be obtained through the:
    /templates/application_components endpoint for application component or
    /templates/libraries endpoint for library

    custom booleanrequired


    A boolean flag indicating whether the template is user-customized. If set to false, the template is provided by CodeNOW.

    Available templates can be obtained through the:
    /templates/application_components endpoint for application component or
    /templates/libraries endpoint for library

    properties

    object


    A map of properties ("key": "value") required for proper template configuration.

    Available templates can be obtained through the:
    /templates/application_components endpoint for application component or
    /templates/libraries endpoint for library

    property name* string

    scm

    object

    required


    Defines the repository in SCM.
    Supported providers/actions can be obtained through the /scm/providers endpoint.

    action ActionType (string)required

    Possible values: [CREATE, LINK]

    Default value: CREATE


    Action that will be performed on the SCM repository.
    CREATE: New SCM repository will be created for the component.
    LINK: The component will be linked to an existing SCM repository (unique ID of the repository will be required).

    providerId stringrequired

    Possible values: non-empty

    Instance ID of an existing SCM provider
    Available providers and supported actions can be obtained through the /scm/providers endpoint.

    providerType stringrequired

    Possible values: non-empty

    Type of an existing SCM provider
    Available providers and supported actions can be obtained through the /scm/providers endpoint.

    existingRepository booleanrequired

    Defines if the new component will be created in existing repository:

    • true: you must define spaceId and repositoryId of the existing repository in the request
    • false: new repository will be created for the component
    monoRepository booleanrequired

    Defines if the new component will be share repository with other components:

    • true: you must define componentPath where the component will be hosted in the repository
    • false: the component will be hosted in the root of the repository
    componentPath stringnullable

    Possible values: Value must match regular expression ^[a-zA-Z0-9\-_~/]*$

    Define path in the repository where the component will be placed.

    spaceId stringrequired

    ID of an existing SCM spaces where repository will be hosted.
    Available repositories can be obtained through the /scm/provider/{providerType}/{providerId}/spaces endpoint.

    repositoryId stringnullable

    ID of an existing SCM repository to which the component should be placed.
    Available repositories can be obtained through the /scm/provider/{providerType}/{providerId}/spaces/{spaceId}/repos endpoint.

Responses

Library detail

Schema

    id stringrequired


    The unique identifier of the library. Based on the user-defined library name.

    displayName stringrequired


    The user-friendly name or label for the library. It allows users to provide a clear and descriptive name that helps in identifying and distinguishing different libraries easily. The field accepts free text with alphanumeric and special characters.

    description string


    The detailed textual description of the library. Allows users to add additional context, notes, or any relevant information about the purpose, usage, or characteristics of the library.

    templateId stringrequired


    An internal identifier of the scaffold selected for library creation. It includes information about the selected language, build tool and framework, if specified.

    state LibraryState (string)required

    Possible values: [CREATING, READY, FAILED, DELETING]

    State of the library
    CREATING - Library is being created
    READY - Library is ready
    FAILED - Library creation failed
    DELETING - Library is being deleted

Loading...