softlayer / softlayer-go

SoftLayer API Client for the Go Language
Apache License 2.0
53 stars 46 forks source link

Network_Storage.ReplicationStatus is not a string when volume is a replica or has replica #57

Closed JunliWang closed 7 years ago

JunliWang commented 7 years ago

if a volume is a primary block volume, replicationStatus is a string, if volume is a replicant, then replicationStatus is a struct, see below data:

{
  "capacityGb": 100,
  "id": 26876939,
  "username": "IBM02SL278444_566_REP_1",
  "activeTransactionCount": 0,
  "replicationPartnerCount": 0,
  "activeTransactions": [],
  "lunId": "173",
  "parentVolume": {
    "accountId": 278444,
    "capacityGb": 100,
    "createDate": "2017-06-25T23:18:01-06:00",
    "guestId": null,
    "hardwareId": null,
    "hostId": null,
    "id": 26876585,
    "nasType": "NAS_CONTAINER",
    "serviceProviderId": 1,
    "storageTypeId": "3",
    "upgradableFlag": true,
    "username": "IBM02SVC278444_566",
    "serviceResourceName": "Storage Type 02 Block Aggregate stbf-tok0201a"
  },
  "replicationPartners": [],
  "replicationStatus": {
    "createDate": "2017-06-25T23:31:11-06:00",
    "message": "Replicant Volume Provisioning has completed.",
    "scheduleId": null,
    "typeId": 322,
    "volumeId": 26876585
  },
  "serviceResource": {
    "id": 9157,
    "name": "Storage Type 02 Block Aggregate stbf-hkg0201b",
    "attributes": [
      {
        "value": "2",
        "attributeType": {
          "keyname": "STAAS_VERSION"
        }
      }
    ],
    "datacenter": {
      "name": "hkg02"
    },
    "type": {
      "type": "NETAPP_STOR_AGGR"
    }
  },
  "serviceResourceBackendIpAddress": "10.2.174.82",
  "snapshotCapacityGb": "100",
  "storageType": {
    "keyName": "PERFORMANCE_BLOCK_STORAGE_REPLICANT"
  }
}

I'm not sure whether this is an inconsistency in API implementation or it is designed in this way, but need a way to avoid this error, suggest to change the type to json.RawMessage, and client can unmarshal it accordingly.

renier commented 7 years ago

@JunliWang You should report this on StackOverflow. It does look like an API inconsistency that should be fixed in relation to statically-typed languages like Go and Java.

JunliWang commented 7 years ago

sure. https://stackoverflow.com/questions/44771560/network-storage-replicationstatus-is-not-a-string-when-volume-is-a-replica-or-ha

JunliWang commented 7 years ago

SL ticket is opened: https://control.softlayer.com/support/tickets/44024463

renier commented 7 years ago

Closing this as it has been identified a bug on the API itself.