Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2020 Dremio
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.projectnessie.services.cel;
import com.google.common.collect.ImmutableList;
import java.util.List;
import org.projectnessie.cel.checker.Decls;
import org.projectnessie.cel.relocated.com.google.api.expr.v1alpha1.Decl;
import org.projectnessie.cel.tools.ScriptHost;
import org.projectnessie.cel.types.jackson.JacksonRegistry;
import org.projectnessie.model.CommitMeta;
import org.projectnessie.model.Content;
import org.projectnessie.model.ContentKey;
import org.projectnessie.model.ImmutableReferenceMetadata;
import org.projectnessie.model.Namespace;
import org.projectnessie.model.Operation;
import org.projectnessie.model.Operation.Delete;
import org.projectnessie.model.Operation.Put;
import org.projectnessie.model.Reference;
import org.projectnessie.model.ReferenceMetadata;
import org.projectnessie.versioned.KeyEntry;
/** A utility class for CEL declarations and other things. */
public final class CELUtil {
public static final String CONTAINER = "org.projectnessie.model";
public static final ScriptHost SCRIPT_HOST =
ScriptHost.newBuilder().registry(JacksonRegistry.newRegistry()).build();
public static final String VAR_REF = "ref";
public static final String VAR_REF_TYPE = "refType";
public static final String VAR_REF_META = "refMeta";
public static final String VAR_COMMIT = "commit";
public static final String VAR_KEY = "key";
public static final String VAR_ENTRY = "entry";
public static final String VAR_PATH = "path";
public static final String VAR_ROLE = "role";
public static final String VAR_ROLES = "roles";
public static final String VAR_OP = "op";
public static final String VAR_ACTIONS = "actions";
public static final String VAR_API = "api";
public static final String VAR_OPERATIONS = "operations";
public static final String VAR_CONTENT_TYPE = "contentType";
public static final List REFERENCES_DECLARATIONS =
ImmutableList.of(
Decls.newVar(VAR_COMMIT, Decls.newObjectType(CommitMeta.class.getName())),
Decls.newVar(VAR_REF, Decls.newObjectType(Reference.class.getName())),
Decls.newVar(VAR_REF_META, Decls.newObjectType(ReferenceMetadata.class.getName())),
Decls.newVar(VAR_REF_TYPE, Decls.String));
public static final List COMMIT_LOG_DECLARATIONS =
ImmutableList.of(
Decls.newVar(VAR_COMMIT, Decls.newObjectType(CommitMeta.class.getName())),
Decls.newVar(
VAR_OPERATIONS,
Decls.newListType(Decls.newObjectType(OperationForCel.class.getName()))));
public static final List CONTENT_KEY_DECLARATIONS =
ImmutableList.of(
Decls.newVar(VAR_KEY, Decls.newObjectType(KeyedEntityForCel.class.getName())));
public static final List ENTRIES_DECLARATIONS =
ImmutableList.of(
Decls.newVar(VAR_ENTRY, Decls.newObjectType(KeyEntryForCel.class.getName())));
public static final List AUTHORIZATION_RULE_DECLARATIONS =
ImmutableList.of(
Decls.newVar(VAR_REF, Decls.String),
Decls.newVar(VAR_PATH, Decls.String),
Decls.newVar(VAR_CONTENT_TYPE, Decls.String),
Decls.newVar(VAR_ROLE, Decls.String),
Decls.newVar(VAR_ROLES, Decls.newListType(Decls.String)),
Decls.newVar(VAR_OP, Decls.String));
public static final List