Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-cpplib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-cpplib
Commits
c22c28ca
Verified
Commit
c22c28ca
authored
1 year ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
ENH: add Connection::ListUsers method
parent
a1058f7a
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!61
Release 0.3.0
,
!47
F null pointer list users
Pipeline
#47071
failed
1 year ago
Stage: info
Stage: setup
Stage: test
Stage: deploy
Pipeline: caosdb-cppinttest
#47073
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
doc/CHANGELOG.md
+2
-0
2 additions, 0 deletions
doc/CHANGELOG.md
include/caosdb/connection.h
+8
-0
8 additions, 0 deletions
include/caosdb/connection.h
requirements.txt
+1
-1
1 addition, 1 deletion
requirements.txt
src/caosdb/connection.cpp
+36
-0
36 additions, 0 deletions
src/caosdb/connection.cpp
with
47 additions
and
1 deletion
doc/CHANGELOG.md
+
2
−
0
View file @
c22c28ca
...
...
@@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
-
Connection::ListUsers method
### Changed
-
Updated dependency versions.
...
...
This diff is collapsed.
Click to expand it.
include/caosdb/connection.h
+
8
−
0
View file @
c22c28ca
...
...
@@ -43,6 +43,9 @@
#include
<map>
// for map
#include
<memory>
// for shared_ptr, unique_ptr
#include
<string>
// for string, basic_string
#ifdef BUILD_ACM
#include
<vector>
// for vector
#endif
namespace
caosdb
::
connection
{
#ifdef BUILD_ACM
...
...
@@ -122,6 +125,11 @@ public:
// TODO(tf) find a way to deal with this:
// NOLINTNEXTLINE(bugprone-easily-swappable-parameters)
auto
DeleteSingleUser
(
const
std
::
string
&
realm
,
const
std
::
string
&
name
)
const
->
void
;
/**
* List known users.
*/
auto
ListUsers
()
const
->
std
::
vector
<
User
>
;
#endif
private
:
...
...
This diff is collapsed.
Click to expand it.
requirements.txt
+
1
−
1
View file @
c22c28ca
...
...
@@ -15,7 +15,7 @@ pluginbase==1.0.1
Pygments
==2.13.0
PyJWT
==2.6.0
python-dateutil
==2.8.2
PyYAML
==6.0
PyYAML
==6.0
.1
requests
==2.28.1
six
==1.16.0
tqdm
==4.64.1
...
...
This diff is collapsed.
Click to expand it.
src/caosdb/connection.cpp
+
36
−
0
View file @
c22c28ca
...
...
@@ -36,6 +36,9 @@
#include
<grpcpp/create_channel.h>
// for CreateChannel
#include
<grpcpp/support/status.h>
// for Status
#include
<string>
// for string, operator+
#ifdef BUILD_ACM
#include
<vector>
// for vector
#endif
// IWYU pragma: no_include "net/proto2/public/repeated_field.h"
namespace
caosdb
::
connection
{
...
...
@@ -46,6 +49,8 @@ using caosdb::acm::v1alpha1::CreateSingleUserRequest;
using
caosdb
::
acm
::
v1alpha1
::
CreateSingleUserResponse
;
using
caosdb
::
acm
::
v1alpha1
::
DeleteSingleUserRequest
;
using
caosdb
::
acm
::
v1alpha1
::
DeleteSingleUserResponse
;
using
caosdb
::
acm
::
v1alpha1
::
ListUsersRequest
;
using
caosdb
::
acm
::
v1alpha1
::
ListUsersResponse
;
using
caosdb
::
acm
::
v1alpha1
::
RetrieveSingleUserRequest
;
using
caosdb
::
acm
::
v1alpha1
::
RetrieveSingleUserResponse
;
#endif
...
...
@@ -204,6 +209,37 @@ auto Connection::CreateSingleUser(const User &user) const -> void {
}
status
.
ThrowExceptionIfError
();
}
auto
Connection
::
ListUsers
()
const
->
std
::
vector
<
User
>
{
ListUsersRequest
request
;
ListUsersResponse
response
;
grpc
::
ClientContext
context
;
const
grpc
::
Status
grpc_status
=
this
->
access_controll_management_service
->
ListUsers
(
&
context
,
request
,
&
response
);
auto
status
=
TransactionStatus
::
SUCCESS
();
if
(
!
grpc_status
.
ok
())
{
switch
(
grpc_status
.
error_code
())
{
case
grpc
::
StatusCode
::
UNAUTHENTICATED
:
status
=
TransactionStatus
::
AUTHENTICATION_ERROR
(
grpc_status
.
error_message
());
break
;
case
grpc
::
StatusCode
::
UNAVAILABLE
:
status
=
TransactionStatus
::
CONNECTION_ERROR
();
break
;
default:
auto
error_message
=
grpc_status
.
error_message
();
status
=
TransactionStatus
::
RPC_ERROR
(
std
::
to_string
(
grpc_status
.
error_code
())
+
" - "
+
error_message
);
}
}
status
.
ThrowExceptionIfError
();
std
::
vector
<
User
>
results
;
for
(
auto
&
user
:
*
(
response
.
mutable_users
()))
{
results
.
push_back
(
User
(
std
::
make_unique
<
UserImpl
>
(
&
user
)));
}
return
results
;
}
#endif
auto
ConnectionManager
::
mHasConnection
(
const
std
::
string
&
name
)
const
->
bool
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment