Skip to content

Commit b158034

Browse files
lucamolteniwtrocki
authored andcommitted
Correct polymorphism in ClusterTarget/AddOnClusterTarget
1 parent c2a3168 commit b158034

18 files changed

Lines changed: 396 additions & 258 deletions

File tree

.openapi/connector_mgmt.yaml

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -759,34 +759,38 @@ components:
759759
`GET /api/connector_mgmt/v1/kafka_connector_types/{connector_type_id}`.
760760
761761
ClusterTarget:
762+
required:
763+
- kind
764+
properties:
765+
kind:
766+
type: string
767+
type: object
762768
discriminator:
763769
propertyName: kind
764770
mapping:
765771
addon: "#/components/schemas/AddonClusterTarget"
766772
cloud_provider: "#/components/schemas/CloudProviderClusterTarget"
767-
oneOf:
768-
- $ref: "#/components/schemas/AddonClusterTarget"
769-
- $ref: "#/components/schemas/CloudProviderClusterTarget"
770773

771774
AddonClusterTarget:
775+
allOf:
776+
- $ref: "#/components/schemas/ClusterTarget"
777+
- $ref: "#/components/schemas/AddonClusterTarget_allOf"
778+
779+
AddonClusterTarget_allOf:
772780
description: "Targets workloads to an addon cluster"
773781
type: object
774-
required:
775-
- kind
776782
properties:
777-
kind:
778-
type: string
779783
cluster_id:
780784
type: string
781785

782786
CloudProviderClusterTarget:
787+
allOf:
788+
- $ref: "#/components/schemas/ClusterTarget"
789+
- $ref: "#/components/schemas/CloudProviderClusterTarget_allOf"
790+
CloudProviderClusterTarget_allOf:
783791
description: "Targets workloads to a cloud provider"
784792
type: object
785-
required:
786-
- kind
787793
properties:
788-
kind:
789-
type: string
790794
cloud_provider:
791795
type: string
792796
region:

packages/connector-management-sdk/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,10 @@ Class | Method | HTTP request | Description
129129
## Documentation for Models
130130

131131
- [AddonClusterTarget](docs/AddonClusterTarget.md)
132+
- [AddonClusterTargetAllOf](docs/AddonClusterTargetAllOf.md)
132133
- [AddonParameter](docs/AddonParameter.md)
133134
- [CloudProviderClusterTarget](docs/CloudProviderClusterTarget.md)
135+
- [CloudProviderClusterTargetAllOf](docs/CloudProviderClusterTargetAllOf.md)
134136
- [ClusterTarget](docs/ClusterTarget.md)
135137
- [Connector](docs/Connector.md)
136138
- [ConnectorAllOf](docs/ConnectorAllOf.md)

packages/connector-management-sdk/api/openapi.yaml

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -995,32 +995,35 @@ components:
995995
addon: '#/components/schemas/AddonClusterTarget'
996996
cloud_provider: '#/components/schemas/CloudProviderClusterTarget'
997997
propertyName: kind
998-
oneOf:
999-
- $ref: '#/components/schemas/AddonClusterTarget'
1000-
- $ref: '#/components/schemas/CloudProviderClusterTarget'
1001-
AddonClusterTarget:
1002-
description: Targets workloads to an addon cluster
1003998
properties:
1004999
kind:
10051000
type: string
1006-
cluster_id:
1007-
type: string
10081001
required:
10091002
- kind
10101003
type: object
1004+
AddonClusterTarget:
1005+
allOf:
1006+
- $ref: '#/components/schemas/ClusterTarget'
1007+
- $ref: '#/components/schemas/AddonClusterTarget_allOf'
1008+
AddonClusterTarget_allOf:
1009+
description: Targets workloads to an addon cluster
1010+
properties:
1011+
cluster_id:
1012+
type: string
1013+
type: object
10111014
CloudProviderClusterTarget:
1015+
allOf:
1016+
- $ref: '#/components/schemas/ClusterTarget'
1017+
- $ref: '#/components/schemas/CloudProviderClusterTarget_allOf'
1018+
CloudProviderClusterTarget_allOf:
10121019
description: Targets workloads to a cloud provider
10131020
properties:
1014-
kind:
1015-
type: string
10161021
cloud_provider:
10171022
type: string
10181023
region:
10191024
type: string
10201025
multi_az:
10211026
type: boolean
1022-
required:
1023-
- kind
10241027
type: object
10251028
AddonParameterList:
10261029
description: A list of addon parameters

packages/connector-management-sdk/docs/AddonClusterTarget.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
# AddonClusterTarget
44

5-
Targets workloads to an addon cluster
65

76
## Properties
87

98
Name | Type | Description | Notes
109
------------ | ------------- | ------------- | -------------
11-
**kind** | **String** | |
1210
**clusterId** | **String** | | [optional]
1311

1412

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
# AddonClusterTargetAllOf
4+
5+
Targets workloads to an addon cluster
6+
7+
## Properties
8+
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**clusterId** | **String** | | [optional]
12+
13+
14+

packages/connector-management-sdk/docs/CloudProviderClusterTarget.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,11 @@
22

33
# CloudProviderClusterTarget
44

5-
Targets workloads to a cloud provider
65

76
## Properties
87

98
Name | Type | Description | Notes
109
------------ | ------------- | ------------- | -------------
11-
**kind** | **String** | |
1210
**cloudProvider** | **String** | | [optional]
1311
**region** | **String** | | [optional]
1412
**multiAz** | **Boolean** | | [optional]
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
3+
# CloudProviderClusterTargetAllOf
4+
5+
Targets workloads to a cloud provider
6+
7+
## Properties
8+
9+
Name | Type | Description | Notes
10+
------------ | ------------- | ------------- | -------------
11+
**cloudProvider** | **String** | | [optional]
12+
**region** | **String** | | [optional]
13+
**multiAz** | **Boolean** | | [optional]
14+
15+
16+

packages/connector-management-sdk/docs/ClusterTarget.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
Name | Type | Description | Notes
99
------------ | ------------- | ------------- | -------------
1010
**kind** | **String** | |
11-
**clusterId** | **String** | | [optional]
12-
**cloudProvider** | **String** | | [optional]
13-
**region** | **String** | | [optional]
14-
**multiAz** | **Boolean** | | [optional]
1511

1612

1713

packages/connector-management-sdk/src/main/java/com/openshift/cloud/api/connector/models/AddonClusterTarget.java

Lines changed: 17 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -18,56 +18,37 @@
1818
import com.fasterxml.jackson.annotation.JsonInclude;
1919
import com.fasterxml.jackson.annotation.JsonProperty;
2020
import com.fasterxml.jackson.annotation.JsonCreator;
21+
import com.fasterxml.jackson.annotation.JsonSubTypes;
22+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
2123
import com.fasterxml.jackson.annotation.JsonTypeName;
2224
import com.fasterxml.jackson.annotation.JsonValue;
25+
import com.openshift.cloud.api.connector.models.AddonClusterTarget;
26+
import com.openshift.cloud.api.connector.models.AddonClusterTargetAllOf;
27+
import com.openshift.cloud.api.connector.models.CloudProviderClusterTarget;
28+
import com.openshift.cloud.api.connector.models.ClusterTarget;
2329
import io.swagger.annotations.ApiModel;
2430
import io.swagger.annotations.ApiModelProperty;
2531
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
2632

2733
/**
28-
* Targets workloads to an addon cluster
34+
* AddonClusterTarget
2935
*/
30-
@ApiModel(description = "Targets workloads to an addon cluster")
3136
@JsonPropertyOrder({
32-
AddonClusterTarget.JSON_PROPERTY_KIND,
3337
AddonClusterTarget.JSON_PROPERTY_CLUSTER_ID
3438
})
3539
@JsonTypeName("AddonClusterTarget")
3640
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
37-
public class AddonClusterTarget {
38-
public static final String JSON_PROPERTY_KIND = "kind";
39-
private String kind;
41+
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.EXISTING_PROPERTY, property = "kind", visible = true)
42+
@JsonSubTypes({
43+
@JsonSubTypes.Type(value = AddonClusterTarget.class, name = "addon"),
44+
@JsonSubTypes.Type(value = CloudProviderClusterTarget.class, name = "cloud_provider"),
45+
})
4046

47+
public class AddonClusterTarget extends ClusterTarget {
4148
public static final String JSON_PROPERTY_CLUSTER_ID = "cluster_id";
4249
private String clusterId;
4350

4451

45-
public AddonClusterTarget kind(String kind) {
46-
47-
this.kind = kind;
48-
return this;
49-
}
50-
51-
/**
52-
* Get kind
53-
* @return kind
54-
**/
55-
@ApiModelProperty(required = true, value = "")
56-
@JsonProperty(JSON_PROPERTY_KIND)
57-
@JsonInclude(value = JsonInclude.Include.ALWAYS)
58-
59-
public String getKind() {
60-
return kind;
61-
}
62-
63-
64-
@JsonProperty(JSON_PROPERTY_KIND)
65-
@JsonInclude(value = JsonInclude.Include.ALWAYS)
66-
public void setKind(String kind) {
67-
this.kind = kind;
68-
}
69-
70-
7152
public AddonClusterTarget clusterId(String clusterId) {
7253

7354
this.clusterId = clusterId;
@@ -104,20 +85,20 @@ public boolean equals(Object o) {
10485
return false;
10586
}
10687
AddonClusterTarget addonClusterTarget = (AddonClusterTarget) o;
107-
return Objects.equals(this.kind, addonClusterTarget.kind) &&
108-
Objects.equals(this.clusterId, addonClusterTarget.clusterId);
88+
return Objects.equals(this.clusterId, addonClusterTarget.clusterId) &&
89+
super.equals(o);
10990
}
11091

11192
@Override
11293
public int hashCode() {
113-
return Objects.hash(kind, clusterId);
94+
return Objects.hash(clusterId, super.hashCode());
11495
}
11596

11697
@Override
11798
public String toString() {
11899
StringBuilder sb = new StringBuilder();
119100
sb.append("class AddonClusterTarget {\n");
120-
sb.append(" kind: ").append(toIndentedString(kind)).append("\n");
101+
sb.append(" ").append(toIndentedString(super.toString())).append("\n");
121102
sb.append(" clusterId: ").append(toIndentedString(clusterId)).append("\n");
122103
sb.append("}");
123104
return sb.toString();
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
/*
2+
* Connector Service Fleet Manager
3+
* Connector Service Fleet Manager is a Rest API to manage connectors.
4+
*
5+
* The version of the OpenAPI document: 0.0.3
6+
*
7+
*
8+
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9+
* https://openapi-generator.tech
10+
* Do not edit the class manually.
11+
*/
12+
13+
14+
package com.openshift.cloud.api.connector.models;
15+
16+
import java.util.Objects;
17+
import java.util.Arrays;
18+
import com.fasterxml.jackson.annotation.JsonInclude;
19+
import com.fasterxml.jackson.annotation.JsonProperty;
20+
import com.fasterxml.jackson.annotation.JsonCreator;
21+
import com.fasterxml.jackson.annotation.JsonTypeName;
22+
import com.fasterxml.jackson.annotation.JsonValue;
23+
import io.swagger.annotations.ApiModel;
24+
import io.swagger.annotations.ApiModelProperty;
25+
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
26+
27+
/**
28+
* Targets workloads to an addon cluster
29+
*/
30+
@ApiModel(description = "Targets workloads to an addon cluster")
31+
@JsonPropertyOrder({
32+
AddonClusterTargetAllOf.JSON_PROPERTY_CLUSTER_ID
33+
})
34+
@JsonTypeName("AddonClusterTarget_allOf")
35+
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen")
36+
public class AddonClusterTargetAllOf {
37+
public static final String JSON_PROPERTY_CLUSTER_ID = "cluster_id";
38+
private String clusterId;
39+
40+
41+
public AddonClusterTargetAllOf clusterId(String clusterId) {
42+
43+
this.clusterId = clusterId;
44+
return this;
45+
}
46+
47+
/**
48+
* Get clusterId
49+
* @return clusterId
50+
**/
51+
@javax.annotation.Nullable
52+
@ApiModelProperty(value = "")
53+
@JsonProperty(JSON_PROPERTY_CLUSTER_ID)
54+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
55+
56+
public String getClusterId() {
57+
return clusterId;
58+
}
59+
60+
61+
@JsonProperty(JSON_PROPERTY_CLUSTER_ID)
62+
@JsonInclude(value = JsonInclude.Include.USE_DEFAULTS)
63+
public void setClusterId(String clusterId) {
64+
this.clusterId = clusterId;
65+
}
66+
67+
68+
@Override
69+
public boolean equals(Object o) {
70+
if (this == o) {
71+
return true;
72+
}
73+
if (o == null || getClass() != o.getClass()) {
74+
return false;
75+
}
76+
AddonClusterTargetAllOf addonClusterTargetAllOf = (AddonClusterTargetAllOf) o;
77+
return Objects.equals(this.clusterId, addonClusterTargetAllOf.clusterId);
78+
}
79+
80+
@Override
81+
public int hashCode() {
82+
return Objects.hash(clusterId);
83+
}
84+
85+
@Override
86+
public String toString() {
87+
StringBuilder sb = new StringBuilder();
88+
sb.append("class AddonClusterTargetAllOf {\n");
89+
sb.append(" clusterId: ").append(toIndentedString(clusterId)).append("\n");
90+
sb.append("}");
91+
return sb.toString();
92+
}
93+
94+
/**
95+
* Convert the given object to string with each line indented by 4 spaces
96+
* (except the first line).
97+
*/
98+
private String toIndentedString(Object o) {
99+
if (o == null) {
100+
return "null";
101+
}
102+
return o.toString().replace("\n", "\n ");
103+
}
104+
105+
}
106+

0 commit comments

Comments
 (0)