<commit_before>/*
 * Copyright 2012 Splunk, Inc.
 *
 * 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 com.splunk;


import java.util.Map;
import java.util.HashMap;

/**
 * The {@code Resource} class represents a Splunk resource.
 */
public abstract class Resource {
    protected Map<String, String> actions;
    protected String path;
    protected String partialPath;
    protected Service service;
    protected String title;
    protected Args refreshArgs;
    private boolean maybeValid = false;

    /**
     * Class constructor.
     *
     * @param service The connected {@code Service} instance.
     * @param path The target endpoint.
     */
    Resource(Service service, String path) {
        this.path = service.fullpath(path);
        this.partialPath = path;
        this.service = service;
        this.refreshArgs = new Args("count", "-1");
    }

    /**
     * Class Constructor.
     *
     * @param service The connected service instance.
     * @param path The target endpoint.
     * @param args Arguments use at instantiation, such as count and offset.
     */
    Resource(Service service, String path, Args args) {
        this.service = service;
        // Pull out namespace items (app, owner, sharing) from the args, and
        // then use to create the full path.
        Args clonedArgs = new Args(args);
        Args namespace = new Args();
        if (args.containsKey("app")) {
            namespace.put("app", args.get("app").toString());
            clonedArgs.remove("app");
        }
        if (args.containsKey("owner")) {
            namespace.put("owner", args.get("owner").toString());
            clonedArgs.remove("owner");
        }
        if (args.containsKey("sharing")) {
            namespace.put("sharing", args.get("sharing").toString());
            clonedArgs.remove("sharing");
        }
        this.refreshArgs = clonedArgs;
        this.path = service.fullpath(
            path, namespace.size() == 0 ? null : namespace);
    }

    /**
     * Returns a map of actions that are enabled for this resource.
     *
     * @return The action map.
     */
    public Map<String, String> getActions() {
        return validate().actions;
    }<commit_msg>When adding namespace or any other argument; make count behave as the non-argument API, unless passed in by the caller.<commit_after>/*
 * Copyright 2012 Splunk, Inc.
 *
 * 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 com.splunk;


import java.util.Map;
import java.util.HashMap;

/**
 * The {@code Resource} class represents a Splunk resource.
 */
public abstract class Resource {
    protected Map<String, String> actions;
    protected String path;
    protected String partialPath;
    protected Service service;
    protected String title;
    protected Args refreshArgs;
    private boolean maybeValid = false;

    /**
     * Class constructor.
     *
     * @param service The connected {@code Service} instance.
     * @param path The target endpoint.
     */
    Resource(Service service, String path) {
        this.path = service.fullpath(path);
        this.partialPath = path;
        this.service = service;
        this.refreshArgs = new Args("count", "-1");
    }

    /**
     * Class Constructor.
     *
     * @param service The connected service instance.
     * @param path The target endpoint.
     * @param args Arguments use at instantiation, such as count and offset.
     */
    Resource(Service service, String path, Args args) {
        this.service = service;
        // Pull out namespace items (app, owner, sharing) from the args, and
        // then use to create the full path.
        Args clonedArgs = new Args(args);
        Args namespace = new Args();
        if (args.containsKey("app")) {
            namespace.put("app", args.get("app").toString());
            clonedArgs.remove("app");
        }
        if (args.containsKey("owner")) {
            namespace.put("owner", args.get("owner").toString());
            clonedArgs.remove("owner");
        }
        if (args.containsKey("sharing")) {
            namespace.put("sharing", args.get("sharing").toString());
            clonedArgs.remove("sharing");
        }
        if (!clonedArgs.containsKey("count"))
            clonedArgs.put("count", "-1");

        this.refreshArgs = clonedArgs;
        this.path = service.fullpath(
            path, namespace.size() == 0 ? null : namespace);
    }

    /**
     * Returns a map of actions that are enabled for this resource.
     *
     * @return The action map.
     */
    public Map<String, String> getActions() {
        return validate().actions;
    }
{'fraction_non_alphanumeric': 0.10824195259992925, 'fraction_numerical': 0.003714184648036788, 'mean_word_length': 2.5080645161290325, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3928716', 'n_tokens_mistral': 1479, 'n_tokens_neox': 1454, 'n_words': 533}