Search in sources :

Example 1 with ServiceAccount

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount in project gapic-generator-java by googleapis.

the class AsyncGetServiceAccount method asyncGetServiceAccount.

public static void asyncGetServiceAccount() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetServiceAccountRequest request = GetServiceAccountRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ApiFuture<ServiceAccount> future = storageClient.getServiceAccountCallable().futureCall(request);
        // Do something.
        ServiceAccount response = future.get();
    }
}
Also used : ServiceAccount(com.google.storage.v2.ServiceAccount) StorageClient(com.google.storage.v2.StorageClient) GetServiceAccountRequest(com.google.storage.v2.GetServiceAccountRequest)

Example 2 with ServiceAccount

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount in project gapic-generator-java by googleapis.

the class SyncGetServiceAccount method syncGetServiceAccount.

public static void syncGetServiceAccount() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        GetServiceAccountRequest request = GetServiceAccountRequest.newBuilder().setProject(ProjectName.of("[PROJECT]").toString()).setCommonRequestParams(CommonRequestParams.newBuilder().build()).build();
        ServiceAccount response = storageClient.getServiceAccount(request);
    }
}
Also used : ServiceAccount(com.google.storage.v2.ServiceAccount) StorageClient(com.google.storage.v2.StorageClient) GetServiceAccountRequest(com.google.storage.v2.GetServiceAccountRequest)

Example 3 with ServiceAccount

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount in project gapic-generator-java by googleapis.

the class SyncGetServiceAccountProjectname method syncGetServiceAccountProjectname.

public static void syncGetServiceAccountProjectname() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        ProjectName project = ProjectName.of("[PROJECT]");
        ServiceAccount response = storageClient.getServiceAccount(project);
    }
}
Also used : ServiceAccount(com.google.storage.v2.ServiceAccount) ProjectName(com.google.storage.v2.ProjectName) StorageClient(com.google.storage.v2.StorageClient)

Example 4 with ServiceAccount

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount in project kas-fleetshard by bf2fc6cc711aee1a0c2a.

the class KafkaCluster method addQuotaConfig.

private void addQuotaConfig(ManagedKafka managedKafka, Kafka current, Map<String, Object> config) {
    config.put("client.quota.callback.class", IO_STRIMZI_KAFKA_QUOTA_STATIC_QUOTA_CALLBACK);
    // Throttle at Ingress/Egress MB/sec per broker
    config.put(QUOTA_PRODUCE, String.valueOf(getIngressBytes(managedKafka, current)));
    config.put(QUOTA_FETCH, String.valueOf(getEgressBytes(managedKafka, current)));
    // Start throttling when disk is above requested size. Full stop when only storageMinMargin is free.
    Quantity maxDataRetentionSize = getAdjustedMaxDataRetentionSize(managedKafka, current);
    long hardStorageLimit = Quantity.getAmountInBytes(maxDataRetentionSize).longValue() - Quantity.getAmountInBytes(storageMinMargin).longValue();
    long softStorageLimit = Quantity.getAmountInBytes(maxDataRetentionSize).longValue() - getStoragePadding(managedKafka, current);
    config.put("client.quota.callback.static.storage.soft", String.valueOf(softStorageLimit));
    config.put("client.quota.callback.static.storage.hard", String.valueOf(hardStorageLimit));
    // Check storage every storageCheckInterval seconds
    config.put("client.quota.callback.static.storage.check-interval", String.valueOf(storageCheckInterval));
    // Configure the quota plugin so that the canary is not subjected to the quota checks.
    Optional<ServiceAccount> canaryServiceAccount = managedKafka.getServiceAccount(ServiceAccount.ServiceAccountName.Canary);
    canaryServiceAccount.ifPresent(serviceAccount -> config.put("client.quota.callback.static.excluded.principal.name.list", serviceAccount.getPrincipal()));
    config.put("quota.window.num", "30");
    config.put("quota.window.size.seconds", "2");
}
Also used : ServiceAccount(org.bf2.operator.resources.v1alpha1.ServiceAccount) Quantity(io.fabric8.kubernetes.api.model.Quantity)

Example 5 with ServiceAccount

use of com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount in project gapic-generator-java by googleapis.

the class SyncGetServiceAccountString method syncGetServiceAccountString.

public static void syncGetServiceAccountString() throws Exception {
    // It may require modifications to work in your environment.
    try (StorageClient storageClient = StorageClient.create()) {
        String project = ProjectName.of("[PROJECT]").toString();
        ServiceAccount response = storageClient.getServiceAccount(project);
    }
}
Also used : ServiceAccount(com.google.storage.v2.ServiceAccount) StorageClient(com.google.storage.v2.StorageClient)

Aggregations

ServiceAccount (com.google.storage.v2.ServiceAccount)4 StorageClient (com.google.storage.v2.StorageClient)4 ServiceAccount (com.marcnuri.yakc.model.io.k8s.api.core.v1.ServiceAccount)3 Test (org.junit.jupiter.api.Test)3 GetServiceAccountRequest (com.google.storage.v2.GetServiceAccountRequest)2 DisplayName (org.junit.jupiter.api.DisplayName)2 ProjectName (com.google.storage.v2.ProjectName)1 KC (com.marcnuri.yakc.KubernetesClientExtension.KC)1 CoreV1Api (com.marcnuri.yakc.api.core.v1.CoreV1Api)1 Configuration (com.marcnuri.yakc.config.Configuration)1 Node (com.marcnuri.yakc.model.io.k8s.api.core.v1.Node)1 ObjectReference (com.marcnuri.yakc.model.io.k8s.api.core.v1.ObjectReference)1 Secret (com.marcnuri.yakc.model.io.k8s.api.core.v1.Secret)1 ObjectMeta (com.marcnuri.yakc.model.io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta)1 Quantity (io.fabric8.kubernetes.api.model.Quantity)1 IOException (java.io.IOException)1 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)1 ServiceAccount (org.bf2.operator.resources.v1alpha1.ServiceAccount)1 BeforeAll (org.junit.jupiter.api.BeforeAll)1 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)1