Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

DynamicManifestApi

Justin McWilliams edited this page Oct 17, 2014 · 2 revisions

Introduction

If you're not already familiar with the concept of Dynamic Manifests, please refer to Wiki documentation which overviews the feature.

This document relates to the Dynamic Manifest API, which lets you make RESTful calls to your Simian server to add/remove manifest modifications.

Parameters

  • mod_type: the str type of manifest modification being requested.
    • valid options: owner, uuid, site, os_version, and tag.
  • target: the str target of the mod_type.
    • for example, 'foouser' for mod_type='owner', or '10.7.4' for mod_type='os_version'.
  • pkg_alias: the str package alias or name to make available to the above.
    • example: 'Foo Package' if you have a Package Alias setup for this package name.
  • install_types: the str Munki install type you wish you add.
    • valid options: optional_installs, managed_updates, managed_installs, etc.
  • manifest (optional): the manifest you wish for this mod to apply to.
    • default: if omitted, apply the mod to all manifests.
    • valid options: unstable, testing, stable.

Example Code

  import oauth2 as oauth
  import socket
  
  API_URL = 'http://example.appspot.com/api'
  OAUTH_CONSUMER_KEY = ''
  OAUTH_CONSUMER_SECRET = ''
  OAUTH_ACCESS_TOKEN = ''
  OAUTH_TOKEN_SECRET = ''

  # define parameters of the manifest mod.
  params = {
      'mod_type': 'owner',
      'target': 'foouser',
      'pkg_alias': 'Foo Package',
      'install_types': 'optional_installs',
  }

  # init an OAuth client.
  try:
    consumer = oauth.Consumer(OAUTH_CONSUMER_KEY,
                              OAUTH_CONSUMER_SECRET)
    token = oauth.Token(OAUTH_ACCESS_TOKEN, OAUTH_TOKEN_SECRET)
    oauth_client = oauth.Client(consumer, token)
  except oauth.httplib2.HttpLib2Error, error:
    print 'Non-fatal auth error: %s' % error
  except ValueError, error:
    print 'Fatal auth error: %s' % error

  # send the manifest mod parameters.
  try:
    response_headers, response_body = oauth_client.request(
        API_URL, 'POST',
        body=urllib.urlencode(params, doseq=True))
  except (oauth.httplib2.HttpLib2Error, socket.error), error:
    print 'Non-fatal request error: %s' % response_body
  except ValueError, error:
    print 'Fatal error: %s' % error

  response_status_code = response_headers['status']
  if response_status_code != 200:
    print 'Error; respose_status_code != 200: %s\n Body:\n%s' % (response_status_code, response_body)

  # response_body is JSON, for easy parsing.

This wiki will be finished ASAP.

Until then, you can explore the functional API code here: http://code.google.com/p/simian/source/browse/trunk/src/simian/mac/api/dynamic_manifest.py

Clone this wiki locally