Skip to content

Commit

Permalink
OCM-10883 | feat: bump api model version
Browse files Browse the repository at this point in the history
  • Loading branch information
gdbranco committed Sep 9, 2024
1 parent efcb490 commit 093685d
Show file tree
Hide file tree
Showing 7 changed files with 4,381 additions and 3,891 deletions.
54 changes: 49 additions & 5 deletions clustersmgmt/v1/manifest_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,22 @@ limitations under the License.

package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1

import (
time "time"
)

// ManifestBuilder contains the data and logic needed to build 'manifest' objects.
//
// Representation of a manifestwork.
type ManifestBuilder struct {
bitmap_ uint32
id string
href string
workloads []interface{}
bitmap_ uint32
id string
href string
creationTimestamp time.Time
liveResource interface{}
spec interface{}
updatedTimestamp time.Time
workloads []interface{}
}

// NewManifest creates a new builder of 'manifest' objects.
Expand Down Expand Up @@ -59,11 +67,39 @@ func (b *ManifestBuilder) Empty() bool {
return b == nil || b.bitmap_&^1 == 0
}

// CreationTimestamp sets the value of the 'creation_timestamp' attribute to the given value.
func (b *ManifestBuilder) CreationTimestamp(value time.Time) *ManifestBuilder {
b.creationTimestamp = value
b.bitmap_ |= 8
return b
}

// LiveResource sets the value of the 'live_resource' attribute to the given value.
func (b *ManifestBuilder) LiveResource(value interface{}) *ManifestBuilder {
b.liveResource = value
b.bitmap_ |= 16
return b
}

// Spec sets the value of the 'spec' attribute to the given value.
func (b *ManifestBuilder) Spec(value interface{}) *ManifestBuilder {
b.spec = value
b.bitmap_ |= 32
return b
}

// UpdatedTimestamp sets the value of the 'updated_timestamp' attribute to the given value.
func (b *ManifestBuilder) UpdatedTimestamp(value time.Time) *ManifestBuilder {
b.updatedTimestamp = value
b.bitmap_ |= 64
return b
}

// Workloads sets the value of the 'workloads' attribute to the given values.
func (b *ManifestBuilder) Workloads(values ...interface{}) *ManifestBuilder {
b.workloads = make([]interface{}, len(values))
copy(b.workloads, values)
b.bitmap_ |= 8
b.bitmap_ |= 128
return b
}

Expand All @@ -75,6 +111,10 @@ func (b *ManifestBuilder) Copy(object *Manifest) *ManifestBuilder {
b.bitmap_ = object.bitmap_
b.id = object.id
b.href = object.href
b.creationTimestamp = object.creationTimestamp
b.liveResource = object.liveResource
b.spec = object.spec
b.updatedTimestamp = object.updatedTimestamp
if object.workloads != nil {
b.workloads = make([]interface{}, len(object.workloads))
copy(b.workloads, object.workloads)
Expand All @@ -90,6 +130,10 @@ func (b *ManifestBuilder) Build() (object *Manifest, err error) {
object.id = b.id
object.href = b.href
object.bitmap_ = b.bitmap_
object.creationTimestamp = b.creationTimestamp
object.liveResource = b.liveResource
object.spec = b.spec
object.updatedTimestamp = b.updatedTimestamp
if b.workloads != nil {
object.workloads = make([]interface{}, len(b.workloads))
copy(object.workloads, b.workloads)
Expand Down
112 changes: 106 additions & 6 deletions clustersmgmt/v1/manifest_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ limitations under the License.

package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1

import (
time "time"
)

// ManifestKind is the name of the type used to represent objects
// of type 'manifest'.
const ManifestKind = "Manifest"
Expand All @@ -35,10 +39,14 @@ const ManifestNilKind = "ManifestNil"
//
// Representation of a manifestwork.
type Manifest struct {
bitmap_ uint32
id string
href string
workloads []interface{}
bitmap_ uint32
id string
href string
creationTimestamp time.Time
liveResource interface{}
spec interface{}
updatedTimestamp time.Time
workloads []interface{}
}

// Kind returns the name of the type of the object.
Expand Down Expand Up @@ -98,12 +106,104 @@ func (o *Manifest) Empty() bool {
return o == nil || o.bitmap_&^1 == 0
}

// CreationTimestamp returns the value of the 'creation_timestamp' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Date and time when the manifest got created in clusters-service.
func (o *Manifest) CreationTimestamp() time.Time {
if o != nil && o.bitmap_&8 != 0 {
return o.creationTimestamp
}
return time.Time{}
}

// GetCreationTimestamp returns the value of the 'creation_timestamp' attribute and
// a flag indicating if the attribute has a value.
//
// Date and time when the manifest got created in clusters-service.
func (o *Manifest) GetCreationTimestamp() (value time.Time, ok bool) {
ok = o != nil && o.bitmap_&8 != 0
if ok {
value = o.creationTimestamp
}
return
}

// LiveResource returns the value of the 'live_resource' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Transient value to represent the underyling live resource.
func (o *Manifest) LiveResource() interface{} {
if o != nil && o.bitmap_&16 != 0 {
return o.liveResource
}
return nil
}

// GetLiveResource returns the value of the 'live_resource' attribute and
// a flag indicating if the attribute has a value.
//
// Transient value to represent the underyling live resource.
func (o *Manifest) GetLiveResource() (value interface{}, ok bool) {
ok = o != nil && o.bitmap_&16 != 0
if ok {
value = o.liveResource
}
return
}

// Spec returns the value of the 'spec' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Spec of Manifest Work object from open cluster management.
func (o *Manifest) Spec() interface{} {
if o != nil && o.bitmap_&32 != 0 {
return o.spec
}
return nil
}

// GetSpec returns the value of the 'spec' attribute and
// a flag indicating if the attribute has a value.
//
// Spec of Manifest Work object from open cluster management.
func (o *Manifest) GetSpec() (value interface{}, ok bool) {
ok = o != nil && o.bitmap_&32 != 0
if ok {
value = o.spec
}
return
}

// UpdatedTimestamp returns the value of the 'updated_timestamp' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// Date and time when the manifest got updated in clusters-service.
func (o *Manifest) UpdatedTimestamp() time.Time {
if o != nil && o.bitmap_&64 != 0 {
return o.updatedTimestamp
}
return time.Time{}
}

// GetUpdatedTimestamp returns the value of the 'updated_timestamp' attribute and
// a flag indicating if the attribute has a value.
//
// Date and time when the manifest got updated in clusters-service.
func (o *Manifest) GetUpdatedTimestamp() (value time.Time, ok bool) {
ok = o != nil && o.bitmap_&64 != 0
if ok {
value = o.updatedTimestamp
}
return
}

// Workloads returns the value of the 'workloads' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// List of k8s objects to deploy on a hosted cluster.
func (o *Manifest) Workloads() []interface{} {
if o != nil && o.bitmap_&8 != 0 {
if o != nil && o.bitmap_&128 != 0 {
return o.workloads
}
return nil
Expand All @@ -114,7 +214,7 @@ func (o *Manifest) Workloads() []interface{} {
//
// List of k8s objects to deploy on a hosted cluster.
func (o *Manifest) GetWorkloads() (value []interface{}, ok bool) {
ok = o != nil && o.bitmap_&8 != 0
ok = o != nil && o.bitmap_&128 != 0
if ok {
value = o.workloads
}
Expand Down
67 changes: 65 additions & 2 deletions clustersmgmt/v1/manifest_type_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ package v1 // github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1

import (
"io"
"time"

jsoniter "github.com/json-iterator/go"
"github.com/openshift-online/ocm-sdk-go/helpers"
Expand Down Expand Up @@ -65,7 +66,43 @@ func writeManifest(object *Manifest, stream *jsoniter.Stream) {
count++
}
var present_ bool
present_ = object.bitmap_&8 != 0 && object.workloads != nil
present_ = object.bitmap_&8 != 0
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("creation_timestamp")
stream.WriteString((object.creationTimestamp).Format(time.RFC3339))
count++
}
present_ = object.bitmap_&16 != 0
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("live_resource")
stream.WriteVal(object.liveResource)
count++
}
present_ = object.bitmap_&32 != 0
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("spec")
stream.WriteVal(object.spec)
count++
}
present_ = object.bitmap_&64 != 0
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("updated_timestamp")
stream.WriteString((object.updatedTimestamp).Format(time.RFC3339))
count++
}
present_ = object.bitmap_&128 != 0 && object.workloads != nil
if present_ {
if count > 0 {
stream.WriteMore()
Expand Down Expand Up @@ -108,10 +145,36 @@ func readManifest(iterator *jsoniter.Iterator) *Manifest {
case "href":
object.href = iterator.ReadString()
object.bitmap_ |= 4
case "creation_timestamp":
text := iterator.ReadString()
value, err := time.Parse(time.RFC3339, text)
if err != nil {
iterator.ReportError("", err.Error())
}
object.creationTimestamp = value
object.bitmap_ |= 8
case "live_resource":
var value interface{}
iterator.ReadVal(&value)
object.liveResource = value
object.bitmap_ |= 16
case "spec":
var value interface{}
iterator.ReadVal(&value)
object.spec = value
object.bitmap_ |= 32
case "updated_timestamp":
text := iterator.ReadString()
value, err := time.Parse(time.RFC3339, text)
if err != nil {
iterator.ReportError("", err.Error())
}
object.updatedTimestamp = value
object.bitmap_ |= 64
case "workloads":
value := readInterfaceList(iterator)
object.workloads = value
object.bitmap_ |= 8
object.bitmap_ |= 128
default:
iterator.ReadAny()
}
Expand Down
Loading

0 comments on commit 093685d

Please sign in to comment.