Запрос на отмену REST API SoftLayer

Я хотел бы отменить SoftLayer устройство в определенную дату в будущем и обнаружил следующее SoftLayer_Billing_Item_Cancellation_Request::createObject.

Как бы выглядел request url и как бы выглядел POST parameters, если бы я использовал json?

Спасибо


person juls85    schedule 12.04.2016    source источник


Ответы (3)


Это пример Rest может помочь вам:

Отмена обслуживания — отдых

Чтобы получить элемент выставления счетов, см.:

SoftLayer_Virtual_Guest::getBillingItem

Кроме того, это пример Python:

"""
Cancel a Virtual Guest.
It cancels the resource for a billing Item. The billing item will be cancelled
immediately and reclaim of the resource will begin shortly.

Important manual pages:
http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/getObject
http://sldn.softlayer.com/reference/services/SoftLayer_Billing_Item/cancelService

License: http://sldn.softlayer.com/article/License
Author: SoftLayer Technologies, Inc. <[email protected]>
"""
import SoftLayer.API
from pprint import pprint as pp

# Your SoftLayer API username and key.
API_USERNAME = 'set me'

# Generate one at https://control.softlayer.com/account/users
API_KEY = 'set me'

virtualGuestId = 9923645

client = SoftLayer.Client(
    username=API_USERNAME,
    api_key=API_KEY,
)

try:
    # Getting the billing item id
    mask = 'mask.billingItem.id'
    cci = client['SoftLayer_Virtual_Guest'].getObject(mask=mask, id=virtualGuestId)
    billingItemId = cci['billingItem']['id']

    try:
        # Canceling the Virtual Guest
        result = client['Billing_Item'].cancelService(id=billingItemId)
        pp(result)
    except SoftLayer.SoftLayerAPIError as e:
        pp('Unable to cancel the VSI faultCode=%s, faultString=%s'
            % (e.faultCode, e.faultString))

except SoftLayer.SoftLayerAPIError as e:
        pp('Unable to get the billing item id from VSI faultCode=%s, faultString=%s'
            % (e.faultCode, e.faultString))

Также есть много примеров в других клиентах, которые могут вам помочь:

Отмена обслуживания — отдых

Отмена службы — Python

отменить услугу — php

отменить сервис-perl

Ссылки

SoftLayer_Billing_Item::cancelService

SoftLayer_Virtual_Guest::getBillingItem

SoftLayer_Virtual_Guest::getObject

person mcruz    schedule 12.04.2016
comment
Это не то, что я пытался сделать. Я хочу отменить виртуальное устройство в будущем, а это значит, что мне нужно будет прикрепить к запросу какой-то объект даты/времени. Существует ли что-то подобное для SoftLayer? - person juls85; 13.04.2016

Это может быть то, что вы ищете:

Post URL: https://api.softlayer.com/rest/v3.1/SoftLayer_Billing_Item_Cancellation_Request/createObject.json

Payload: 

{
    "parameters": [
        {
            "complexType": "SoftLayer_Billing_Item_Cancellation_Request",
            "accountId": 321752,
            "notes": "No notes provided",
            "items": [
                {
                    "complexType": "SoftLayer_Billing_Item_Cancellation_Request_Item",
                    "billingItemId": 25849466,
                    "scheduledCancellationDate": "5/15/2006"
                }
            ]
        }
    ]
}

Я надеюсь, что это помогает

С уважением

person Nelson Raul Cabero Mendoza    schedule 13.04.2016
comment
Спасибо, похоже то, что нужно :) - person juls85; 14.04.2016
comment
Эта и немного другая версия Запроса у меня не работают. - person juls85; 15.04.2016
comment
Не удалось отменить элементы выставления счетов. Не удалось определить группу заявок для восстановления вычислительного экземпляра. - person juls85; 15.04.2016
comment
Вы уверены, что идентификатор billingItem правильный? - person Nelson Raul Cabero Mendoza; 15.04.2016
comment
Для его получения я использую следующее: api.softlayer. com/rest/v3/SoftLayer_Virtual_Guest/[id]/ - person juls85; 18.04.2016
comment
это похоже на проблему, потому что согласно этому методу sldn.softlayer.com/reference/services/ идентификатор пункта выставления счетов VSI действителен для отмены, я предлагаю вам подать заявку на это на портале softlayer. - person Nelson Raul Cabero Mendoza; 18.04.2016

Ответ, который сработал для меня, следующий:

  1. https://api.softlayer.com/rest/v3/SoftLayer_Virtual_Guest/[deviceID]/getBillingItem.json
  2. https://api.softlayer.com/rest/v3/SoftLayer_Billing_Item/[BillingItemID]/cancelServiceOnAnniversaryDate.json

Оба являются Get запросами.

person juls85    schedule 19.04.2016