Skip to content

Commit

Permalink
Regenerate client from commit 957a4550 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Feb 4, 2025
1 parent 0ebdaeb commit ffa32c2
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-04 14:10:00.992806",
"spec_repo_commit": "4fb9047a"
"regenerated": "2025-02-04 21:28:24.827859",
"spec_repo_commit": "957a4550"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2025-02-04 14:10:01.007762",
"spec_repo_commit": "4fb9047a"
"regenerated": "2025-02-04 21:28:24.843320",
"spec_repo_commit": "957a4550"
}
}
}
18 changes: 17 additions & 1 deletion .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1965,6 +1965,22 @@ components:
deployment:
$ref: '#/components/schemas/DeploymentRelationship'
type: object
AppVersionSelector:
description: The version selector parameter used in endpoints such as Get App
oneOf:
- $ref: '#/components/schemas/AppVersionSelectorConstants'
- format: int64
minimum: 0
type: integer
AppVersionSelectorConstants:
description: Constants that always select a particular version of an app
enum:
- latest
- deployed
type: string
x-enum-varnames:
- LATEST
- DEPLOYED
ApplicationKeyCreateAttributes:
description: Attributes used to create an application Key.
properties:
Expand Down Expand Up @@ -32494,7 +32510,7 @@ paths:
name: version
required: false
schema:
type: string
$ref: '#/components/schemas/AppVersionSelector'
responses:
'200':
content:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ public CompletableFuture<ApiResponse<DeleteAppsResponse>> deleteAppsWithHttpInfo

/** Manage optional parameters to getApp. */
public static class GetAppOptionalParameters {
private String version;
private AppVersionSelector version;

/**
* Set version.
Expand All @@ -512,7 +512,7 @@ public static class GetAppOptionalParameters {
* latest version or the published version, respectively. (optional)
* @return GetAppOptionalParameters
*/
public GetAppOptionalParameters version(String version) {
public GetAppOptionalParameters version(AppVersionSelector version) {
this.version = version;
return this;
}
Expand Down Expand Up @@ -613,7 +613,7 @@ public ApiResponse<GetAppResponse> getAppWithHttpInfo(
if (appId == null) {
throw new ApiException(400, "Missing the required parameter 'appId' when calling getApp");
}
String version = parameters.version;
AppVersionSelector version = parameters.version;
// create path and map variables
String localVarPath =
"/api/v2/app-builder/apps/{app_id}"
Expand Down Expand Up @@ -674,7 +674,7 @@ public CompletableFuture<ApiResponse<GetAppResponse>> getAppWithHttpInfoAsync(
new ApiException(400, "Missing the required parameter 'appId' when calling getApp"));
return result;
}
String version = parameters.version;
AppVersionSelector version = parameters.version;
// create path and map variables
String localVarPath =
"/api/v2/app-builder/apps/{app_id}"
Expand Down
271 changes: 271 additions & 0 deletions src/main/java/com/datadog/api/client/v2/model/AppVersionSelector.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,271 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/

package com.datadog.api.client.v2.model;

import com.datadog.api.client.AbstractOpenApiSchema;
import com.datadog.api.client.JSON;
import com.datadog.api.client.UnparsedObject;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonToken;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import jakarta.ws.rs.core.GenericType;
import java.io.IOException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;

@jakarta.annotation.Generated(
value = "https://github.com/DataDog/datadog-api-client-java/blob/master/.generator")
@JsonDeserialize(using = AppVersionSelector.AppVersionSelectorDeserializer.class)
@JsonSerialize(using = AppVersionSelector.AppVersionSelectorSerializer.class)
public class AppVersionSelector extends AbstractOpenApiSchema {
private static final Logger log = Logger.getLogger(AppVersionSelector.class.getName());

@JsonIgnore public boolean unparsed = false;

public static class AppVersionSelectorSerializer extends StdSerializer<AppVersionSelector> {
public AppVersionSelectorSerializer(Class<AppVersionSelector> t) {
super(t);
}

public AppVersionSelectorSerializer() {
this(null);
}

@Override
public void serialize(AppVersionSelector value, JsonGenerator jgen, SerializerProvider provider)
throws IOException, JsonProcessingException {
jgen.writeObject(value.getActualInstance());
}
}

public static class AppVersionSelectorDeserializer extends StdDeserializer<AppVersionSelector> {
public AppVersionSelectorDeserializer() {
this(AppVersionSelector.class);
}

public AppVersionSelectorDeserializer(Class<?> vc) {
super(vc);
}

@Override
public AppVersionSelector deserialize(JsonParser jp, DeserializationContext ctxt)
throws IOException, JsonProcessingException {
JsonNode tree = jp.readValueAsTree();
Object deserialized = null;
Object tmp = null;
boolean typeCoercion = ctxt.isEnabled(MapperFeature.ALLOW_COERCION_OF_SCALARS);
int match = 0;
JsonToken token = tree.traverse(jp.getCodec()).nextToken();
// deserialize AppVersionSelectorConstants
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (AppVersionSelectorConstants.class.equals(Integer.class)
|| AppVersionSelectorConstants.class.equals(Long.class)
|| AppVersionSelectorConstants.class.equals(Float.class)
|| AppVersionSelectorConstants.class.equals(Double.class)
|| AppVersionSelectorConstants.class.equals(Boolean.class)
|| AppVersionSelectorConstants.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((AppVersionSelectorConstants.class.equals(Integer.class)
|| AppVersionSelectorConstants.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((AppVersionSelectorConstants.class.equals(Float.class)
|| AppVersionSelectorConstants.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(AppVersionSelectorConstants.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |=
(AppVersionSelectorConstants.class.equals(String.class)
&& token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(AppVersionSelectorConstants.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
if (!((AppVersionSelectorConstants) tmp).unparsed) {
deserialized = tmp;
match++;
}
log.log(Level.FINER, "Input data matches schema 'AppVersionSelectorConstants'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'AppVersionSelectorConstants'", e);
}

// deserialize Long
try {
boolean attemptParsing = true;
// ensure that we respect type coercion as set on the client ObjectMapper
if (Long.class.equals(Integer.class)
|| Long.class.equals(Long.class)
|| Long.class.equals(Float.class)
|| Long.class.equals(Double.class)
|| Long.class.equals(Boolean.class)
|| Long.class.equals(String.class)) {
attemptParsing = typeCoercion;
if (!attemptParsing) {
attemptParsing |=
((Long.class.equals(Integer.class) || Long.class.equals(Long.class))
&& token == JsonToken.VALUE_NUMBER_INT);
attemptParsing |=
((Long.class.equals(Float.class) || Long.class.equals(Double.class))
&& (token == JsonToken.VALUE_NUMBER_FLOAT
|| token == JsonToken.VALUE_NUMBER_INT));
attemptParsing |=
(Long.class.equals(Boolean.class)
&& (token == JsonToken.VALUE_FALSE || token == JsonToken.VALUE_TRUE));
attemptParsing |= (Long.class.equals(String.class) && token == JsonToken.VALUE_STRING);
}
}
if (attemptParsing) {
tmp = tree.traverse(jp.getCodec()).readValueAs(Long.class);
// TODO: there is no validation against JSON schema constraints
// (min, max, enum, pattern...), this does not perform a strict JSON
// validation, which means the 'match' count may be higher than it should be.
deserialized = tmp;
match++;

log.log(Level.FINER, "Input data matches schema 'Long'");
}
} catch (Exception e) {
// deserialization failed, continue
log.log(Level.FINER, "Input data does not match schema 'Long'", e);
}

AppVersionSelector ret = new AppVersionSelector();
if (match == 1) {
ret.setActualInstance(deserialized);
} else {
Map<String, Object> res =
new ObjectMapper()
.readValue(
tree.traverse(jp.getCodec()).readValueAsTree().toString(),
new TypeReference<Map<String, Object>>() {});
ret.setActualInstance(new UnparsedObject(res));
}
return ret;
}

/** Handle deserialization of the 'null' value. */
@Override
public AppVersionSelector getNullValue(DeserializationContext ctxt)
throws JsonMappingException {
throw new JsonMappingException(ctxt.getParser(), "AppVersionSelector cannot be null");
}
}

// store a list of schema names defined in oneOf
public static final Map<String, GenericType> schemas = new HashMap<String, GenericType>();

public AppVersionSelector() {
super("oneOf", Boolean.FALSE);
}

public AppVersionSelector(AppVersionSelectorConstants o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

public AppVersionSelector(Long o) {
super("oneOf", Boolean.FALSE);
setActualInstance(o);
}

static {
schemas.put("AppVersionSelectorConstants", new GenericType<AppVersionSelectorConstants>() {});
schemas.put("Long", new GenericType<Long>() {});
JSON.registerDescendants(AppVersionSelector.class, Collections.unmodifiableMap(schemas));
}

@Override
public Map<String, GenericType> getSchemas() {
return AppVersionSelector.schemas;
}

/**
* Set the instance that matches the oneOf child schema, check the instance parameter is valid
* against the oneOf child schemas: AppVersionSelectorConstants, Long
*
* <p>It could be an instance of the 'oneOf' schemas. The oneOf child schemas may themselves be a
* composed schema (allOf, anyOf, oneOf).
*/
@Override
public void setActualInstance(Object instance) {
if (JSON.isInstanceOf(AppVersionSelectorConstants.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
if (JSON.isInstanceOf(Long.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}

if (JSON.isInstanceOf(UnparsedObject.class, instance, new HashSet<Class<?>>())) {
super.setActualInstance(instance);
return;
}
throw new RuntimeException("Invalid instance type. Must be AppVersionSelectorConstants, Long");
}

/**
* Get the actual instance, which can be the following: AppVersionSelectorConstants, Long
*
* @return The actual instance (AppVersionSelectorConstants, Long)
*/
@Override
public Object getActualInstance() {
return super.getActualInstance();
}

/**
* Get the actual instance of `AppVersionSelectorConstants`. If the actual instance is not
* `AppVersionSelectorConstants`, the ClassCastException will be thrown.
*
* @return The actual instance of `AppVersionSelectorConstants`
* @throws ClassCastException if the instance is not `AppVersionSelectorConstants`
*/
public AppVersionSelectorConstants getAppVersionSelectorConstants() throws ClassCastException {
return (AppVersionSelectorConstants) super.getActualInstance();
}

/**
* Get the actual instance of `Long`. If the actual instance is not `Long`, the ClassCastException
* will be thrown.
*
* @return The actual instance of `Long`
* @throws ClassCastException if the instance is not `Long`
*/
public Long getLong() throws ClassCastException {
return (Long) super.getActualInstance();
}
}
Loading

0 comments on commit ffa32c2

Please sign in to comment.