From c5a9df872734208c10709237a259bdfd36f340e7 Mon Sep 17 00:00:00 2001 From: Sven Dowideit Date: Wed, 19 Aug 2015 22:36:31 +1000 Subject: [PATCH] Add more curl examples Signed-off-by: Sven Dowideit --- api/dtr_1_3_accounts.md | 6 ++-- api/dtr_1_3_repositories.md | 8 ++--- api/dtr_1_3_team_repo_access.md | 16 +++++++++ api/dtr_1_3_team_repo_namespace_access.md | 19 ++++++++++- api/dtr_1_3_teams.md | 40 +++++++++++++++++++++-- api/dtr_1_3_user_repo_access.md | 12 ++++--- 6 files changed, 87 insertions(+), 14 deletions(-) diff --git a/api/dtr_1_3_accounts.md b/api/dtr_1_3_accounts.md index 1fe5e0310d..82d7df32e4 100755 --- a/api/dtr_1_3_accounts.md +++ b/api/dtr_1_3_accounts.md @@ -300,7 +300,7 @@ Client must be authenticated as a system 'admin' user. `POST /api/v0/accounts/{name}/changePassword` -```curl +```bash curl -v --user admin:password -X POST --data '{"newPassword":"qwerty!@"}' --insecure --header "Content-type: application/json" https://dtr.domain.com/api/v0/accounts/alice/changePassword ``` @@ -345,7 +345,7 @@ which case the `oldPassword` field may be omitted from the request body. `PUT /api/v0/accounts/{name}/activate` -```curl +```bash curl -v --user admin:password -X PUT --insecure https://dtr.domain.com/api/v0/accounts/alice/activate ``` @@ -381,7 +381,7 @@ Client must be authenticated as a system 'admin' user. `PUT /api/v0/accounts/{name}/deactivate` -```curl +```bash curl -v --user admin:password -X PUT --insecure https://dtr.domain.com/api/v0/accounts/alice/deactivate ``` diff --git a/api/dtr_1_3_repositories.md b/api/dtr_1_3_repositories.md index 6d2228e089..5ec6996786 100755 --- a/api/dtr_1_3_repositories.md +++ b/api/dtr_1_3_repositories.md @@ -13,7 +13,7 @@ parent = "smn_dtrapi" `GET /api/v0/repositories/{namespace}` -```curl +```bash $ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/repositories/engineering ``` @@ -58,7 +58,7 @@ filtered to only those repositories that are visible to the client. `GET /api/v0/repositories/{namespace}/{reponame}` -```curl +```bash $ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/repositories/engineering/public-app ``` @@ -89,7 +89,7 @@ Client must be authenticated as a user which has visibility to the repository. `POST /api/v0/repositories/{namespace}` -```curl +```bash $ curl -v --user admin:password --insecure -X POST --data '{"name":"my-app"}' --header "Content-type: application/json" https://dtr.domain.com/api/v0/repositories/engineering ``` @@ -139,7 +139,7 @@ level access to the organization's namespace of repositories). `PATCH /api/v0/repositories/{namespace}/{reponame}` -```curl +```bash $ curl -v --user admin:password --insecure -X PATCH --data '{"shortDescription":"slightly out of date"}' --header "Content-type: application /json" https://192.168.18.129/api/v0/repositories/engineering/public-app ``` diff --git a/api/dtr_1_3_team_repo_access.md b/api/dtr_1_3_team_repo_access.md index 65d2086a82..5f505149a5 100755 --- a/api/dtr_1_3_team_repo_access.md +++ b/api/dtr_1_3_team_repo_access.md @@ -31,6 +31,10 @@ or `admin` level access to any repository that is owned by that organization. `GET /api/v0/repositories/{namespace}/{reponame}/teamAccess` +```bash +$ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/repositories/engineering/public-app/teamAccess +``` + Example Response: ```json @@ -85,6 +89,10 @@ repository. `GET /api/v0/accounts/{name}/teams/{teamname}/repositoryAccess` +```bash +$ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/accounts/engineering/teams/dev/repositoryAccess +``` + Example Response: ```json @@ -142,6 +150,10 @@ in or be a member of that team. `PUT /api/v0/repositories/{namespace}/{reponame}/teamAccess/{teamname}` +```bash +$ curl -v --user admin:password --insecure -X PUT --header "Content-type: application/json" --data '{"accessLevel":"read-write"}' https://dtr.domain.com/api/v0/repositories/engineering/public-app/teamAccess/dev +``` + Example Request: ```http @@ -194,6 +206,10 @@ repository. `DELETE /api/v0/repositories/{namespace}/{reponame}/teamAccess/{teamname}` +```bash +$ curl -v --user admin:password --insecure -X DELETE https://dtr.domain.com/api/v0/repositories/engineering/public-app/teamAccess/dev +``` + **Authorization** Client must be authenticated as a user which has 'admin' level access to the diff --git a/api/dtr_1_3_team_repo_namespace_access.md b/api/dtr_1_3_team_repo_namespace_access.md index 40331c0b5a..5b3c5d43ae 100755 --- a/api/dtr_1_3_team_repo_namespace_access.md +++ b/api/dtr_1_3_team_repo_namespace_access.md @@ -40,6 +40,10 @@ by that organization. `GET /api/v0/repositoryNamespaces/{namespace}/teamAccess` +```bash +$ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/repositoriesNamespaces/engineering/teamAccess +``` + Example Response: ```json @@ -83,12 +87,17 @@ namespace. - *400* the namespace is not owned by an organization. - *403* the client is not authorized. +- *404* - *200* success. ## Get a Team's Granted Access to an Organization-Owned Namespace of Repositories `GET /api/v0/repositoryNamespaces/{namespace}/teamAccess/{teamname}` +```bash +$ curl -v --user admin:password --insecure -X GET https://dtr.domain.com/api/v0/repositoryNamespaces/engineering/teamAccess/lead +``` + Example Response: ```json @@ -125,6 +134,10 @@ is a member of the team in question. `PUT /api/v0/repositoryNamespaces/{namespace}/teamAccess/{teamname}` +```bash +curl -v --user admin:password --insecure -X PUT --header "Content-type: application/json" --data '{"accessLevel":"admin"}' https://dtr.domain.com/api/v0/repositoryNamespaces/engineering/teamAccess/lead +``` + Example Request: ```http @@ -172,6 +185,10 @@ namespace. `DELETE /api/v0/repositoryNamespaces/{namespace}/teamAccess/{teamname}` +```bash +$ curl -v --user admin:password --insecure -X DELETE https://dtr.domain.com/api/v0/repositoryNamespaces/engineering/teamAccess/lead +``` + **Authorization** Client must be authenticated as a user which has 'admin' level access to the @@ -179,7 +196,7 @@ namespace. **Status Codes** -- *400* the repository is not owned by an organiztion. +- *400* the repository is not owned by an organization. - *400* the team does not belong to the owning organization. - *403* the client is not authorized. - *200* success. diff --git a/api/dtr_1_3_teams.md b/api/dtr_1_3_teams.md index df683408cb..3492f6bd83 100755 --- a/api/dtr_1_3_teams.md +++ b/api/dtr_1_3_teams.md @@ -15,6 +15,10 @@ DTR Teams, like on the Docker Hub, only exist within an Organization. `GET /api/v0/accounts/{name}/teams` +```bash +$ curl --insecure -v --user admin:password https://dtr.domain.com/api/v0/accounts/engineering/teams +``` + Example Response: ```json @@ -52,6 +56,10 @@ Client must be authenticated as a member of the organization. `GET /api/v0/accounts/{name}/teams/{teamname}` +```bash +$ curl --insecure -v --user admin:password https://dtr.domain.com/api/v0/accounts/engineering/teams/qa +``` + Example Response: ```json @@ -78,6 +86,10 @@ Client must be authenticated as a member of the organization. `GET /api/v0/accounts/{name}/teams/{teamname}/members` +```bash +$ curl --insecure -v --user admin:password https://dtr.domain.com/api/v0/accounts/engineering/teams/qa/members +``` + Example Response: ```json @@ -126,6 +138,10 @@ in the organization, or a member of the team in question. `GET /api/v0/accounts/{name}/teams/{teamname}/members/{member}` +```bash +$ curl --insecure -v --user admin:password -X GET https://dtr.domain.com/api/v0/accounts/engineering/teams/qa/members/test +``` + **Authorization** Client must be authenticated as a user which has visibility into the team @@ -141,6 +157,10 @@ Client must be authenticated as a user which has visibility into the team `POST /api/v0/accounts/{name}/teams` +```bash +$ curl --insecure -v --user admin:password -X POST --data '{"name": "qa", "type": "managed"}' --header "Content-type: application/json" https://dtr.domain.com/api/v0/accounts/engineering/teams +``` + Example Request: ```http @@ -185,6 +205,10 @@ team in the organization. `PATCH /api/v0/accounts/{name}/teams/{teamname}` +```bash +$ curl --insecure -v --user admin:password -X PATCH --data '{"description":"add one"}' --header "Content-type: application/json" https://dtr.domain.com/api/v0/accounts/engineering/teams/qa +``` + Example Request: ```http @@ -228,6 +252,10 @@ team in the organization. `PUT /api/v0/accounts/{name}/teams/{teamname}/members/{member}` +```bash +$ curl --insecure -v --user admin:password -X PUT https://dtr.domain.com/api/v0/accounts/engineering/teams/qa/members/alice +``` + **Authorization** Client must be authenticated as a system admin or a member of the "owners" @@ -236,13 +264,17 @@ team in the organization. **Status Codes** - *403* the client is not authorized. -- *404* no such team exists. +- *404* no such team or user. - *200* success. ## Remove a User from a Team (if not LDAP synced). `DELETE /api/v0/accounts/{name}/teams/{teamname}/members/{member}` +```bash +$ curl --insecure -v --user admin:password -X DELETE https://dtr.domain.com/api/v0/accounts/engineering/teams/qa/members/alice +``` + **Authorization** Client must be authenticated as a system admin or a member of the "owners" @@ -252,12 +284,16 @@ team in the organization. - *403* the client is not authorized. - *404* no such team exists. -- *200* success. +- *204* success. ## Remove a Team. `DELETE /api/v0/accounts/{name}/teams/{teamname}` +```bash +$ curl --insecure -v --user admin:password -X DELETE https://dtr.domain.com/api/v0/accounts/engineering/teams/qa +``` + **Authorization** Client must be authenticated as a system admin or a member of the "owners" diff --git a/api/dtr_1_3_user_repo_access.md b/api/dtr_1_3_user_repo_access.md index 4638ab4111..e108b3c03c 100755 --- a/api/dtr_1_3_user_repo_access.md +++ b/api/dtr_1_3_user_repo_access.md @@ -31,8 +31,8 @@ to any repository that is owned by another user account. `GET /api/v0/repositories/{namespace}/{reponame}/userAccess` -```curl -curl -v --user josh:password --insecure -X GET https://dtr.domain.com/api/v0/repositories/josh/public-app/userAccess +```bash +curl -v --user josh:password --insecure https://dtr.domain.com/api/v0/repositories/josh/public-app/userAccess ``` Example Response: @@ -87,8 +87,8 @@ repository. `PUT /api/v0/repositories/{namespace}/{reponame}/userAccess/{grantee}` -```curl -curl -v --user josh:password --insecure -X PUT --header "Content-type: application/json" --data '{"accessLevel":"read-write"}' https://192.168.18.129/api/v0/repositories/alice/public-app/userAccess/brian +```bash +curl -v --user josh:password --insecure -X PUT --header "Content-type: application/json" --data '{"accessLevel":"read-write"}' https://dtr.domain.com/api/v0/repositories/alice/public-app/userAccess/brian ``` Example Request: @@ -141,6 +141,10 @@ repository. `DELETE /api/v0/repositories/{namespace}/{reponame}/userAccess/{grantee}` +```bash +$ curl -v --user josh:password --insecure -X DELETE https://dtr.domain.com/api/v0/repositories/josh/public-app/userAccess/user +``` + **Authorization** Client must be authenticated as a user which has 'admin' level access to the