com.azure.resourcemanager.mediaservices.models.ContentKeyPolicyTokenRestriction Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of azure-resourcemanager-mediaservices Show documentation
Show all versions of azure-resourcemanager-mediaservices Show documentation
This package contains Microsoft Azure SDK for MediaServices Management SDK. For documentation on how to use this package, please see https://aka.ms/azsdk/java/mgmt. This Swagger was generated by the API Framework. Package tag package-account-2023-01.
The newest version!
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
package com.azure.resourcemanager.mediaservices.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
import com.azure.json.JsonReader;
import com.azure.json.JsonToken;
import com.azure.json.JsonWriter;
import java.io.IOException;
import java.util.List;
/**
* Represents a token restriction. Provided token must match these requirements for successful license or key delivery.
*/
@Fluent
public final class ContentKeyPolicyTokenRestriction extends ContentKeyPolicyRestriction {
/*
* The discriminator for derived types.
*/
private String odataType = "#Microsoft.Media.ContentKeyPolicyTokenRestriction";
/*
* The token issuer.
*/
private String issuer;
/*
* The audience for the token.
*/
private String audience;
/*
* The primary verification key.
*/
private ContentKeyPolicyRestrictionTokenKey primaryVerificationKey;
/*
* A list of alternative verification keys.
*/
private List alternateVerificationKeys;
/*
* A list of required token claims.
*/
private List requiredClaims;
/*
* The type of token.
*/
private ContentKeyPolicyRestrictionTokenType restrictionTokenType;
/*
* The OpenID connect discovery document.
*/
private String openIdConnectDiscoveryDocument;
/**
* Creates an instance of ContentKeyPolicyTokenRestriction class.
*/
public ContentKeyPolicyTokenRestriction() {
}
/**
* Get the odataType property: The discriminator for derived types.
*
* @return the odataType value.
*/
@Override
public String odataType() {
return this.odataType;
}
/**
* Get the issuer property: The token issuer.
*
* @return the issuer value.
*/
public String issuer() {
return this.issuer;
}
/**
* Set the issuer property: The token issuer.
*
* @param issuer the issuer value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction withIssuer(String issuer) {
this.issuer = issuer;
return this;
}
/**
* Get the audience property: The audience for the token.
*
* @return the audience value.
*/
public String audience() {
return this.audience;
}
/**
* Set the audience property: The audience for the token.
*
* @param audience the audience value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction withAudience(String audience) {
this.audience = audience;
return this;
}
/**
* Get the primaryVerificationKey property: The primary verification key.
*
* @return the primaryVerificationKey value.
*/
public ContentKeyPolicyRestrictionTokenKey primaryVerificationKey() {
return this.primaryVerificationKey;
}
/**
* Set the primaryVerificationKey property: The primary verification key.
*
* @param primaryVerificationKey the primaryVerificationKey value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction
withPrimaryVerificationKey(ContentKeyPolicyRestrictionTokenKey primaryVerificationKey) {
this.primaryVerificationKey = primaryVerificationKey;
return this;
}
/**
* Get the alternateVerificationKeys property: A list of alternative verification keys.
*
* @return the alternateVerificationKeys value.
*/
public List alternateVerificationKeys() {
return this.alternateVerificationKeys;
}
/**
* Set the alternateVerificationKeys property: A list of alternative verification keys.
*
* @param alternateVerificationKeys the alternateVerificationKeys value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction
withAlternateVerificationKeys(List alternateVerificationKeys) {
this.alternateVerificationKeys = alternateVerificationKeys;
return this;
}
/**
* Get the requiredClaims property: A list of required token claims.
*
* @return the requiredClaims value.
*/
public List requiredClaims() {
return this.requiredClaims;
}
/**
* Set the requiredClaims property: A list of required token claims.
*
* @param requiredClaims the requiredClaims value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction withRequiredClaims(List requiredClaims) {
this.requiredClaims = requiredClaims;
return this;
}
/**
* Get the restrictionTokenType property: The type of token.
*
* @return the restrictionTokenType value.
*/
public ContentKeyPolicyRestrictionTokenType restrictionTokenType() {
return this.restrictionTokenType;
}
/**
* Set the restrictionTokenType property: The type of token.
*
* @param restrictionTokenType the restrictionTokenType value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction
withRestrictionTokenType(ContentKeyPolicyRestrictionTokenType restrictionTokenType) {
this.restrictionTokenType = restrictionTokenType;
return this;
}
/**
* Get the openIdConnectDiscoveryDocument property: The OpenID connect discovery document.
*
* @return the openIdConnectDiscoveryDocument value.
*/
public String openIdConnectDiscoveryDocument() {
return this.openIdConnectDiscoveryDocument;
}
/**
* Set the openIdConnectDiscoveryDocument property: The OpenID connect discovery document.
*
* @param openIdConnectDiscoveryDocument the openIdConnectDiscoveryDocument value to set.
* @return the ContentKeyPolicyTokenRestriction object itself.
*/
public ContentKeyPolicyTokenRestriction withOpenIdConnectDiscoveryDocument(String openIdConnectDiscoveryDocument) {
this.openIdConnectDiscoveryDocument = openIdConnectDiscoveryDocument;
return this;
}
/**
* Validates the instance.
*
* @throws IllegalArgumentException thrown if the instance is not valid.
*/
@Override
public void validate() {
if (issuer() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property issuer in model ContentKeyPolicyTokenRestriction"));
}
if (audience() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property audience in model ContentKeyPolicyTokenRestriction"));
}
if (primaryVerificationKey() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property primaryVerificationKey in model ContentKeyPolicyTokenRestriction"));
} else {
primaryVerificationKey().validate();
}
if (alternateVerificationKeys() != null) {
alternateVerificationKeys().forEach(e -> e.validate());
}
if (requiredClaims() != null) {
requiredClaims().forEach(e -> e.validate());
}
if (restrictionTokenType() == null) {
throw LOGGER.atError()
.log(new IllegalArgumentException(
"Missing required property restrictionTokenType in model ContentKeyPolicyTokenRestriction"));
}
}
private static final ClientLogger LOGGER = new ClientLogger(ContentKeyPolicyTokenRestriction.class);
/**
* {@inheritDoc}
*/
@Override
public JsonWriter toJson(JsonWriter jsonWriter) throws IOException {
jsonWriter.writeStartObject();
jsonWriter.writeStringField("issuer", this.issuer);
jsonWriter.writeStringField("audience", this.audience);
jsonWriter.writeJsonField("primaryVerificationKey", this.primaryVerificationKey);
jsonWriter.writeStringField("restrictionTokenType",
this.restrictionTokenType == null ? null : this.restrictionTokenType.toString());
jsonWriter.writeStringField("@odata.type", this.odataType);
jsonWriter.writeArrayField("alternateVerificationKeys", this.alternateVerificationKeys,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeArrayField("requiredClaims", this.requiredClaims,
(writer, element) -> writer.writeJson(element));
jsonWriter.writeStringField("openIdConnectDiscoveryDocument", this.openIdConnectDiscoveryDocument);
return jsonWriter.writeEndObject();
}
/**
* Reads an instance of ContentKeyPolicyTokenRestriction from the JsonReader.
*
* @param jsonReader The JsonReader being read.
* @return An instance of ContentKeyPolicyTokenRestriction if the JsonReader was pointing to an instance of it, or
* null if it was pointing to JSON null.
* @throws IllegalStateException If the deserialized JSON object was missing any required properties.
* @throws IOException If an error occurs while reading the ContentKeyPolicyTokenRestriction.
*/
public static ContentKeyPolicyTokenRestriction fromJson(JsonReader jsonReader) throws IOException {
return jsonReader.readObject(reader -> {
ContentKeyPolicyTokenRestriction deserializedContentKeyPolicyTokenRestriction
= new ContentKeyPolicyTokenRestriction();
while (reader.nextToken() != JsonToken.END_OBJECT) {
String fieldName = reader.getFieldName();
reader.nextToken();
if ("issuer".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.issuer = reader.getString();
} else if ("audience".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.audience = reader.getString();
} else if ("primaryVerificationKey".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.primaryVerificationKey
= ContentKeyPolicyRestrictionTokenKey.fromJson(reader);
} else if ("restrictionTokenType".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.restrictionTokenType
= ContentKeyPolicyRestrictionTokenType.fromString(reader.getString());
} else if ("@odata.type".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.odataType = reader.getString();
} else if ("alternateVerificationKeys".equals(fieldName)) {
List alternateVerificationKeys
= reader.readArray(reader1 -> ContentKeyPolicyRestrictionTokenKey.fromJson(reader1));
deserializedContentKeyPolicyTokenRestriction.alternateVerificationKeys = alternateVerificationKeys;
} else if ("requiredClaims".equals(fieldName)) {
List requiredClaims
= reader.readArray(reader1 -> ContentKeyPolicyTokenClaim.fromJson(reader1));
deserializedContentKeyPolicyTokenRestriction.requiredClaims = requiredClaims;
} else if ("openIdConnectDiscoveryDocument".equals(fieldName)) {
deserializedContentKeyPolicyTokenRestriction.openIdConnectDiscoveryDocument = reader.getString();
} else {
reader.skipChildren();
}
}
return deserializedContentKeyPolicyTokenRestriction;
});
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy