Skip to content

Instantly share code, notes, and snippets.

@BillyDonahue
Created April 29, 2020 16:12
Show Gist options
  • Save BillyDonahue/6657e34e8dd76e07f8a6643539154002 to your computer and use it in GitHub Desktop.
Save BillyDonahue/6657e34e8dd76e07f8a6643539154002 to your computer and use it in GitHub Desktop.
generated action_type.h
// AUTO-GENERATED FILE DO NOT EDIT
// See src/mongo/db/auth/generate_action_types.py
/**
* Copyright (C) 2018-present MongoDB, Inc.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the Server Side Public License, version 1,
* as published by MongoDB, Inc.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* Server Side Public License for more details.
*
* You should have received a copy of the Server Side Public License
* along with this program. If not, see
* <http://www.mongodb.com/licensing/server-side-public-license>.
*
* As a special exception, the copyright holders give permission to link the
* code of portions of this program with the OpenSSL library under certain
* conditions as described in each individual source file and distribute
* linked combinations including the program with the OpenSSL library. You
* must comply with the Server Side Public License in all respects for
* all of the code used other than as permitted herein. If you modify file(s)
* with this exception, you may extend this exception to your version of the
* file(s), but you are not obligated to do so. If you do not wish to do so,
* delete this exception statement from your version. If you delete this
* exception statement from all source files in the program, then also delete
* it in the license file.
*/
#pragma once
#include <array>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
#include "mongo/base/status.h"
namespace mongo {
// clang-format off
#define EXPAND_ACTION_TYPE(X) \
X(addShard) \
X(advanceClusterTime) \
X(anyAction) \
X(appendOplogNote) \
X(applicationMessage) \
X(auditLogRotate) \
X(authCheck) \
X(authenticate) \
X(authSchemaUpgrade) \
X(bypassDocumentValidation) \
X(changeCustomData) \
X(changePassword) \
X(changeOwnPassword) \
X(changeOwnCustomData) \
X(changeStream) \
X(checkFreeMonitoringStatus) \
X(cleanupOrphaned) \
X(clearJumboFlag) \
X(closeAllDatabases) \
X(collMod) \
X(collStats) \
X(compact) \
X(connPoolStats) \
X(connPoolSync) \
X(convertToCapped) \
X(cpuProfiler) \
X(createCollection) \
X(createDatabase) \
X(createIndex) \
X(createRole) \
X(createUser) \
X(dbHash) \
X(dbStats) \
X(dropAllRolesFromDatabase) \
X(dropAllUsersFromDatabase) \
X(dropCollection) \
X(dropConnections) \
X(dropDatabase) \
X(dropIndex) \
X(dropRole) \
X(dropUser) \
X(emptycapped) \
X(enableProfiler) \
X(enableSharding) \
X(find) \
X(flushRouterConfig) \
X(forceUUID) \
X(fsync) \
X(getDatabaseVersion) \
X(getDefaultRWConcern) \
X(getCmdLineOpts) \
X(getLog) \
X(getParameter) \
X(getShardMap) \
X(getShardVersion) \
X(grantRole) \
X(grantPrivilegesToRole) \
X(grantRolesToRole) \
X(grantRolesToUser) \
X(hostInfo) \
X(impersonate) \
X(indexStats) \
X(inprog) \
X(insert) \
X(internal) \
X(invalidateUserCache) \
X(killAnyCursor) \
X(killAnySession) \
X(killCursors) \
X(killop) \
X(listCachedAndActiveUsers) \
X(listCollections) \
X(listCursors) \
X(listDatabases) \
X(listIndexes) \
X(listSessions) \
X(listShards) \
X(logRotate) \
X(moveChunk) \
X(netstat) \
X(planCacheIndexFilter) \
X(planCacheRead) \
X(planCacheWrite) \
X(refineCollectionShardKey) \
X(reIndex) \
X(remove) \
X(removeShard) \
X(renameCollection) \
X(renameCollectionSameDB) \
X(repairDatabase) \
X(replSetConfigure) \
X(replSetGetConfig) \
X(replSetGetStatus) \
X(replSetHeartbeat) \
X(replSetReconfig) \
X(replSetResizeOplog) \
X(replSetStateChange) \
X(resync) \
X(revokeRole) \
X(revokePrivilegesFromRole) \
X(revokeRolesFromRole) \
X(revokeRolesFromUser) \
X(runAsLessPrivilegedUser) \
X(serverStatus) \
X(setAuthenticationRestriction) \
X(setDefaultRWConcern) \
X(setFeatureCompatibilityVersion) \
X(setFreeMonitoring) \
X(setParameter) \
X(shardCollection) \
X(shardingState) \
X(shutdown) \
X(splitChunk) \
X(splitVector) \
X(storageDetails) \
X(top) \
X(touch) \
X(trafficRecord) \
X(unlock) \
X(useUUID) \
X(update) \
X(updateRole) \
X(updateUser) \
X(validate) \
X(viewRole) \
X(viewUser) \
/**/
// clang-format on
struct ActionType {
public:
enum ActionTypeIdentifier {
#define X_(a) a##Value,
EXPAND_ACTION_TYPE(X_)
#undef X_
actionTypeEndValue, // Should always be last in this enum
};
#define X_(a) static const ActionType a;
EXPAND_ACTION_TYPE(X_)
#undef X_
static constexpr int NUM_ACTION_TYPES = actionTypeEndValue;
explicit constexpr ActionType(uint32_t identifier) : _id(identifier) {}
ActionType() = default;
constexpr uint32_t getIdentifier() const {
return _id;
}
std::string toString() const {
return std::string{actionToString(*this)};
}
// Takes the string representation of a single action type and returns the corresponding
// ActionType enum.
static Status parseActionFromString(StringData actionString, ActionType* result);
// Takes an ActionType and returns the string representation
static std::string actionToString(const ActionType& action);
friend constexpr bool operator==(const ActionType& a, const ActionType& b) {
return a.getIdentifier() == b.getIdentifier();
}
friend constexpr bool operator!=(const ActionType& a, const ActionType& b) {
return !(a == b);
}
friend std::ostream& operator<<(std::ostream& os, const ActionType& at) {
return os << at.toString();
}
private:
uint32_t _id; // unique identifier for this action.
};
#define X_(a) constexpr ActionType ActionType::a{a##Value};
EXPAND_ACTION_TYPE(X_)
#undef X_
} // namespace mongo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment