def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.create_feedback_feedback_post_endpoint = _Endpoint( settings={ 'response_type': (FeedbackFeedbackPost, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/feedback/FeedbackPosts', 'operation_id': 'create_feedback_feedback_post', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'feedback_feedback_post', 'if_match', 'if_none_match', ], 'required': [ 'feedback_feedback_post', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'feedback_feedback_post': (FeedbackFeedbackPost, ), 'if_match': (str, ), 'if_none_match': (str, ), }, 'attribute_map': { 'if_match': 'If-Match', 'if_none_match': 'If-None-Match', }, 'location_map': { 'feedback_feedback_post': 'body', 'if_match': 'header', 'if_none_match': 'header', }, 'collection_format_map': {} }, headers_map={ 'accept': ['application/json'], 'content_type': ['application/json'] }, api_client=api_client)
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.create_smtp_policy_endpoint = _Endpoint( settings={ 'response_type': (SmtpPolicy, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies', 'operation_id': 'create_smtp_policy', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'smtp_policy', 'if_match', 'if_none_match', ], 'required': [ 'smtp_policy', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'smtp_policy': (SmtpPolicy, ), 'if_match': (str, ), 'if_none_match': (str, ), }, 'attribute_map': { 'if_match': 'If-Match', 'if_none_match': 'If-None-Match', }, 'location_map': { 'smtp_policy': 'body', 'if_match': 'header', 'if_none_match': 'header', }, 'collection_format_map': {} }, headers_map={ 'accept': ['application/json'], 'content_type': ['application/json'] }, api_client=api_client) self.delete_smtp_policy_endpoint = _Endpoint( settings={ 'response_type': None, 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies/{Moid}', 'operation_id': 'delete_smtp_policy', 'http_method': 'DELETE', 'servers': None, }, params_map={ 'all': [ 'moid', ], 'required': [ 'moid', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'moid': (str, ), }, 'attribute_map': { 'moid': 'Moid', }, 'location_map': { 'moid': 'path', }, 'collection_format_map': {} }, headers_map={ 'accept': ['application/json'], 'content_type': [], }, api_client=api_client) self.get_smtp_policy_by_moid_endpoint = _Endpoint( settings={ 'response_type': (SmtpPolicy, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies/{Moid}', 'operation_id': 'get_smtp_policy_by_moid', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'moid', ], 'required': [ 'moid', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'moid': (str, ), }, 'attribute_map': { 'moid': 'Moid', }, 'location_map': { 'moid': 'path', }, 'collection_format_map': {} }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client) self.get_smtp_policy_list_endpoint = _Endpoint( settings={ 'response_type': (SmtpPolicyResponse, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies', 'operation_id': 'get_smtp_policy_list', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'filter', 'orderby', 'top', 'skip', 'select', 'expand', 'apply', 'count', 'inlinecount', 'at', 'tags', ], 'required': [], 'nullable': [], 'enum': [ 'inlinecount', ], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': { ('inlinecount', ): { "ALLPAGES": "allpages", "NONE": "none" }, }, 'openapi_types': { 'filter': (str, ), 'orderby': (str, ), 'top': (int, ), 'skip': (int, ), 'select': (str, ), 'expand': (str, ), 'apply': (str, ), 'count': (bool, ), 'inlinecount': (str, ), 'at': (str, ), 'tags': (str, ), }, 'attribute_map': { 'filter': '$filter', 'orderby': '$orderby', 'top': '$top', 'skip': '$skip', 'select': '$select', 'expand': '$expand', 'apply': '$apply', 'count': '$count', 'inlinecount': '$inlinecount', 'at': 'at', 'tags': 'tags', }, 'location_map': { 'filter': 'query', 'orderby': 'query', 'top': 'query', 'skip': 'query', 'select': 'query', 'expand': 'query', 'apply': 'query', 'count': 'query', 'inlinecount': 'query', 'at': 'query', 'tags': 'query', }, 'collection_format_map': {} }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client) self.patch_smtp_policy_endpoint = _Endpoint( settings={ 'response_type': (SmtpPolicy, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies/{Moid}', 'operation_id': 'patch_smtp_policy', 'http_method': 'PATCH', 'servers': None, }, params_map={ 'all': [ 'moid', 'smtp_policy', 'if_match', ], 'required': [ 'moid', 'smtp_policy', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'moid': (str, ), 'smtp_policy': (SmtpPolicy, ), 'if_match': (str, ), }, 'attribute_map': { 'moid': 'Moid', 'if_match': 'If-Match', }, 'location_map': { 'moid': 'path', 'smtp_policy': 'body', 'if_match': 'header', }, 'collection_format_map': {} }, headers_map={ 'accept': ['application/json'], 'content_type': ['application/json', 'application/json-patch+json'] }, api_client=api_client) self.update_smtp_policy_endpoint = _Endpoint( settings={ 'response_type': (SmtpPolicy, ), 'auth': ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2'], 'endpoint_path': '/api/v1/smtp/Policies/{Moid}', 'operation_id': 'update_smtp_policy', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'moid', 'smtp_policy', 'if_match', ], 'required': [ 'moid', 'smtp_policy', ], 'nullable': [], 'enum': [], 'validation': [] }, root_map={ 'validations': {}, 'allowed_values': {}, 'openapi_types': { 'moid': (str, ), 'smtp_policy': (SmtpPolicy, ), 'if_match': (str, ), }, 'attribute_map': { 'moid': 'Moid', 'if_match': 'If-Match', }, 'location_map': { 'moid': 'path', 'smtp_policy': 'body', 'if_match': 'header', }, 'collection_format_map': {} }, headers_map={ 'accept': ['application/json'], 'content_type': ['application/json', 'application/json-patch+json'] }, api_client=api_client)
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.query_telemetry_datasource_metadata_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidDataSourceMetadataResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/DataSourceMetadata', 'operation_id': 'query_telemetry_datasource_metadata', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_data_source_metadata_request', ], 'required': [ 'telemetry_druid_data_source_metadata_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_data_source_metadata_request': (TelemetryDruidDataSourceMetadataRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_data_source_metadata_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_group_by_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidGroupByResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/GroupBys', 'operation_id': 'query_telemetry_group_by', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_group_by_request', ], 'required': [ 'telemetry_druid_group_by_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_group_by_request': (TelemetryDruidGroupByRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_group_by_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_scan_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidScanResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/Scans', 'operation_id': 'query_telemetry_scan', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_scan_request', ], 'required': [ 'telemetry_druid_scan_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_scan_request': (TelemetryDruidScanRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_scan_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_search_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidSearchResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/Searches', 'operation_id': 'query_telemetry_search', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_search_request', ], 'required': [ 'telemetry_druid_search_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_search_request': (TelemetryDruidSearchRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_search_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_segment_metadata_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidSegmentMetadataResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/SegmentMetadata', 'operation_id': 'query_telemetry_segment_metadata', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_segment_metadata_request', ], 'required': [ 'telemetry_druid_segment_metadata_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_segment_metadata_request': (TelemetryDruidSegmentMetadataRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_segment_metadata_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_time_boundary_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidTimeBoundaryResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/TimeBoundaries', 'operation_id': 'query_telemetry_time_boundary', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_time_boundary_request', ], 'required': [ 'telemetry_druid_time_boundary_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_time_boundary_request': (TelemetryDruidTimeBoundaryRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_time_boundary_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_time_series_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidIntervalResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/TimeSeries', 'operation_id': 'query_telemetry_time_series', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_time_series_request', ], 'required': [ 'telemetry_druid_time_series_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_time_series_request': (TelemetryDruidTimeSeriesRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_time_series_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client ) self.query_telemetry_top_n_endpoint = _Endpoint( settings={ 'response_type': ([TelemetryDruidTopNResult],), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/telemetry/Topns', 'operation_id': 'query_telemetry_top_n', 'http_method': 'POST', 'servers': None, }, params_map={ 'all': [ 'telemetry_druid_top_n_request', ], 'required': [ 'telemetry_druid_top_n_request', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'telemetry_druid_top_n_request': (TelemetryDruidTopNRequest,), }, 'attribute_map': { }, 'location_map': { 'telemetry_druid_top_n_request': 'body', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json' ], 'content_type': [ 'application/json' ] }, api_client=api_client )
def main(): argument_spec = dict( api_private_key=dict(type='path', required=True), api_uri=dict(type='str', default='https://intersight.com/api/v1'), api_key_id=dict(type='str', required=True), objects=dict(type='list'), json_config_file=dict(type='path'), state=dict(type='str', choices=['present', 'absent'], default='present'), ) module = AnsibleModule( argument_spec, supports_check_mode=True, required_one_of=[ ['objects', 'json_config_file'], ], mutually_exclusive=[ ['objects', 'json_config_file'], ], ) if not HAS_INTERSIGHT: module.fail_json(msg='intersight module is not available') api_instance = IntersightApiClient( host=module.params['api_uri'], private_key=module.params['api_private_key'], api_key_id=module.params['api_key_id'], ) err = False # note that all objects specified in the object list report a single result (including a single changed). result = dict(changed=False) try: if module.params.get('objects'): objects = module.params['objects'] else: # either objects or json_config_file will be specified, so if there is no objects option use a config file with open(module.params['json_config_file']) as f: objects = json.load(f) for item in objects: moid = None props_match = False # import the module and GET the resource based on an optional filter param api_module = import_module(item['api_module']) api_class = getattr(api_module, item['api_class']) api_object = api_class(api_instance) response_dict = get_object(api_object, item) result['api_response'] = response_dict if response_dict.get('moid'): moid = response_dict['moid'] if module.params['state'] == 'absent': # object must exist, but all properties do not have to match if moid: if not module.check_mode: api_moid_delete_method = getattr( api_object, item['api_method_prefix'] + '_moid_delete') api_moid_delete_method(moid) result['api_response'] = {} result['changed'] = True else: # configure as present. Note that no api_body implies a GET only - api_response from above returned if item.get('api_body'): # configure based on api_body if moid: # check object properties data_module = import_module(item['data_module']) data_class = getattr(data_module, item['data_class']) deserialize_instance = ApiClient() data_object = deserialize_instance._ApiClient__deserialize_model( item['api_body'], data_class) deserialize_dict = data_object.to_dict() props_match = compare_values(deserialize_dict, response_dict) if not props_match: if not module.check_mode: if moid: # update the resource - user has to specify all the props they want updated api_moid_patch_method = getattr( api_object, item['api_method_prefix'] + '_moid_patch') api_response = api_moid_patch_method( moid, item['api_body']) else: # create the resource api_post_method = getattr( api_object, item['api_method_prefix'] + '_post') api_response = api_post_method( item['api_body']) if not api_response: result['api_response'] = get_object( api_object, item) result['changed'] = True except Exception as e: err = True result['msg'] = "setup error: %s " % str(e) if err: module.fail_json(**result) module.exit_json(**result)
def __init__(self, api_client=None): if api_client is None: api_client = ApiClient() self.api_client = api_client self.get_view_health_status_by_moid_endpoint = _Endpoint( settings={ 'response_type': (ViewHealthStatus,), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/view/HealthStatuses/{Moid}', 'operation_id': 'get_view_health_status_by_moid', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'moid', ], 'required': [ 'moid', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'moid': (str,), }, 'attribute_map': { 'moid': 'Moid', }, 'location_map': { 'moid': 'path', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client ) self.get_view_health_status_list_endpoint = _Endpoint( settings={ 'response_type': (ViewHealthStatusResponse,), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/view/HealthStatuses', 'operation_id': 'get_view_health_status_list', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'filter', 'orderby', 'top', 'skip', 'select', 'expand', 'apply', 'count', 'inlinecount', 'at', 'tags', ], 'required': [], 'nullable': [ ], 'enum': [ 'inlinecount', ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { ('inlinecount',): { "ALLPAGES": "allpages", "NONE": "none" }, }, 'openapi_types': { 'filter': (str,), 'orderby': (str,), 'top': (int,), 'skip': (int,), 'select': (str,), 'expand': (str,), 'apply': (str,), 'count': (bool,), 'inlinecount': (str,), 'at': (str,), 'tags': (str,), }, 'attribute_map': { 'filter': '$filter', 'orderby': '$orderby', 'top': '$top', 'skip': '$skip', 'select': '$select', 'expand': '$expand', 'apply': '$apply', 'count': '$count', 'inlinecount': '$inlinecount', 'at': 'at', 'tags': 'tags', }, 'location_map': { 'filter': 'query', 'orderby': 'query', 'top': 'query', 'skip': 'query', 'select': 'query', 'expand': 'query', 'apply': 'query', 'count': 'query', 'inlinecount': 'query', 'at': 'query', 'tags': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client ) self.get_view_server_by_moid_endpoint = _Endpoint( settings={ 'response_type': (ViewServer,), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/view/Servers/{Moid}', 'operation_id': 'get_view_server_by_moid', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'moid', ], 'required': [ 'moid', ], 'nullable': [ ], 'enum': [ ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { }, 'openapi_types': { 'moid': (str,), }, 'attribute_map': { 'moid': 'Moid', }, 'location_map': { 'moid': 'path', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client ) self.get_view_server_list_endpoint = _Endpoint( settings={ 'response_type': (ViewServerResponse,), 'auth': [ 'cookieAuth', 'http_signature', 'oAuth2', 'oAuth2' ], 'endpoint_path': '/api/v1/view/Servers', 'operation_id': 'get_view_server_list', 'http_method': 'GET', 'servers': None, }, params_map={ 'all': [ 'filter', 'orderby', 'top', 'skip', 'select', 'expand', 'apply', 'count', 'inlinecount', 'at', 'tags', ], 'required': [], 'nullable': [ ], 'enum': [ 'inlinecount', ], 'validation': [ ] }, root_map={ 'validations': { }, 'allowed_values': { ('inlinecount',): { "ALLPAGES": "allpages", "NONE": "none" }, }, 'openapi_types': { 'filter': (str,), 'orderby': (str,), 'top': (int,), 'skip': (int,), 'select': (str,), 'expand': (str,), 'apply': (str,), 'count': (bool,), 'inlinecount': (str,), 'at': (str,), 'tags': (str,), }, 'attribute_map': { 'filter': '$filter', 'orderby': '$orderby', 'top': '$top', 'skip': '$skip', 'select': '$select', 'expand': '$expand', 'apply': '$apply', 'count': '$count', 'inlinecount': '$inlinecount', 'at': 'at', 'tags': 'tags', }, 'location_map': { 'filter': 'query', 'orderby': 'query', 'top': 'query', 'skip': 'query', 'select': 'query', 'expand': 'query', 'apply': 'query', 'count': 'query', 'inlinecount': 'query', 'at': 'query', 'tags': 'query', }, 'collection_format_map': { } }, headers_map={ 'accept': [ 'application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ], 'content_type': [], }, api_client=api_client )