IBM-Cloud / bluemix-go

Go library for accessing the Bluemix API
Apache License 2.0
37 stars 89 forks source link

How to wait for providing an service #55

Closed huikang closed 7 years ago

huikang commented 7 years ago

When I follow the sample code to provision a discovery service and then update the servicekey. The update call returns the following error:

ServerErrorResponse: {
          "description": "An operation for service instance test-1-discovery is in progress.",
          "error_code": "CF-AsyncServiceInstanceOperationInProgress",
          "code": 60016
        }

My code looks like

myService, err := serviceInstanceAPI.Create(mccpv2.ServiceInstanceCreateRequest
updatedInstance, err := serviceInstanceAPI.Update(myService.Metadata.GUID, mccpv2.ServiceInstanceUpdateRequest{
        Name: helpers.String(service.InstanceName),
    })

My question is is there anyway to check the status of the service instance by the GUID and then call the update. Thanks.

ashishth09 commented 7 years ago

Hi @huikang ,

You could use https://github.com/IBM-Bluemix/bluemix-go/blob/master/api/mccp/mccpv2/service_instances.go#L38, perform a GET operation and check the state of the LastOperation.

Check the last_operation.state here https://apidocs.cloudfoundry.org/272/service_instances/retrieve_a_particular_service_instance.html

huikang commented 7 years ago

cool! Thanks.