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

Restoring spaces graph endpoint #3094

Merged
merged 15 commits into from
Feb 4, 2022

Conversation

kobergj
Copy link
Collaborator

@kobergj kobergj commented Feb 2, 2022

Description

Restore spaces by sending to the Patch Drive Graph endpoint. Get information when a drive is deleted (Check it's root for "deleted" flag)

Short example for space restore/delete

Step 1: Find spaceID

curl -k https://localhost:9200/graph/v1.0/me/drives -u admin:admin 
...
{
      "driveType": "project",
      "id": "db589b97-f2ea-4864-bf5f-55a43325f77a",
      "lastModifiedDateTime": "2022-02-04T09:07:45.824270628+01:00",
      "name": "Project PUPPELE",
      "owner": {
        "user": {
          "id": "ddc2004c-0977-11eb-9d3f-a793888cd0f8"
        }
      },
      "quota": {
        "remaining": 1000000000,
        "state": "normal",
        "total": 1000000000,
        "used": 0
      },
      "root": {
        "id": "db589b97-f2ea-4864-bf5f-55a43325f77a",
        "webDavUrl": "https://localhost:9200/dav/spaces/db589b97-f2ea-4864-bf5f-55a43325f77a"
      }
}
...

Step 2: Disable the space

curl -X DELETE -k https://localhost:9200/graph/v1.0/drives/db589b97-f2ea-4864-bf5f-55a43325f77a -u admin:admin

Note that response on GET endpoint changes. It contains information that the drive is trashed. Calling curl from Step1 would return:

 {
      "driveType": "project",
      "id": "db589b97-f2ea-4864-bf5f-55a43325f77a",
      "lastModifiedDateTime": "2022-02-04T09:07:45.824270628+01:00",
      "name": "Project PUPPELE",
      "owner": {
        "user": {
          "id": "ddc2004c-0977-11eb-9d3f-a793888cd0f8"
        }
      },
      "quota": {
        "remaining": 1000000000,
        "state": "normal",
        "total": 1000000000,
        "used": 0
      },
      "root": {
        "deleted": {
          "state": "trashed"
        },
        "id": "db589b97-f2ea-4864-bf5f-55a43325f77a",
        "webDavUrl": "https://localhost:9200/dav/spaces/db589b97-f2ea-4864-bf5f-55a43325f77a"
      }
}

Step 3a: Restore the space

This will restore the space and everything will be like before

curl -X PATCH -k https://localhost:9200/graph/v1.0/drives/db589b97-f2ea-4864-bf5f-55a43325f77a -u admin:admin -H "restore: true" -d '{}'

Step 3b: Delete the space

This will remove the space completely

curl -X DELETE -k https://localhost:9200/graph/v1.0/drives/db589b97-f2ea-4864-bf5f-55a43325f77a -u admin:admin -H "purge: true"

Note that delete and purge requests now use the same URL, just a different header. Purging an enabled space will still not work. Step 2 is mandatory.

@ownclouders
Copy link
Contributor

ownclouders commented Feb 2, 2022

💥 Acceptance test Core-API-Tests-ocis-storage-1 failed. Further test are cancelled...

@kobergj kobergj force-pushed the RestoringSpacesGraphEndpoint branch from 133023f to 2da43f3 Compare February 2, 2022 18:51
Signed-off-by: jkoberg <[email protected]>
Signed-off-by: jkoberg <[email protected]>
@kobergj kobergj force-pushed the RestoringSpacesGraphEndpoint branch from a9ac051 to 3596f7a Compare February 3, 2022 11:03
Signed-off-by: jkoberg <[email protected]>
@kobergj kobergj force-pushed the RestoringSpacesGraphEndpoint branch from 3596f7a to 19006fe Compare February 3, 2022 11:35
Signed-off-by: jkoberg <[email protected]>
@kobergj kobergj marked this pull request as ready for review February 4, 2022 09:52
Copy link
Contributor

@micbar micbar left a comment

Choose a reason for hiding this comment

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

LGTM

@micbar
Copy link
Contributor

micbar commented Feb 4, 2022

@kobergj can you move the description into the top post please? That makes it easier in the future.

Signed-off-by: jkoberg <[email protected]>
@kobergj kobergj force-pushed the RestoringSpacesGraphEndpoint branch from 61336b3 to 63f052a Compare February 4, 2022 11:13
@sonarcloud
Copy link

sonarcloud bot commented Feb 4, 2022

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

7.1% 7.1% Coverage
0.0% 0.0% Duplication

@kobergj kobergj merged commit 559abd9 into owncloud:master Feb 4, 2022
@kobergj kobergj deleted the RestoringSpacesGraphEndpoint branch February 4, 2022 12:45
ownclouders pushed a commit that referenced this pull request Feb 4, 2022
Author: kobergj <[email protected]>
Date:   Fri Feb 4 13:45:37 2022 +0100

    Restoring spaces graph endpoint (#3094)

    * restore drive & trashed information

    Signed-off-by: jkoberg <[email protected]>

    * TEMP: use feature branch reva

    Signed-off-by: jkoberg <[email protected]>

    * add changelog

    Signed-off-by: jkoberg <[email protected]>

    * TEMP: update reva version

    Signed-off-by: jkoberg <[email protected]>

    * go back to edge reva

    Signed-off-by: jkoberg <[email protected]>

    * use latest edge

    Signed-off-by: jkoberg <[email protected]>

    * back to feature reva

    Signed-off-by: jkoberg <[email protected]>

    * bump reva again

    Signed-off-by: jkoberg <[email protected]>

    * update expected failures

    Signed-off-by: jkoberg <[email protected]>

    * next reva bump

    Signed-off-by: jkoberg <[email protected]>

    * use edge reva

    Signed-off-by: jkoberg <[email protected]>

    * next reva change

    Signed-off-by: jkoberg <[email protected]>

    * use reva edge again (please go green)

    Signed-off-by: jkoberg <[email protected]>

    * remove expected failure as it passes now

    Signed-off-by: jkoberg <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants