F5Networks / f5-common-python

Python SDK for configuration and monitoring of F5® BIG-IP® devices via the iControl® REST API.
https://f5-sdk.readthedocs.org
Apache License 2.0
262 stars 134 forks source link

how to create a data-group? #1336

Closed kimoziiiii closed 6 years ago

kimoziiiii commented 6 years ago

I don't know how to use an this API, because i can't find the corresponding document In [47]: testdg = ltm.data_group.internals.internal.create(name="testDG", type="String", records='{"name":"ffff.com"}')

/root/py2.7env/lib/python2.7/site-packages/urllib3/connectionpool.py:858: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
---------------------------------------------------------------------------
iControlUnexpectedHTTPError               Traceback (most recent call last)
<ipython-input-47-925411c6dde3> in <module>()
----> 1 testdg = ltm.data_group.internals.internal.create(name="testDG", type="String", records='{"name":"ffff.cn"}')

/root/py2.7env/lib/python2.7/site-packages/f5/bigip/resource.pyc in create(self, **kwargs)
   1000 
   1001         """
-> 1002         return self._create(**kwargs)
   1003 
   1004     def _check_load_parameters(self, **kwargs):

/root/py2.7env/lib/python2.7/site-packages/f5/bigip/resource.pyc in _create(self, **kwargs)
    966 
    967         # Invoke the REST operation on the device.
--> 968         response = session.post(_create_uri, json=kwargs, **requests_params)
    969 
    970         # Make new instance of self

/root/py2.7env/lib/python2.7/site-packages/icontrol/session.pyc in wrapper(self, RIC_base_uri, **kwargs)
    270                              response.url,
    271                              response.text)
--> 272             raise iControlUnexpectedHTTPError(error_message, response=response)
    273         return response
    274     return wrapper

iControlUnexpectedHTTPError: 400 Unexpected Error: Bad Request for uri: https://10.50.2.65:443/mgmt/tm/ltm/data-group/internal/
Text: u'{"code":400,"message":"one or more configuration identifiers must be provided","errorStack":[]}'
caphrim007 commented 6 years ago

@kimoziiiii

https://github.com/F5Networks/f5-common-python/blob/development/f5/bigip/tm/ltm/test/functional/test_data_group.py#L86

kimoziiiii commented 6 years ago

@caphrim007 thank you 💯