# Create a new container in one project with the python "gdapi"

**URL:** <https://forums.suse.com/t/create-a-new-container-in-one-project-with-the-python-gdapi/7815>\
**Category:** Rancher 1.x\
**Created:** [November 16, 2017, 2:37pm UTC](https://forums.suse.com/t/create-a-new-container-in-one-project-with-the-python-gdapi/7815 "2017-11-16T14:37:57Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdonorio](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pdonorio/32/3089_2.png) [@pdonorio](https://forums.suse.com/u/pdonorio)\
**Post date:** [November 16, 2017, 2:37pm UTC](https://forums.suse.com/t/create-a-new-container-in-one-project-with-the-python-gdapi/7815/1 "2017-11-16T14:37:57Z")

</div>

Hello there,  
I’m trying to use the [gdapi](https://github.com/rancher/gdapi-python) in python.

I’ve seen similar topics but no clear solution, so let’s try:

I can currently create a client how the README says and it works; I can do “read-only” operations like listing projects, containers, hosts and so one.

Now I want to create: stack, service, container.  
I can do that with the REST API like:  
`POST /projects/{$PID}/containers [paramaters]`  
but how does that map to the gdapi?  
The documentation is poor; I have tried to recover a “project handler” with `client.by_id_project('myid')` but then I have nothing like ‘create’ or ‘post’ in that REST object.

Please could some one help and point me in the right direction?

Thank you,  
Paolo

---

<div class="post-metadata">

**Author:** ![cjellick](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/cjellick/32/2876_2.png) [@cjellick](https://forums.suse.com/u/cjellick)\
**Post date:** [November 16, 2017, 3:45pm UTC](https://forums.suse.com/t/create-a-new-container-in-one-project-with-the-python-gdapi/7815/2 "2017-11-16T15:45:11Z")

</div>

Hi Paolo,

Yes, the documentation for the python client is exceedingly poor. It is mainly intended as an internal tool we use for writing tests. We don’t put much effort into making it consumable by the day-to-day user.

That said, it works well and we use it for all of our integration and validation tests. Looking at those tests would be the best way to understand how to use it. Here are the validation tests:

> **[validation-tests/tests/v2\_validation/cattlevalidationtest/core at master ·...](https://github.com/rancher/validation-tests/tree/master/tests/v2_validation/cattlevalidationtest/core)**
>
> master/tests/v2\_validation/cattlevalidationtest/core

And here are the integration tests from our cattle repo:

> **[cattle/tests/integration/cattletest/core at v1.6 · rancher/cattle](https://github.com/rancher/cattle/tree/v1.6/tests/integration/cattletest/core)**
>
> v1.6/tests/integration/cattletest/core

Both make extensive use of the python client. The clients are wired into the tests through the use of pytest fixtures, so to understand how we are passing around the clients, you’ll need some understanding of those. We create the clients in common\_fixtures.py and use them in the tests themselves.

Good luck!

---

<div class="post-metadata">

**Author:** ![pdonorio](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/pdonorio/32/3089_2.png) [@pdonorio](https://forums.suse.com/u/pdonorio)\
**Post date:** [December 1, 2017, 4:12pm UTC](https://forums.suse.com/t/create-a-new-container-in-one-project-with-the-python-gdapi/7815/3 "2017-12-01T16:12:12Z")

</div>

Hello there,  
I’ve finally found a little time to dig more into all of your tests.

Well, it has been very difficult to debug all the (uncommented) common fixture you have there 😛  
But I’ve reached some outcome, hope this helps others in the future!

Basically your clients in any test have a `create_container` method inside, which was not in my client (created from the example in the `README` of the gdapi repo).  
But! I’ve finally found the difference from our clients: the one you create has a `projects/$[PROJECT_ID]/schemas` as a suffix. If I append that to my initial `http://${RANCHER_HOST}:${RANCHER_PORT}/v2-beta/` url it finally works, the `create_container` is now there in the python object 😉

Hurray!
