Welcome to smis!

smis is a small library that allows Python applications to access the Autodesk InfraWorks 360 Model Information Service, which provides a REST API to retrieve information from a published Autodesk InfraWorks 360 model. The purpose of this library is to demonstrate how applications can access the Autodesk InfraWorks 360 Model Information Service, and it serves as an example for other applications to integrate the service. Still, the goal is to provide a fully functional library that can be use in your Python applications to integrate with Autodesk InfraWorks 360 Model Information Service.

Important

The Autodesk InfraWorks 360 Model Information Service is currently in preview mode, and it is subject to change. We are looking for developers that will like to integrate the service with their applications and provide us with feedback about the service. It is important to understand applications that integrate the service might be broken in the future when APIs and representations change, and that Autodesk will not be responsible for any problems caused by changes in the service. The following describes the terms of service of the library and its source code.

  1. Copyright 2015 Autodesk, Inc. All rights reserved.

Permission to use, copy, modify, and distribute these source code samples is hereby granted, provided that (i) you must clearly identify any modified source code files and any resulting binary files as works developed by you, and not by Autodesk; and (ii) you may distribute the resulting binary files of the source code samples in works that are commercially distributed software applications only if: (a) such applications require an Autodesk product to operate; and (b) such applications contain, subject to Autodesk’s sole discretion, significant features and functionality in addition to the source code samples so that the source code samples are not the primary source of value. In any copy of the source code samples, derivative works, and resulting binary files, you must include the copyright notices of Autodesk, Inc., the limited warranty and restricted rights notice below, and (if modified) the following statement: “This software contains copyrighted code owned by Autodesk but has been modified and is not endorsed by Autodesk in its modified form”.

AUTODESK PROVIDES THIS SOFTWARE “AS IS” AND WITH ALL FAULTS. AUTODESK MAKES NO WARRANTIES, EXPRESS OR IMPLIED, AS TO NON-INFRINGEMENT OF THIRD PARTY RIGHTS, MERCHANTABILITY, OR FITNESS FOR ANY PARTICULAR PURPOSE. IN NO EVENT WILL AUTODESK BE LIABLE TO YOU FOR ANY CONSEQUENTIAL, INCIDENTAL OR SPECIAL DAMAGES, INCLUDING ANY LOST PROFITS OR LOST SAVINGS, EVEN IF AUTODESK HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES, OR FOR ANY CLAIM BY ANY THIRD PARTY. AUTODESK DOES NOT WARRANT THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR FREE.

Use, duplication, or disclosure by the U.S. Government is subject to restrictions set forth in FAR 52.227-19 (Commercial ComputerSoftware - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) (Rights in Technical Data and Computer Software), as applicable.

You may not export the source code samples or any derivative works, resulting binaries, or any related technical documentation, in violation of U.S. or other applicable export control laws.

smis Installation Guide

The smis library is provides as Python package at the Python Package Index and as source code, which can be obtained from its GitHub repository. The following sections describe the requirements and installation process of the library.

Software Requirements

The library is currently implemented using Python 2.7.x, and it is being tested using that version. It may work under Python 3.x, but I haven’t tested the functionality. If you decided to use the source version of the library, downloaded from its GitHub repository, you will have to use Python 2.7.x to insure all the requirements can be satisfied in your environment for development.

Due to some security restriction accessing the Autodesk InfraWorks 360 Model Information Service, the minimum version of Python required is 2.7.9. This is due to the fact that the Autodesk InfraWorks 360 Model Information Service requires secure requests using the TLS 1.2 protocol, which is supported out of the box by Python 2.7.9 or higher.

Python 2.7.9 or higher also comes pre-packaged with pip, which allows to install the library from Python Package Index, which is the recommended procedure.

Access Requirements

In order to access the Autodesk InfraWorks 360 Model Information Service, you need to request a consumer key and secret that will enable your application to access the service. You can request the consumer key and secret by contacting Autodesk A.D.N.

Installing the Library using PIP

The installation using pip through Python Package Index is identical to other python packages. The library will be installed into your site-packages folder and will become available to your Python environment:

> pip install smis

Note

I prefer and recommend to create a virtual environment for each application I work in Python, that way, I don’t clutter the global Python environment. You can create a virtual environment for your smis applications by following the instructions in the virtualenv documentation site.

Downloading the Source Code

If you plan to contribute or if you would like to checkout the code, you can get the library source from its GitHub repository. Once you download the source to your machine, you will need to install all the required packages to insure everything is setup correctly:

> git clone https://github.com/CurroRodriguez/smis-python
> pip install -r requirements.txt

To insure you have the project setup correctly, you can execute all the tests, and if no errors are found, then your environment has been setup correctly (see notes about Setting Up Credentials):

# Executing the unit tests.
> nosetests ./tests/unit

# Executing acceptance tests.
> behave ./tests/acceptance

Setting Up Credentials

To contribute to the source, you need to insure that all the test automation is working; therefore, you need to run the tests. There are two test harness: a unit test harness which verifies the low-level implementation of the library and that can be executed without credentials; and an acceptance test harness that performs calls into the live service to insure the library functionality works as expected. For the later, you need to setup your credentials.

There are two sets of credentials required for any application to be able to access the service. First, you need to request a consumer key and secret unique to each application you intend to develop. This includes the ability to run the acceptance tests (see Access Requirements). You also need an active user in Autodesk 360 because all requests to Autodesk InfraWorks 360 Model Information Service are performed on behalf of a user.

Once you have both sets of credentials you can create a smis.txt file in the user directory in your system. The file uses a standard .ini format for the parameters:

[smis]
consumer_key=<replace with your consumer key>
consumer_secret=<replace with your consumer secret>
user_name=<replace with your user name usually your email>
password=<replace with your password>

The acceptance test harness will load your credentials from this file, and will allow you run the automation.

Links

Python Reference Guide

The smis Python package provides a simple interface to access Autodesk InfraWorks 360 Model Information Service, which exposes a REST API to access model data from Autodesk InfraWorks 360 models stored in the cloud. The package removes the complexity of authorizing an application to use the service and simplifies the process of sending HTTP requests to the service to access the resource information.

smis.connect(key, secret, login_callback)[source]

This function authorizes the application to access.

Parameters:
  • key – Consumer key for an authorized application.
  • secret – Consumer secret for an authorized application.
  • login_callback – Login callback to authenticate user.
Returns:

Client object that provides interface to access the service

The following example shows the connect method use:

import smis

def my_login_callback(url):
    # display provided url to allow user to enter credentials.
    #
    show_browser(url) # not implemented

client = smis.connect('consumer-key', 'consumer-secret', my_login_callback)
class smis._client.Client(service)[source]

Model Information Service client application.

This class is provided as entry point for all interfaces that communicate with the Autodesk InfraWorks 360 Model Information Service. The class is instantiated with a service proxy that knows how to communicate with the on-line service REST API.

Client applications should not instantiate this class directly, and they should use the connect() method instead to access the Client object.

get()[source]

Returns the service payload.

Returns:Returns the service end-point payload as a python object (a dict).

Todo

Finalize behavior and complete documentation with sample code.

response

Returns the response object from the service. This property returns None if get() has not been invoked yet. The property becomes handy in case of exceptions where it can provide more information about what went wrong.

Returns:The response object from accessing the client end-point.
url

Provides the end-point URL of the Autodesk InfraWorks 360 Model Information Service.

Returns:A string containing the URL to the Autodesk InfraWorks 360 Model Information Service.

Todo

Provide sample code.

class smis._client._Resource(url_token, service, parent=None)[source]

This internal class is accessed through the Client interface an allows accessing resources in the service.

get()[source]

Provides the resource representation as a python object (dict for single resources, list for collections).

Returns:Returns the resource representation.

Todo

Finalize behavior and complete documentation with sample code.

item(identity)[source]

Temporary item() method documentation. :param identity: :return:

Todo

Finalize behavior and complete documentation with sample code.

path

Provides the relative path to the resource from the base end-point.

Returns:Returns a string containing the relative path to the resource.

Todo

Provide sample code.

response

Returns the response object for the resource. This property returns None if get() has not been invoked yet. The property becomes handy in case of exceptions where it can provide more information about what went wrong.

Returns:The response object from accessing the resource.
url

Provides the full URL to the resource.

Returns:A string containing the full URL to the resource.

Todo

Provide sample code.

Documentation Improvements

The following is a list of ToDos to improve the documentation.

Todo

Finalize behavior and complete documentation with sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client.Client.get, line 6.)

Todo

Provide sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client.Client.url, line 6.)

Todo

Finalize behavior and complete documentation with sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client._Resource.get, line 6.)

Todo

Finalize behavior and complete documentation with sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client._Resource.item, line 5.)

Todo

Provide sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client._Resource.path, line 6.)

Todo

Provide sample code.

(The original entry is located in /home/docs/checkouts/readthedocs.org/user_builds/simple-mis/checkouts/latest/source/smis/_client.py:docstring of smis._client._Resource.url, line 6.)

Indices and tables