// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.resourcemanager.videoanalyzer.generated;

import com.azure.core.util.Context;
import com.azure.resourcemanager.videoanalyzer.models.AccessPolicyEccAlgo;
import com.azure.resourcemanager.videoanalyzer.models.AccessPolicyEntity;
import com.azure.resourcemanager.videoanalyzer.models.AccessPolicyRsaAlgo;
import com.azure.resourcemanager.videoanalyzer.models.EccTokenKey;
import com.azure.resourcemanager.videoanalyzer.models.JwtAuthentication;
import com.azure.resourcemanager.videoanalyzer.models.RsaTokenKey;
import com.azure.resourcemanager.videoanalyzer.models.TokenClaim;
import java.util.Arrays;

/** Samples for AccessPolicies Update. */
public final class AccessPoliciesUpdateSamples {
    /*
     * x-ms-original-file: specification/videoanalyzer/resource-manager/Microsoft.Media/preview/2021-11-01-preview/examples/access-policy-patch.json
     */
    /**
     * Sample code: Update access policy entity.
     *
     * @param manager Entry point to VideoAnalyzerManager.
     */
    public static void updateAccessPolicyEntity(com.azure.resourcemanager.videoanalyzer.VideoAnalyzerManager manager) {
        AccessPolicyEntity resource =
            manager
                .accessPolicies()
                .getWithResponse("testrg", "testaccount2", "accessPolicyName1", Context.NONE)
                .getValue();
        resource
            .update()
            .withAuthentication(
                new JwtAuthentication()
                    .withIssuers(Arrays.asList("issuer1", "issuer2"))
                    .withAudiences(Arrays.asList("audience1"))
                    .withClaims(
                        Arrays
                            .asList(
                                new TokenClaim().withName("claimname1").withValue("claimvalue1"),
                                new TokenClaim().withName("claimname2").withValue("claimvalue2")))
                    .withKeys(
                        Arrays
                            .asList(
                                new RsaTokenKey()
                                    .withKid("123")
                                    .withAlg(AccessPolicyRsaAlgo.RS256)
                                    .withN("YmFzZTY0IQ==")
                                    .withE("ZLFzZTY0IQ=="),
                                new EccTokenKey()
                                    .withKid("124")
                                    .withAlg(AccessPolicyEccAlgo.ES256)
                                    .withX("XX==")
                                    .withY("YY=="))))
            .apply();
    }
}
