Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API: add location create endpoint #368

Merged
merged 1 commit into from
Jun 8, 2018
Merged

Conversation

sevein
Copy link
Member

@sevein sevein commented Jun 1, 2018

Add new POST /api/v2/location/ endpoint to enable creation of Location
instances given a known space and pipeline. The following is an example on how
it could be used:

Find a pipeline:

curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/pipeline/" | \
            jq -r ".objects | .[0] | .resource_uri"
/api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/

Find a space:

curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/space/" | \
            jq -r ".objects | .[0] | .resource_uri"
/api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/

Create new location:

curl -s -d '{
    "pipeline": ["/api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/"],
    "purpose": "TS",
    "relative_path": "automated-workflow/foo/bar",
    "description": "automated workflow",
    "space": "/api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/"
}' \
    -X POST \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/location/" | \
            jq -r ".resource_uri"
/api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/

Inspect location:

curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/" | jq
{
  "description": "automated workflow",
  "enabled": true,
  "path": "/automated-workflow/foo/bar",
  "pipeline": [
    "/api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/"
  ],
  "purpose": "TS",
  "quota": null,
  "relative_path": "automated-workflow/foo/bar",
  "resource_uri": "/api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/",
  "space": "/api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/",
  "used": "0",
  "uuid": "693f8fa4-744a-4c8f-9e1f-275d422e3bad"
}

This is connected to #367.

@sevein sevein added this to the 0.12.0 milestone Jun 1, 2018
@sevein sevein self-assigned this Jun 1, 2018
@sevein sevein requested review from ross-spencer and jrwdunham June 1, 2018 08:58
Copy link
Contributor

@jrwdunham jrwdunham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Confirmed that it works as advertised in the PR description.

@jrwdunham
Copy link
Contributor

jrwdunham commented Jun 5, 2018

@sevein should merging this PR also involve adding to https://wiki.archivematica.org/Storage_Service_API? (This touches on the issue 369 which PR 370 aims to solve, but that's not ready so it's not entirely relevant yet.)

Add new `POST /api/v2/location/` endpoint to enable creation of Location
instances given a known space and pipeline. The following is an example on how
it could be used:

Find a pipeline:

```shell
curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/pipeline/" | \
            jq -r ".objects | .[0] | .resource_uri"
```

    /api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/

Find a space:

```shell
curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/space/" | \
            jq -r ".objects | .[0] | .resource_uri"
```

    /api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/

Create new location:

```shell
curl -s -d '{
    "pipeline": ["/api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/"],
    "purpose": "TS",
    "relative_path": "automated-workflow/foo/bar",
    "description": "automated workflow",
    "space": "/api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/"
}' \
    -X POST \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/location/" | \
            jq -r ".resource_uri"
```

    /api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/

Inspect location:

```shell
curl -s \
    -H "Authorization: ApiKey test:test" \
    -H "Content-Type: application/json" \
        "http://127.0.0.1:62081/api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/" | jq
```

```json
{
  "description": "automated workflow",
  "enabled": true,
  "path": "/automated-workflow/foo/bar",
  "pipeline": [
    "/api/v2/pipeline/90707555-244f-47af-8271-66496a6a965b/"
  ],
  "purpose": "TS",
  "quota": null,
  "relative_path": "automated-workflow/foo/bar",
  "resource_uri": "/api/v2/location/693f8fa4-744a-4c8f-9e1f-275d422e3bad/",
  "space": "/api/v2/space/141593ff-2a27-44a1-9de1-917573fa0f4a/",
  "used": "0",
  "uuid": "693f8fa4-744a-4c8f-9e1f-275d422e3bad"
}
```

This closes #367.
@qubot qubot force-pushed the dev/issue-367-api-location-create branch from 3737682 to 9f813d7 Compare June 8, 2018 17:38
@qubot qubot merged commit 9f813d7 into qa/0.x Jun 8, 2018
@qubot qubot deleted the dev/issue-367-api-location-create branch June 8, 2018 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants