Skip to content

Commit

Permalink
fix(ATracker V2): re-gen service after recent API changes (#188)
Browse files Browse the repository at this point in the history
  • Loading branch information
johnymathew authored May 11, 2022
1 parent 11ceaec commit 25d7447
Show file tree
Hide file tree
Showing 4 changed files with 182 additions and 237 deletions.
154 changes: 53 additions & 101 deletions atrackerv2/atracker_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.45.1-632ec580-20220210-190638
* IBM OpenAPI SDK Code Generator Version: 3.49.0-be9b22fb-20220504-154308
*/

// Package atrackerv2 : Operations and models for the AtrackerV2 service
Expand Down Expand Up @@ -119,8 +119,10 @@ func GetServiceURLForRegion(region string) (string, error) {
"private.us-east": "https://private.us-east.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the us-east region.
"eu-de": "https://eu-de.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the eu-de region.
"private.eu-de": "https://private.eu-de.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the eu-de region.
"eu-gb": "https://eu-gb.atracker.cloud.ibm.com", // The public server for IBM Cloud Activity Tracker Service in the eu-gb region.
"private.eu-gb": "https://private.eu-gb.atracker.cloud.ibm.com", // The private server for IBM Cloud Activity Tracker Service in the eu-gb region.
"eu-gb": "https://eu-gb.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the eu-gb region.
"private.eu-gb": "https://private.eu-gb.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the eu-gb region.
"au-syd": "https://au-syd.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the au-syd region.
"private.au-syd": "https://private.au-syd.atracker.cloud.ibm.com", // The server for IBM Cloud Activity Tracker Service in the au-syd region.
}

if url, ok := endpoints[region]; ok {
Expand Down Expand Up @@ -415,18 +417,12 @@ func (atracker *AtrackerV2) ReplaceTargetWithContext(ctx context.Context, replac
if replaceTargetOptions.Name != nil {
body["name"] = replaceTargetOptions.Name
}
if replaceTargetOptions.TargetType != nil {
body["target_type"] = replaceTargetOptions.TargetType
}
if replaceTargetOptions.CosEndpoint != nil {
body["cos_endpoint"] = replaceTargetOptions.CosEndpoint
}
if replaceTargetOptions.LogdnaEndpoint != nil {
body["logdna_endpoint"] = replaceTargetOptions.LogdnaEndpoint
}
if replaceTargetOptions.Region != nil {
body["region"] = replaceTargetOptions.Region
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
return
Expand Down Expand Up @@ -1007,8 +1003,8 @@ func (atracker *AtrackerV2) PutSettingsWithContext(ctx context.Context, putSetti
return
}

// PostMigration : Migrate v1 atracker resources to v2 atracker resources
// Migrate all v1 atracker targets and routes to v2 atracker targets and routes under an IBM account.
// PostMigration : Migrate Activity Tracker Event Routing configurations from v1 to v2
// Migrate all v1 Activity Tracker Event Routing targets and routes to v2 under an IBM account.
func (atracker *AtrackerV2) PostMigration(postMigrationOptions *PostMigrationOptions) (result *Migration, response *core.DetailedResponse, err error) {
return atracker.PostMigrationWithContext(context.Background(), postMigrationOptions)
}
Expand Down Expand Up @@ -1059,8 +1055,9 @@ func (atracker *AtrackerV2) PostMigrationWithContext(ctx context.Context, postMi
return
}

// GetMigration : get migration status
// retrieve migration process and status.
// GetMigration : Get the migration status
// Retrieve the status of the migration process. This can be used after the POST /migration to monitor the progress of
// the migration process.
func (atracker *AtrackerV2) GetMigration(getMigrationOptions *GetMigrationOptions) (result *Migration, response *core.DetailedResponse, err error) {
return atracker.GetMigrationWithContext(context.Background(), getMigrationOptions)
}
Expand Down Expand Up @@ -1111,7 +1108,7 @@ func (atracker *AtrackerV2) GetMigrationWithContext(ctx context.Context, getMigr
return
}

// CosEndpoint : Property values for a Cloud Object Storage Endpoint.
// CosEndpoint : Property values for a Cloud Object Storage Endpoint in responses.
type CosEndpoint struct {
// The host name of the Cloud Object Storage endpoint.
Endpoint *string `json:"endpoint" validate:"required"`
Expand All @@ -1122,10 +1119,6 @@ type CosEndpoint struct {
// The bucket name under the Cloud Object Storage instance.
Bucket *string `json:"bucket" validate:"required"`

// The IAM API key that has writer access to the Cloud Object Storage instance. This credential is masked in the
// response. This is required if service_to_service is not enabled.
APIKey *string `json:"api_key,omitempty"`

// ATracker service is enabled to support service to service authentication. If service to service is enabled then set
// this flag is true and do not supply apikey.
ServiceToServiceEnabled *bool `json:"service_to_service_enabled" validate:"required"`
Expand All @@ -1146,19 +1139,14 @@ func UnmarshalCosEndpoint(m map[string]json.RawMessage, result interface{}) (err
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "api_key", &obj.APIKey)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "service_to_service_enabled", &obj.ServiceToServiceEnabled)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}

// CosEndpointPrototype : Property values for a Cloud Object Storage Endpoint.
// CosEndpointPrototype : Property values for a Cloud Object Storage Endpoint in requests.
type CosEndpointPrototype struct {
// The host name of the Cloud Object Storage endpoint.
Endpoint *string `json:"endpoint" validate:"required"`
Expand Down Expand Up @@ -1264,11 +1252,11 @@ type CreateTargetOptions struct {
// The type of the target. It can be cloud_object_storage or logdna. Based on this type you must include cos_endpoint
// or logdna_endpoint.
TargetType *string `json:"target_type" validate:"required"`

// Property values for a Cloud Object Storage Endpoint.
// Property values for a Cloud Object Storage Endpoint in requests.
CosEndpoint *CosEndpointPrototype `json:"cos_endpoint,omitempty"`

// Property values for a LogDNA Endpoint.
// Property values for a LogDNA Endpoint in requests.
LogdnaEndpoint *LogdnaEndpointPrototype `json:"logdna_endpoint,omitempty"`

// Include this optional field if you want to create a target in a different region other than the one you are
Expand Down Expand Up @@ -1532,13 +1520,10 @@ func (options *ListTargetsOptions) SetHeaders(param map[string]string) *ListTarg
return options
}

// LogdnaEndpoint : Property values for a LogDNA Endpoint.
// LogdnaEndpoint : Property values for a LogDNA Endpoint in responses.
type LogdnaEndpoint struct {
// The CRN of the LogDNA instance.
TargetCRN *string `json:"target_crn" validate:"required"`

// The LogDNA ingestion key is used for routing logs to a specific LogDNA instance.
IngestionKey *string `json:"ingestion_key" validate:"required"`
}

// UnmarshalLogdnaEndpoint unmarshals an instance of LogdnaEndpoint from the specified map of raw messages.
Expand All @@ -1548,15 +1533,11 @@ func UnmarshalLogdnaEndpoint(m map[string]json.RawMessage, result interface{}) (
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "ingestion_key", &obj.IngestionKey)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}

// LogdnaEndpointPrototype : Property values for a LogDNA Endpoint.
// LogdnaEndpointPrototype : Property values for a LogDNA Endpoint in requests.
type LogdnaEndpointPrototype struct {
// The CRN of the LogDNA instance.
TargetCRN *string `json:"target_crn" validate:"required"`
Expand Down Expand Up @@ -1590,20 +1571,20 @@ func UnmarshalLogdnaEndpointPrototype(m map[string]json.RawMessage, result inter
return
}

// Migration : Atracker migration response.
// Migration : The Activity Tracker Event Routing migration response contains an overall status of the migration process.
type Migration struct {
// Overall migration progress in percentage.
// The overall migration progress as a percentage.
Progress *int64 `json:"progress" validate:"required"`

// Overall status of the migration.
// The overall status of the migration.
Status *string `json:"status" validate:"required"`

// Migration item lists.
// List containing the migration status for each of the routes and targets that are or will be migrated.
MigrationItems []MigrationItem `json:"migration_items" validate:"required"`
}

// Constants associated with the Migration.Status property.
// Overall status of the migration.
// The overall status of the migration.
const (
MigrationStatusCanceledConst = "canceled"
MigrationStatusCompletedConst = "completed"
Expand Down Expand Up @@ -1633,41 +1614,43 @@ func UnmarshalMigration(m map[string]json.RawMessage, result interface{}) (err e
return
}

// MigrationItem : Atracker migration item.
// MigrationItem : The Activity Tracker Event Routing migration status for an individual route or target.
type MigrationItem struct {
// Type of the migration item.
// The type of the resource being migrated.
ResourceType *string `json:"resource_type" validate:"required"`

// Migration item id.
// The uuid of the route or target.
ID *string `json:"id" validate:"required"`

// the region where the resource is defined.
// The region where the resource is defined.
Region *string `json:"region" validate:"required"`

// Migration item status.
// The status of the migration for this resource.
Status *string `json:"status" validate:"required"`

// detailed status of this migration.
// The detailed status message of the migration for this resource. In the event of a failure this will contain the
// details as to why the migration failed for this resource.
DetailedStatus []string `json:"detailed_status" validate:"required"`

// Migration error encountered.
Error *string `json:"error,omitempty"`
}

// Constants associated with the MigrationItem.ResourceType property.
// Type of the migration item.
// The type of the resource being migrated.
const (
MigrationItemResourceTypePrivateEndpointConst = "private_endpoint"
MigrationItemResourceTypeRouteConst = "route"
MigrationItemResourceTypeTargetConst = "target"
)

// Constants associated with the MigrationItem.Status property.
// Migration item status.
// The status of the migration for this resource.
const (
MigrationItemStatusCompletedConst = "completed"
MigrationItemStatusFailedConst = "failed"
MigrationItemStatusInProgressConst = "in_progress"
MigrationItemStatusNotStartedConst = "not_started"
MigrationItemStatusPendingConst = "pending"
)

Expand Down Expand Up @@ -1833,40 +1816,22 @@ type ReplaceTargetOptions struct {

// The name of the target. The name must be 1000 characters or less, and cannot include any special characters other
// than `(space) - . _ :`.
Name *string `json:"name" validate:"required"`

// The type of the target. It can be cloud_object_storage or logdna. Based on this type you must include cos_endpoint
// or logdna_endpoint.
TargetType *string `json:"target_type" validate:"required"`
Name *string `json:"name,omitempty"`

// Property values for a Cloud Object Storage Endpoint.
// Property values for a Cloud Object Storage Endpoint in requests.
CosEndpoint *CosEndpointPrototype `json:"cos_endpoint,omitempty"`

// Property values for a LogDNA Endpoint.
// Property values for a LogDNA Endpoint in requests.
LogdnaEndpoint *LogdnaEndpointPrototype `json:"logdna_endpoint,omitempty"`

// Include this optional field if you want to create a target in a different region other than the one you are
// connected.
Region *string `json:"region,omitempty"`

// Allows users to set headers on API requests
Headers map[string]string
}

// Constants associated with the ReplaceTargetOptions.TargetType property.
// The type of the target. It can be cloud_object_storage or logdna. Based on this type you must include cos_endpoint or
// logdna_endpoint.
const (
ReplaceTargetOptionsTargetTypeCloudObjectStorageConst = "cloud_object_storage"
ReplaceTargetOptionsTargetTypeLogdnaConst = "logdna"
)

// NewReplaceTargetOptions : Instantiate ReplaceTargetOptions
func (*AtrackerV2) NewReplaceTargetOptions(id string, name string, targetType string) *ReplaceTargetOptions {
func (*AtrackerV2) NewReplaceTargetOptions(id string) *ReplaceTargetOptions {
return &ReplaceTargetOptions{
ID: core.StringPtr(id),
Name: core.StringPtr(name),
TargetType: core.StringPtr(targetType),
ID: core.StringPtr(id),
}
}

Expand All @@ -1882,12 +1847,6 @@ func (_options *ReplaceTargetOptions) SetName(name string) *ReplaceTargetOptions
return _options
}

// SetTargetType : Allow user to set TargetType
func (_options *ReplaceTargetOptions) SetTargetType(targetType string) *ReplaceTargetOptions {
_options.TargetType = core.StringPtr(targetType)
return _options
}

// SetCosEndpoint : Allow user to set CosEndpoint
func (_options *ReplaceTargetOptions) SetCosEndpoint(cosEndpoint *CosEndpointPrototype) *ReplaceTargetOptions {
_options.CosEndpoint = cosEndpoint
Expand All @@ -1900,12 +1859,6 @@ func (_options *ReplaceTargetOptions) SetLogdnaEndpoint(logdnaEndpoint *LogdnaEn
return _options
}

// SetRegion : Allow user to set Region
func (_options *ReplaceTargetOptions) SetRegion(region string) *ReplaceTargetOptions {
_options.Region = core.StringPtr(region)
return _options
}

// SetHeaders : Allow user to set Headers
func (options *ReplaceTargetOptions) SetHeaders(param map[string]string) *ReplaceTargetOptions {
options.Headers = param
Expand Down Expand Up @@ -1939,6 +1892,9 @@ type Route struct {

// The API version of the route.
APIVersion *int64 `json:"api_version" validate:"required"`

// An optional message containing information about the route.
Message *string `json:"message,omitempty"`
}

// UnmarshalRoute unmarshals an instance of Route from the specified map of raw messages.
Expand Down Expand Up @@ -1976,6 +1932,10 @@ func UnmarshalRoute(m map[string]json.RawMessage, result interface{}) (err error
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "message", &obj.Message)
if err != nil {
return
}
reflect.ValueOf(result).Elem().Set(reflect.ValueOf(obj))
return
}
Expand Down Expand Up @@ -2058,7 +2018,7 @@ func UnmarshalRulePrototype(m map[string]json.RawMessage, result interface{}) (e
return
}

// Settings : Activity Tracker settings response.
// Settings : Activity Tracker Event Routing settings response.
type Settings struct {
// The target ID List. In the event that no routing rule causes the event to be sent to a target, these targets will
// receive the event.
Expand All @@ -2068,7 +2028,8 @@ type Settings struct {
PermittedTargetRegions []string `json:"permitted_target_regions" validate:"required"`

// To store all your meta data in a single region.
MetadataRegionPrimary *string `json:"metadata_region_primary,omitempty"`

MetadataRegionPrimary *string `json:"metadata_region_primary" validate:"required"`

// If you set this true then you cannot access api through public network.
PrivateAPIEndpointOnly *bool `json:"private_api_endpoint_only" validate:"required"`
Expand Down Expand Up @@ -2104,8 +2065,7 @@ func UnmarshalSettings(m map[string]json.RawMessage, result interface{}) (err er
return
}

// Target : Property values for a target in the response. Credentials associated with the target are encrypted and masked as
// REDACTED in the response.
// Target : Property values for a target in responses.
type Target struct {
// The uuid of the target resource.
ID *string `json:"id" validate:"required"`
Expand All @@ -2123,14 +2083,10 @@ type Target struct {
// connected.
Region *string `json:"region,omitempty"`

// The encryption key that is used to encrypt events before Activity Tracker services buffer them on storage. This
// credential is masked in the response.
EncryptionKey *string `json:"encryption_key,omitempty"`

// Property values for a Cloud Object Storage Endpoint.
// Property values for a Cloud Object Storage Endpoint in responses.
CosEndpoint *CosEndpoint `json:"cos_endpoint,omitempty"`

// Property values for a LogDNA Endpoint.
// Property values for a LogDNA Endpoint in responses.
LogdnaEndpoint *LogdnaEndpoint `json:"logdna_endpoint,omitempty"`

// The status of the write attempt to the target with the provided endpoint parameters.
Expand Down Expand Up @@ -2176,10 +2132,6 @@ func UnmarshalTarget(m map[string]json.RawMessage, result interface{}) (err erro
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "encryption_key", &obj.EncryptionKey)
if err != nil {
return
}
err = core.UnmarshalModel(m, "cos_endpoint", &obj.CosEndpoint, UnmarshalCosEndpoint)
if err != nil {
return
Expand Down Expand Up @@ -2280,13 +2232,13 @@ func UnmarshalWarning(m map[string]json.RawMessage, result interface{}) (err err
// WarningReport : Description of a warning that occurred in a service request.
type WarningReport struct {
// The status code.
StatusCode *int64 `json:"status_code" validate:"required"`
StatusCode *int64 `json:"status_code,omitempty"`

// The transaction-id of the API request.
Trace *string `json:"trace" validate:"required"`
Trace *string `json:"trace,omitempty"`

// The warning array triggered by the API request.
Warnings []Warning `json:"warnings" validate:"required"`
Warnings []Warning `json:"warnings,omitempty"`
}

// UnmarshalWarningReport unmarshals an instance of WarningReport from the specified map of raw messages.
Expand Down
Loading

0 comments on commit 25d7447

Please sign in to comment.