Pull projects from a project space

POST https://{controlplane_path}/api/1/rest/public/project/git-pull/projects/{project_space_path}      

Overview

Updates each Git-linked project in the specified project space with the latest files from its associated Git repository.

Important: This API currently supports GitHub only.

The API processes each project in the space as follows:

  • Projects that are not linked to a Git repository are skipped.
  • Linked projects with no new commit are skipped.
  • Linked projects with a new commit but no file changes have only their last-commit metadata updated.
  • Linked projects with changes have those changes applied.

Optionally, you can limit the operation to a specified subset of projects in the project space.

Note:
  • You can track a maximum of 1000 assets per project. If a check-in would exceed 1000 assets in the repository or if you try to check out a project with more than 1000 assets, an error is thrown.
  • You must use the Project Manager UI or Git tools to commit changes to your repository.

Prerequisites

  • Write access to the assets to be added or updated

Limitations

  • You cannot use SnapLogic service accounts to call any of the SnapLogic Git operation APIs.

Request

 POST https://{controlplane_path}/api/1/rest/public/project/git-pull/projects/{project_space_path}

Path parameters

Key Description
controlplane_path Required. The path to the SnapLogic control plane: elastic.snaplogic.com
For the UAT or EMEA control plane, substitute the name for elastic. For example:
  • uat.elastic.snaplogic.com
  • emea.snaplogic.com
project_space_path Required. The path to the project space, in the format {org}/{project_space}.

Query parameters

None.

Request header

Basic authentication

To use basic authentication, specify Basic for authorization in the request header, add your credentials (email and password for your SnapLogic user or service account), and specify application/json for content type. For example:


Authorization: Basic {base64_encoded <email>:<password>}
Content-Type: application/json
          

Example of basic authentication using Postman:

Learn more about the basic authentication header in REST API requests.

JWT authentication

When using JWT authentication, the API request includes specific headers. In the request header, specify Bearer Token for authorization, add the token, and specify application/json for content type. These headers are automatically added when you configure bearer token authentication in your API client. The authorization header contains the word Bearer followed by a space and your JWT.


Authorization: Bearer Token {token}
Content-Type: application/json
          

Example of JWT authentication using Postman:

Request body


{
  "project_path_list": ["myorg/myspace/project1", "myorg/myspace/project2"],
  "use_theirs": ["65e12ed44f526dee5878a380"],
  "use_ours": ["65e12ed482f42d881560dfca"]
}
        
Key Type Description
project_path_list array Optional. An array of project paths to pull. If omitted or empty, the API pulls all linked projects in the project space.
use_theirs array Optional. An array of asset IDs for assets in the local projects to overwrite with the versions from the repository. To retrieve asset IDs, use Retrieve the Status of the Git Repository.
use_ours array Optional. An array of asset IDs for assets in the local projects to keep unchanged, ignoring the corresponding updates from the repository.

Response

The response contains one entry per project in the project space. Each entry is either a pull result object or a string indicating the project was skipped.


{
  "response_map": {
    "myorg/myspace/project1": {
      "status": "updated",
      "overwritten": [],
      "updated": ["pipeline1.slp"],
      "created": [],
      "deleted": [],
      "ignored": [],
      "error_msgs": []
    },
    "myorg/myspace/project2": {
      "status": "up-to-date"
    },
    "myorg/myspace/project3": "Skipped: Project is not connected to a Git repository."
  },
  "http_status_code": 200
}
        
Key Type Description
project_path object or string The result for each project. An object with status, overwritten, updated, created, deleted, ignored, and error_msgs fields if the pull was attempted, or a string starting with "Skipped:" if the project was not linked to a repository or encountered an error.

Example

This example uses Basic authentication. For a JWT example, refer to Authentication.

curl -X POST \
  'https://elastic.snaplogic.com/api/1/rest/public/project/git-pull/projects/acme/MySpace' \
  -H 'Authorization: Basic {base64_encoded email:password}' \
  -H 'Content-Type: application/json' \
  -d '{
    "project_path_list": ["acme/MySpace/project1", "acme/MySpace/project2"]
  }'