ListRowPolicies()
Lists the row policies defined for a collection.
Status ListRowPolicies(const ListRowPoliciesRequest& request, ListRowPoliciesResponse& response)
Request Syntax
auto request = milvus::ListRowPoliciesRequest()
.WithDatabaseName("default")
.WithCollectionName("messages");
REQUEST METHODS:
WithDatabaseName(const std::string& db_name)Sets the database name. Use the default database when it is empty.
SetDatabaseName(const std::string& db_name)Sets the database name. Use the default database when it is empty.
WithCollectionName(const std::string& collection_name)Sets the collection whose policies are listed.
SetCollectionName(const std::string& collection_name)Sets the collection whose policies are listed.
RETURNS:
Returns a Status indicating whether the operation succeeded.
response (ListRowPoliciesResponse) -
Policies (const std::vector
& ) -Returns the policies. Each RowPolicy carries its name, type, actions, expressions, description, and creation time.
RowPolicy
Describes one row-level security policy returned by ListRowPolicies().
class RowPolicy;
METHODS:
const std::string& PolicyName() constReturns the policy name, unique within the collection.
RowPolicyType PolicyType() constReturns the policy type. See RowPolicyType.
const std::vector<RowPolicyAction>& Actions() constReturns the row-bearing operations covered by the policy. See RowPolicyAction.
const std::string& UsingExpr() constReturns the filter expression that controls which existing rows are visible.
const std::string& CheckExpr() constReturns the expression that controls which new or changed rows may be written.
const std::string& Description() constReturns the policy description.
int64_t CreatedAt() constReturns the creation time in milliseconds since the Unix epoch, or zero when unavailable.
ERROR HANDLING:
-
Failures are reported through the returned Status. The SDK converts internal exceptions into a non-OK Status; public API calls do not throw. Inspect
status.IsOk()andstatus.Message()for failure details. See Status.
Example
#include "milvus/MilvusClientV2.h"
#include <iostream>
auto client = milvus::MilvusClientV2::Create();
milvus::ConnectParam connect_param{"http://localhost:19530", "root:Milvus"};
auto status = client->Connect(connect_param);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
milvus::ListRowPoliciesRequest request;
request.WithDatabaseName("default").WithCollectionName("messages");
milvus::ListRowPoliciesResponse response;
status = client->ListRowPolicies(request, response);
if (!status.IsOk()) {
std::cout << status.Message() << std::endl;
}
for (const auto& policy : response.Policies()) {
std::cout << policy.PolicyName() << '\n';
}