A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://cloud.google.com/cpp/docs/reference/policysimulator/2.23.0 below:

C++ Client Libraries | Google Cloud

Stay organized with collections Save and categorize content based on your preferences.

Policy Simulator API C++ Client Library

An idiomatic C++ client library for the Policy Simulator API

Policy Simulator is a collection of endpoints for creating, running, and viewing a Replay. A Replay is a type of simulation that lets you see how your members' access to resources might change if you changed your IAM policy.

During a Replay, Policy Simulator re-evaluates, or replays, past access attempts under both the current policy and your proposed policy, and compares those results to determine how your members' access might change under the proposed policy.

While this library is GA, please note that the Google Cloud C++ client libraries do not follow Semantic Versioning.

Quickstart

The following shows the code that you'll run in the google/cloud/policysimulator/quickstart/ directory, which should give you a taste of the Policy Simulator API C++ client library API.

#include "google/cloud/policysimulator/v1/simulator_client.h"
#include "google/cloud/location.h"
#include <iostream>
#include <string>

int main(int argc, char* argv[]) try {
  if (argc != 3) {
    std::cerr
        << "Usage: " << argv[0] << " project-id resource-name\n"
        << "See https://cloud.google.com/iam/docs/full-resource-names for "
           "examples of fully qualified resource names.\n";
    return 1;
  }

  auto const location = google::cloud::Location(argv[1], "global");
  auto const resource_name = std::string{argv[2]};

  namespace policysimulator = ::google::cloud::policysimulator_v1;
  auto client = policysimulator::SimulatorClient(
      policysimulator::MakeSimulatorConnection());

  google::cloud::policysimulator::v1::Replay r;
  auto& overlay = *r.mutable_config()->mutable_policy_overlay();
  overlay[resource_name] = [] {
    google::iam::v1::Policy p;
    auto& binding = *p.add_bindings();
    binding.set_role("storage.buckets.get");
    binding.add_members("user@example.com");
    return p;
  }();

  auto replay = client.CreateReplay(location.FullName(), r).get();
  if (!replay) throw std::move(replay).status();
  std::cout << replay->DebugString() << "\n";

  return 0;
} catch (google::cloud::Status const& status) {
  std::cerr << "google::cloud::Status thrown: " << status << "\n";
  return 1;
}
Main classes

The main class in this library is policysimulator_v1::SimulatorClient. All RPCs are exposed as member functions of this class. Other classes provide helpers, configuration parameters, and infrastructure to mock policysimulator_v1::SimulatorClient when testing your application.

More Information

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-08-14 UTC.

[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["The Policy Simulator API C++ Client Library allows users to simulate how changes to IAM policies would affect members' access to resources."],["The library's core functionality revolves around creating and running \"Replays,\" which evaluate past access attempts under current and proposed policies to analyze potential changes."],["The `policysimulator_v1::SimulatorClient` class is the main component, exposing all remote procedure calls (RPCs) for interacting with the Policy Simulator API."],["While the library is in general availability (GA), it does not use semantic versioning."],["The content is an overview of the C++ client library and provides links to detailed information about error handling, endpoint and authentication overriding, retry policies, and environment variables."]]],[]]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4