Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR azure-ai-contentsafety] Add additional OData query parameters + mark some properties as Expandable #7789

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import com.azure.core.client.traits.EndpointTrait;
import com.azure.core.client.traits.HttpTrait;
import com.azure.core.client.traits.KeyCredentialTrait;
import com.azure.core.client.traits.TokenCredentialTrait;
import com.azure.core.credential.KeyCredential;
import com.azure.core.credential.TokenCredential;
import com.azure.core.http.HttpClient;
import com.azure.core.http.HttpHeaderName;
import com.azure.core.http.HttpHeaders;
Expand All @@ -21,6 +23,7 @@
import com.azure.core.http.policy.AddDatePolicy;
import com.azure.core.http.policy.AddHeadersFromContextPolicy;
import com.azure.core.http.policy.AddHeadersPolicy;
import com.azure.core.http.policy.BearerTokenAuthenticationPolicy;
import com.azure.core.http.policy.HttpLogOptions;
import com.azure.core.http.policy.HttpLoggingPolicy;
import com.azure.core.http.policy.HttpPipelinePolicy;
Expand All @@ -46,12 +49,16 @@
public final class ContentSafetyClientBuilder
implements HttpTrait<ContentSafetyClientBuilder>,
ConfigurationTrait<ContentSafetyClientBuilder>,
TokenCredentialTrait<ContentSafetyClientBuilder>,
KeyCredentialTrait<ContentSafetyClientBuilder>,
EndpointTrait<ContentSafetyClientBuilder> {
@Generated private static final String SDK_NAME = "name";

@Generated private static final String SDK_VERSION = "version";

@Generated
private static final String[] DEFAULT_SCOPES = new String[] {"https://cognitiveservices.azure.com/.default"};

@Generated
private static final Map<String, String> PROPERTIES = CoreUtils.getProperties("azure-ai-contentsafety.properties");

Expand Down Expand Up @@ -153,6 +160,19 @@ public ContentSafetyClientBuilder configuration(Configuration configuration) {
return this;
}

/*
* The TokenCredential used for authentication.
*/
@Generated private TokenCredential tokenCredential;

/** {@inheritDoc}. */
@Generated
@Override
public ContentSafetyClientBuilder credential(TokenCredential tokenCredential) {
this.tokenCredential = tokenCredential;
return this;
}

/*
* The KeyCredential used for authentication.
*/
Expand Down Expand Up @@ -261,6 +281,9 @@ private HttpPipeline createHttpPipeline() {
if (keyCredential != null) {
policies.add(new KeyCredentialPolicy("Ocp-Apim-Subscription-Key", keyCredential));
}
if (tokenCredential != null) {
policies.add(new BearerTokenAuthenticationPolicy(tokenCredential, DEFAULT_SCOPES));
}
this.pipelinePolicies.stream()
.filter(p -> p.getPipelinePosition() == HttpPipelinePosition.PER_RETRY)
.forEach(p -> policies.add(p));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

/** Service version of ContentSafetyClient. */
public enum ContentSafetyServiceVersion implements ServiceVersion {
/** Enum value 2023-04-30-preview. */
V2023_04_30_PREVIEW("2023-04-30-preview");
/** Enum value 2023-10-01. */
V2023_10_01("2023-10-01");

private final String version;

Expand All @@ -29,6 +29,6 @@ public String getVersion() {
* @return The latest {@link ContentSafetyServiceVersion}.
*/
public static ContentSafetyServiceVersion getLatest() {
return V2023_04_30_PREVIEW;
return V2023_10_01;
}
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.contentsafety.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The request to add blocklistItems to a text blocklist. */
@Immutable
public final class AddOrUpdateTextBlocklistItemsOptions {
/*
* Array of blocklistItems to add.
*/
@Generated
@JsonProperty(value = "blocklistItems")
private List<TextBlocklistItem> blocklistItems;

/**
* Creates an instance of AddOrUpdateTextBlocklistItemsOptions class.
*
* @param blocklistItems the blocklistItems value to set.
*/
@Generated
@JsonCreator
public AddOrUpdateTextBlocklistItemsOptions(
@JsonProperty(value = "blocklistItems") List<TextBlocklistItem> blocklistItems) {
this.blocklistItems = blocklistItems;
}

/**
* Get the blocklistItems property: Array of blocklistItems to add.
*
* @return the blocklistItems value.
*/
@Generated
public List<TextBlocklistItem> getBlocklistItems() {
return this.blocklistItems;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.contentsafety.models;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.Immutable;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The response of adding blocklistItems to the text blocklist. */
@Immutable
public final class AddOrUpdateTextBlocklistItemsResult {
/*
* Array of blocklistItems have been added.
*/
@Generated
@JsonProperty(value = "blocklistItems")
private List<TextBlocklistItem> blocklistItems;

/**
* Creates an instance of AddOrUpdateTextBlocklistItemsResult class.
*
* @param blocklistItems the blocklistItems value to set.
*/
@Generated
@JsonCreator
private AddOrUpdateTextBlocklistItemsResult(
@JsonProperty(value = "blocklistItems") List<TextBlocklistItem> blocklistItems) {
this.blocklistItems = blocklistItems;
}

/**
* Get the blocklistItems property: Array of blocklistItems have been added.
*
* @return the blocklistItems value.
*/
@Generated
public List<TextBlocklistItem> getBlocklistItems() {
return this.blocklistItems;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;

/** The analysis request of the image. */
/** The image analysis request. */
@Fluent
public final class AnalyzeImageOptions {
/*
Expand All @@ -21,13 +21,21 @@ public final class AnalyzeImageOptions {
private ImageData image;

/*
* The categories will be analyzed. If not assigned, a default set of the categories' analysis results will be
* returned.
* The categories will be analyzed. If they are not assigned, a default set of analysis results for the categories
* will be returned.
*/
@Generated
@JsonProperty(value = "categories")
private List<ImageCategory> categories;

/*
* This refers to the type of image analysis output. If no value is assigned, the default value will be
* "FourSeverityLevels".
*/
@Generated
@JsonProperty(value = "outputType")
private AnalyzeImageOutputType outputType;

/**
* Creates an instance of AnalyzeImageOptions class.
*
Expand All @@ -50,8 +58,8 @@ public ImageData getImage() {
}

/**
* Get the categories property: The categories will be analyzed. If not assigned, a default set of the categories'
* analysis results will be returned.
* Get the categories property: The categories will be analyzed. If they are not assigned, a default set of analysis
* results for the categories will be returned.
*
* @return the categories value.
*/
Expand All @@ -61,8 +69,8 @@ public List<ImageCategory> getCategories() {
}

/**
* Set the categories property: The categories will be analyzed. If not assigned, a default set of the categories'
* analysis results will be returned.
* Set the categories property: The categories will be analyzed. If they are not assigned, a default set of analysis
* results for the categories will be returned.
*
* @param categories the categories value to set.
* @return the AnalyzeImageOptions object itself.
Expand All @@ -72,4 +80,28 @@ public AnalyzeImageOptions setCategories(List<ImageCategory> categories) {
this.categories = categories;
return this;
}

/**
* Get the outputType property: This refers to the type of image analysis output. If no value is assigned, the
* default value will be "FourSeverityLevels".
*
* @return the outputType value.
*/
@Generated
public AnalyzeImageOutputType getOutputType() {
return this.outputType;
}

/**
* Set the outputType property: This refers to the type of image analysis output. If no value is assigned, the
* default value will be "FourSeverityLevels".
*
* @param outputType the outputType value to set.
* @return the AnalyzeImageOptions object itself.
*/
@Generated
public AnalyzeImageOptions setOutputType(AnalyzeImageOutputType outputType) {
this.outputType = outputType;
return this;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) TypeSpec Code Generator.

package com.azure.ai.contentsafety.models;

import com.azure.core.annotation.Generated;
import com.azure.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.Collection;

/** The type of image analysis output. */
public final class AnalyzeImageOutputType extends ExpandableStringEnum<AnalyzeImageOutputType> {
/** Output severities in four levels, the value could be 0,2,4,6. */
@Generated public static final AnalyzeImageOutputType FOUR_SEVERITY_LEVELS = fromString("FourSeverityLevels");

/**
* Creates a new instance of AnalyzeImageOutputType value.
*
* @deprecated Use the {@link #fromString(String)} factory method.
*/
@Generated
@Deprecated
public AnalyzeImageOutputType() {}

/**
* Creates or finds a AnalyzeImageOutputType from its string representation.
*
* @param name a name to look for.
* @return the corresponding AnalyzeImageOutputType.
*/
@Generated
@JsonCreator
public static AnalyzeImageOutputType fromString(String name) {
return fromString(name, AnalyzeImageOutputType.class);
}

/**
* Gets known AnalyzeImageOutputType values.
*
* @return known AnalyzeImageOutputType values.
*/
@Generated
public static Collection<AnalyzeImageOutputType> values() {
return values(AnalyzeImageOutputType.class);
}
}
Loading