001/*
002 * VM-Operator
003 * Copyright (C) 2024 Michael N. Lipp
004 * 
005 * This program is free software: you can redistribute it and/or modify
006 * it under the terms of the GNU Affero General Public License as
007 * published by the Free Software Foundation, either version 3 of the
008 * License, or (at your option) any later version.
009 *
010 * This program is distributed in the hope that it will be useful,
011 * but WITHOUT ANY WARRANTY; without even the implied warranty of
012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013 * GNU Affero General Public License for more details.
014 *
015 * You should have received a copy of the GNU Affero General Public License
016 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
017 */
018
019package org.jdrupes.vmoperator.common;
020
021import io.kubernetes.client.Discovery.APIResource;
022import io.kubernetes.client.openapi.ApiException;
023import io.kubernetes.client.openapi.models.V1Secret;
024import io.kubernetes.client.openapi.models.V1SecretList;
025import io.kubernetes.client.util.generic.options.ListOptions;
026import java.util.Collection;
027import java.util.List;
028
029/**
030 * A stub for secrets (v1).
031 */
032@SuppressWarnings("PMD.DataflowAnomalyAnalysis")
033public class K8sV1SecretStub extends K8sGenericStub<V1Secret, V1SecretList> {
034
035    public static final APIResource CONTEXT = new APIResource("", List.of("v1"),
036        "v1", "Secret", true, "secrets", "secret");
037
038    /**
039     * Instantiates a new stub.
040     *
041     * @param client the client
042     * @param namespace the namespace
043     * @param name the name
044     */
045    protected K8sV1SecretStub(K8sClient client, String namespace,
046            String name) {
047        super(V1Secret.class, V1SecretList.class, client,
048            CONTEXT, namespace, name);
049    }
050
051    /**
052     * Gets the stub for the given namespace and name.
053     *
054     * @param client the client
055     * @param namespace the namespace
056     * @param name the name
057     * @return the config map stub
058     */
059    public static K8sV1SecretStub get(K8sClient client, String namespace,
060            String name) {
061        return new K8sV1SecretStub(client, namespace, name);
062    }
063
064    /**
065     * Creates an object stub from a model.
066     *
067     * @param client the client
068     * @param model the model
069     * @return the k 8 s dynamic stub
070     * @throws ApiException the api exception
071     */
072    public static K8sV1SecretStub create(K8sClient client, V1Secret model)
073            throws ApiException {
074        return K8sGenericStub.create(V1Secret.class,
075            V1SecretList.class, client, CONTEXT, model, K8sV1SecretStub::new);
076    }
077
078    /**
079     * Get the stubs for the objects in the given namespace that match
080     * the criteria from the given options.
081     *
082     * @param client the client
083     * @param namespace the namespace
084     * @param options the options
085     * @return the collection
086     * @throws ApiException the api exception
087     */
088    public static Collection<K8sV1SecretStub> list(K8sClient client,
089            String namespace, ListOptions options) throws ApiException {
090        return K8sGenericStub.list(V1Secret.class, V1SecretList.class, client,
091            CONTEXT, namespace, options, K8sV1SecretStub::new);
092    }
093}