Skip to content

Commit

Permalink
fix(Open Service Broker): re-gen service with latest API
Browse files Browse the repository at this point in the history
  • Loading branch information
padamstx committed Dec 11, 2020
1 parent 1e39db0 commit c6401b1
Show file tree
Hide file tree
Showing 4 changed files with 240 additions and 85 deletions.
69 changes: 42 additions & 27 deletions openservicebrokerv1/open_service_broker_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-8d569e8f-20201030-111043
* IBM OpenAPI SDK Code Generator Version: 99-SNAPSHOT-d753183b-20201209-163011
*/


Expand Down Expand Up @@ -107,6 +107,21 @@ func NewOpenServiceBrokerV1(options *OpenServiceBrokerV1Options) (service *OpenS
return
}

// GetServiceURLForRegion returns the service URL to be used for the specified region
func GetServiceURLForRegion(region string) (string, error) {
return "", fmt.Errorf("service does not support regional URLs")
}

// Clone makes a copy of "openServiceBroker" suitable for processing requests.
func (openServiceBroker *OpenServiceBrokerV1) Clone() *OpenServiceBrokerV1 {
if core.IsNil(openServiceBroker) {
return nil
}
clone := *openServiceBroker
clone.Service = openServiceBroker.Service.Clone()
return &clone
}

// SetServiceURL sets the service URL
func (openServiceBroker *OpenServiceBrokerV1) SetServiceURL(url string) error {
return openServiceBroker.Service.SetServiceURL(url)
Expand Down Expand Up @@ -348,8 +363,8 @@ func (openServiceBroker *OpenServiceBrokerV1) ReplaceServiceInstanceWithContext(
if replaceServiceInstanceOptions.Context != nil {
body["context"] = replaceServiceInstanceOptions.Context
}
if replaceServiceInstanceOptions.OrganizationGuid != nil {
body["organization_guid"] = replaceServiceInstanceOptions.OrganizationGuid
if replaceServiceInstanceOptions.OrganizationGUID != nil {
body["organization_guid"] = replaceServiceInstanceOptions.OrganizationGUID
}
if replaceServiceInstanceOptions.Parameters != nil {
body["parameters"] = replaceServiceInstanceOptions.Parameters
Expand All @@ -360,8 +375,8 @@ func (openServiceBroker *OpenServiceBrokerV1) ReplaceServiceInstanceWithContext(
if replaceServiceInstanceOptions.ServiceID != nil {
body["service_id"] = replaceServiceInstanceOptions.ServiceID
}
if replaceServiceInstanceOptions.SpaceGuid != nil {
body["space_guid"] = replaceServiceInstanceOptions.SpaceGuid
if replaceServiceInstanceOptions.SpaceGUID != nil {
body["space_guid"] = replaceServiceInstanceOptions.SpaceGUID
}
_, err = builder.SetBodyContentJSON(body)
if err != nil {
Expand Down Expand Up @@ -1130,10 +1145,10 @@ type ReplaceServiceInstanceOptions struct {
// Platform specific contextual information under which the service instance is to be provisioned.
Context *Context `json:"context,omitempty"`

// Deprecated in favor of `context`. The identifier for the project space within the IBM Cloud platform organization.
// Although most brokers will not use this field, it might be helpful for executing operations on a user's behalf. It
// MUST be a non-empty string.
OrganizationGuid *string `json:"organization_guid,omitempty"`
// Deprecated in favor of `context`. The IBM Cloud platform GUID for the organization under which the service instance
// is to be provisioned. Although most brokers will not use this field, it might be helpful for executing operations on
// a user's behalf. It MUST be a non-empty string.
OrganizationGUID *string `json:"organization_guid,omitempty"`

// Configuration options for the service instance. An opaque object, controller treats this as a blob. Brokers should
// ensure that the client has provided valid configuration parameters and values for the operation. If this field is
Expand All @@ -1149,10 +1164,10 @@ type ReplaceServiceInstanceOptions struct {
// non-empty string.
ServiceID *string `json:"service_id,omitempty"`

// Deprecated in favor of `context`. The IBM Cloud platform GUID for the organization under which the service instance
// is to be provisioned. Although most brokers will not use this field, it might be helpful for executing operations on
// a user's behalf. It MUST be a non-empty string.
SpaceGuid *string `json:"space_guid,omitempty"`
// Deprecated in favor of `context`. The identifier for the project space within the IBM Cloud platform organization.
// Although most brokers will not use this field, it might be helpful for executing operations on a user's behalf. It
// MUST be a non-empty string.
SpaceGUID *string `json:"space_guid,omitempty"`

// A value of true indicates that both the IBM Cloud platform and the requesting client support asynchronous
// deprovisioning. If this parameter is not included in the request, and the broker can only deprovision a service
Expand Down Expand Up @@ -1182,9 +1197,9 @@ func (options *ReplaceServiceInstanceOptions) SetContext(context *Context) *Repl
return options
}

// SetOrganizationGuid : Allow user to set OrganizationGuid
func (options *ReplaceServiceInstanceOptions) SetOrganizationGuid(organizationGuid string) *ReplaceServiceInstanceOptions {
options.OrganizationGuid = core.StringPtr(organizationGuid)
// SetOrganizationGUID : Allow user to set OrganizationGUID
func (options *ReplaceServiceInstanceOptions) SetOrganizationGUID(organizationGUID string) *ReplaceServiceInstanceOptions {
options.OrganizationGUID = core.StringPtr(organizationGUID)
return options
}

Expand All @@ -1206,9 +1221,9 @@ func (options *ReplaceServiceInstanceOptions) SetServiceID(serviceID string) *Re
return options
}

// SetSpaceGuid : Allow user to set SpaceGuid
func (options *ReplaceServiceInstanceOptions) SetSpaceGuid(spaceGuid string) *ReplaceServiceInstanceOptions {
options.SpaceGuid = core.StringPtr(spaceGuid)
// SetSpaceGUID : Allow user to set SpaceGUID
func (options *ReplaceServiceInstanceOptions) SetSpaceGUID(spaceGUID string) *ReplaceServiceInstanceOptions {
options.SpaceGUID = core.StringPtr(spaceGUID)
return options
}

Expand Down Expand Up @@ -1593,13 +1608,13 @@ type BindResource struct {
AccountID *string `json:"account_id,omitempty"`

// Service ID of resource to bind.
ServiceidCrn *string `json:"serviceid_crn,omitempty"`
ServiceidCRN *string `json:"serviceid_crn,omitempty"`

// Target ID of resource to bind.
TargetCrn *string `json:"target_crn,omitempty"`
TargetCRN *string `json:"target_crn,omitempty"`

// GUID of an application associated with the binding. For credentials bindings.
AppGuid *string `json:"app_guid,omitempty"`
AppGUID *string `json:"app_guid,omitempty"`

// URL of the application to be intermediated. For route services bindings.
Route *string `json:"route,omitempty"`
Expand All @@ -1613,15 +1628,15 @@ func UnmarshalBindResource(m map[string]json.RawMessage, result interface{}) (er
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "serviceid_crn", &obj.ServiceidCrn)
err = core.UnmarshalPrimitive(m, "serviceid_crn", &obj.ServiceidCRN)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "target_crn", &obj.TargetCrn)
err = core.UnmarshalPrimitive(m, "target_crn", &obj.TargetCRN)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "app_guid", &obj.AppGuid)
err = core.UnmarshalPrimitive(m, "app_guid", &obj.AppGUID)
if err != nil {
return
}
Expand All @@ -1644,7 +1659,7 @@ type Context struct {
// service provider perspective, the CRN can largely be treated as an opaque string to be utilized with the IBM Cloud
// APIs, but it can also be decomposed via the following structure:
// `crn:version:cname:ctype:service-name:location:scope:service-instance:resource-type:resource`.
Crn *string `json:"crn,omitempty"`
CRN *string `json:"crn,omitempty"`

// Identifies the platform as "ibmcloud".
Platform *string `json:"platform,omitempty"`
Expand All @@ -1658,7 +1673,7 @@ func UnmarshalContext(m map[string]json.RawMessage, result interface{}) (err err
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "crn", &obj.Crn)
err = core.UnmarshalPrimitive(m, "crn", &obj.CRN)
if err != nil {
return
}
Expand Down
28 changes: 14 additions & 14 deletions openservicebrokerv1/open_service_broker_v1_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ var (
configLoaded bool = false

instanceId string
orgGuid string
orgGUID string
planId string
serviceId string
spaceGuid string
spaceGUID string
accountId string
bindingId string
appGuid string
appGUID string
initiatorId string = "null"
reasonCode string = "IBMCLOUD_ACCT_SUSPEND"
operation string = "Privision_45"
Expand Down Expand Up @@ -98,26 +98,26 @@ var _ = Describe(`OpenServiceBrokerV1 Examples Tests`, func() {
instanceId = config["RESOURCE_INSTANCE_ID"]
Expect(instanceId).ToNot(BeEmpty())

orgGuid = config["ORGANIZATION_GUID"]
Expect(orgGuid).ToNot(BeEmpty())
orgGUID = config["ORGANIZATION_GUID"]
Expect(orgGUID).ToNot(BeEmpty())

planId = config["PLAN_ID"]
Expect(planId).ToNot(BeEmpty())

serviceId = config["SERVICE_ID"]
Expect(serviceId).ToNot(BeEmpty())

spaceGuid = config["SPACE_GUID"]
Expect(spaceGuid).ToNot(BeEmpty())
spaceGUID = config["SPACE_GUID"]
Expect(spaceGUID).ToNot(BeEmpty())

accountId = config["ACCOUNT_ID"]
Expect(accountId).ToNot(BeEmpty())

bindingId = config["BINDING_ID"]
Expect(bindingId).ToNot(BeEmpty())

appGuid = config["APPLICATION_GUID"]
Expect(appGuid).ToNot(BeEmpty())
appGUID = config["APPLICATION_GUID"]
Expect(appGUID).ToNot(BeEmpty())
})
})

Expand Down Expand Up @@ -197,7 +197,7 @@ var _ = Describe(`OpenServiceBrokerV1 Examples Tests`, func() {

contextOpt := &openservicebrokerv1.Context{
AccountID: &accountId,
Crn: &instanceId,
CRN: &instanceId,
Platform: core.StringPtr("ibmcloud"),
}
paramsOpt := make(map[string]string, 0)
Expand All @@ -208,8 +208,8 @@ var _ = Describe(`OpenServiceBrokerV1 Examples Tests`, func() {
)
options = options.SetPlanID(planId)
options = options.SetServiceID(serviceId)
options = options.SetOrganizationGuid(orgGuid)
options = options.SetSpaceGuid(spaceGuid)
options = options.SetOrganizationGUID(orgGUID)
options = options.SetSpaceGUID(spaceGUID)
options = options.SetContext(contextOpt)
options = options.SetParameters(paramsOpt)
options = options.SetAcceptsIncomplete(true)
Expand All @@ -233,7 +233,7 @@ var _ = Describe(`OpenServiceBrokerV1 Examples Tests`, func() {

contextOpt := &openservicebrokerv1.Context{
AccountID: &accountId,
Crn: &instanceId,
CRN: &instanceId,
Platform: core.StringPtr("ibmcloud"),
}

Expand Down Expand Up @@ -317,7 +317,7 @@ var _ = Describe(`OpenServiceBrokerV1 Examples Tests`, func() {

bindResource := &openservicebrokerv1.BindResource{
AccountID: &accountId,
ServiceidCrn: &appGuid,
ServiceidCRN: &appGUID,
}

options := openServiceBrokerService.NewReplaceServiceBindingOptions(
Expand Down
18 changes: 9 additions & 9 deletions openservicebrokerv1/open_service_broker_v1_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ var (
configLoaded bool = false

testAccountId string = "bc2b2fca0af84354a916dc1de6eee42e"
testResourceGroupGuid string = "13aa3ee48c3b44ddb64c05c79f7ab8ef"
testOrgGuid string = "d35d4f0e-5076-4c89-9361-2522894b6548"
testSpaceGuid string = "336ba5f3-f185-488e-ac8d-02195eebb2f3"
testAppGuid string = "bf692181-1f0e-46be-9faf-eb0857f4d1d5"
testResourceGroupGUID string = "13aa3ee48c3b44ddb64c05c79f7ab8ef"
testOrgGUID string = "d35d4f0e-5076-4c89-9361-2522894b6548"
testSpaceGUID string = "336ba5f3-f185-488e-ac8d-02195eebb2f3"
testAppGUID string = "bf692181-1f0e-46be-9faf-eb0857f4d1d5"
testPlanId1 string = "a10e4820-3685-11e9-b210-d663bd873d93"
testPlanId2 string = "a10e4410-3685-11e9-b210-d663bd873d933"
testInstanceId string = "crn:v1:staging:public:bss-monitor:global:a/bc2b2fca0af84354a916dc1de6eee42e:sdkTestInstance::"
Expand Down Expand Up @@ -100,7 +100,7 @@ var _ = Describe("Open Service Broker - Integration Tests", func() {
platform := "ibmcloud"
contextOpt := &openservicebrokerv1.Context{
AccountID: &testAccountId,
Crn: &testInstanceId,
CRN: &testInstanceId,
Platform: &platform,
}

Expand All @@ -110,8 +110,8 @@ var _ = Describe("Open Service Broker - Integration Tests", func() {
options := service.NewReplaceServiceInstanceOptions(testInstanceIdEscaped)
options = options.SetPlanID(testPlanId1)
options = options.SetServiceID(testServiceId)
options = options.SetOrganizationGuid(testOrgGuid)
options = options.SetSpaceGuid(testSpaceGuid)
options = options.SetOrganizationGUID(testOrgGUID)
options = options.SetSpaceGUID(testSpaceGUID)
options = options.SetContext(contextOpt)
options = options.SetParameters(paramsOpt)
options = options.SetAcceptsIncomplete(true)
Expand All @@ -135,7 +135,7 @@ var _ = Describe("Open Service Broker - Integration Tests", func() {
platform := "cf"
contextOpt := &openservicebrokerv1.Context{
AccountID: &testAccountId,
Crn: &testInstanceId,
CRN: &testInstanceId,
Platform: &platform,
}

Expand Down Expand Up @@ -210,7 +210,7 @@ var _ = Describe("Open Service Broker - Integration Tests", func() {

bindResource := &openservicebrokerv1.BindResource{
AccountID: &testAccountId,
ServiceidCrn: &testAppGuid,
ServiceidCRN: &testAppGUID,
}

options := service.NewReplaceServiceBindingOptions(testBindingIdEscaped, testInstanceIdEscaped)
Expand Down
Loading

0 comments on commit c6401b1

Please sign in to comment.