def pause_ros_backup_job(session, ros_backup_job_id, return_type=None, **kwargs): """ Pauses a remote object storage backup job. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type ros_backup_job_id: str :param ros_backup_job_id: The remote object storage backup job 'name' value as returned by get_all_ros_backup_jobs. For example: 'bkpjobs-00000001'. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_ros_destination_id(ros_backup_job_id) path = '/api/object_storage_backup_jobs/{0}/pause.json' \ .format(ros_backup_job_id) return session.post_api(path=path, return_type=return_type, **kwargs)
def get_ros_destination(session, ros_destination_id, return_type=None, **kwargs): """ Retrieves details for a single remote object storage destination. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type ros_destination_id: str :param ros_destination_id: The remote object storage destination 'name' value as returned by get_all_ros_destinations. For example: 'obsdst-00000001'. Required. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_ros_destination_id(ros_destination_id) path = '/api/object_storage_destinations/{0}.json' \ .format(ros_destination_id) return session.get_api(path=path, return_type=return_type, **kwargs)
def get_all_ros_destination_backup_jobs(session, ros_destination_id, start=None, limit=None, return_type=None, **kwargs): """ Retrieves details for all remote object storage backup jobs for the specified remote object storage destination. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type ros_destination_id: str :param ros_destination_id: The remote object storage destination 'name' value as returned by get_all_ros_destinations. For example: 'obsdst-00000001'. Required. :type start: int :param start: The offset to start displaying remote object storage backup jobs from. Optional. :type: limit: int :param limit: The maximum number of remote object storage backup jobs to return. Optional. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_ros_destination_id(ros_destination_id) path = '/api/object_storage_destinations/{0}/backup_jobs.json' \ .format(ros_destination_id) parameters = verify_start_limit(start, limit) return session.get_api(path=path, parameters=parameters, return_type=return_type, **kwargs)
def create_ros_restore_job(session, display_name, ros_destination_id, pool_id, restore_mode, volume_name, local_snapshot_id, object_store_key, crypt, dedupe='NO', compress='NO', return_type=None, **kwargs): """ Creates a new remote object storage backup job. Backups are based on snapshots taken by the specified snapshot policy. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type display_name: str :param display_name: A text label to assign to the remote object storage restore job. For example: 'PDF archive restore'. May not contain a single quote (') character. Required. :type ros_destination_id: str :param ros_destination_id: The remote object storage destination 'name' value as returned by get_all_ros_destinations for the destination where the snapshot is stored. For example: 'obsdst-00000001'. Required. :type pool_id: str :param pool_id: The pool 'name' value as returned by get_all_pools where the snapshot will be restored. For example: 'pool-00000001'. The volume will be created on this pool. Required. :type restore_mode: str :param restore_mode: This parameter expects one of three values: 'restore', 'clone', or 'import_seed'. When set to 'restore', the volume can be immediately attached to servers; data is retrieved from object storage on demand and in a background process; and all data will eventually be restored. When set to 'clone', the volume can be immediately attached to servers; and starting with zero capacity, data is retrieved from object storage only on-demand when accessed by the attached servers. When set to 'import_seed', a full capacity clone is created, including snapshot time-stamping; The volume can be attached to servers only after the volume's data was fully retrieved from object storage; use this mode to import initial data seed for remote mirroring. Required. :type volume_name: str :param volume_name: A text label to assign to the restored volume. For example: 'pdf-files'. May not contain a single quote (') character. Required. :type local_snapshot_id: str :param local_snapshot_id: Either this or object_store_key is required. If using local_snapshot_id, the desired snapshot 'name' is passed as returned by get_all_snapshots (with the ros_backup_job_id specified). For example: 'snap-00000001'. Optional. :type object_store_key: str :param object_store_key: Either this or local_snapshot_id is required. If using object_store_key, this is the full object storage key for the "path" to the individual snapshot to be restored. For example: "cloud1.C97E9A00ADE7489BB08A9AB3B0B6484F/myvpsa.vsa-00000169/ myvol.volume-00000011/2015-07-01T09:26:01+0000_snap-0000003e/". This is useful when there is no local_snapshot_id to reference; for example, if the snapshot is being restored to a different VPSA than the original source. Optional. :type crypt: str :param crypt: If set to 'YES', the resulting volume of the restoration will be encrypted with the VPSA's encryption key. If 'NO', the resulting volume will not be encrypted. Required. :type dedupe: str :param dedupe: If set to 'YES', deduplication will be enabled on the volume. If 'NO', it won't. Optional. :type compress: str :param compress: If set to 'YES', compression will be enabled on the volume. If 'NO', it won't. Optional. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_ros_destination_id(ros_destination_id) verify_pool_id(pool_id) verify_restore_mode(restore_mode) body_values = { 'name': verify_field(display_name, "display_name"), 'remote_object_store': ros_destination_id, 'poolname': pool_id, 'mode': restore_mode, 'volname': verify_field(volume_name, "volume"), 'crypt': verify_boolean(crypt, "crypt") } if local_snapshot_id is None and object_store_key is None: raise ValueError('Either "local_snapshot_id" or "object_store_key" ' 'needs to be passed as a parameter.') if local_snapshot_id is not None: verify_snapshot_id(local_snapshot_id) body_values['local_snapname'] = local_snapshot_id if object_store_key is not None: body_values['key'] = verify_field(object_store_key, "object_store_key") if dedupe is not None: body_values["dedupe"] = verify_boolean(dedupe, 'dedupe') if compress is not None: body_values["compress"] = verify_boolean(compress, 'compress') path = '/api/object_storage_restore_jobs.json' return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def create_ros_backup_job(session, display_name, ros_destination_id, sse, volume_id, policy_id, compression='YES', return_type=None, **kwargs): """ Creates a new remote object storage backup job. Backups are based on snapshots taken by the specified snapshot policy. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type display_name: str :param display_name: A text label to assign to the remote object storage backup job. For example: 'Daily S3 Backup'. May not contain a single quote (') character. Required. :type sse: str :param sse: The remote object storage destination SSE: 'NO', 'AES256', 'KMS', 'KMSKEYID Required. :type ros_destination_id: str :param ros_destination_id: The remote object storage destination 'name' value as returned by get_all_ros_destinations. For example: 'obsdst-00000001'. Required. :type volume_id: str :param volume_id: The volume 'name' value as returned by get_all_volumes for the volume to be backed up. For example: 'volume-00000001'. Required. :type policy_id: str :param policy_id: The snapshot policy 'name' value as returned by get_all_snapshot_policies. For example: 'policy-00000001'. This policy will determine the frequency and retention of backups for this job. Required. :type compression: str :param compression: If set to 'YES', backup data will be compressed in flight. If 'NO', backup data will not be compressed. Set to 'YES' by default. Optional. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ display_name = verify_field(display_name, "display_name") verify_ros_destination_id(ros_destination_id) verify_volume_id(volume_id) verify_policy_id(policy_id) body_values = { 'name': display_name, 'destination': ros_destination_id, 'volume': volume_id, 'policy': policy_id, 'sse': sse, 'compression': verify_boolean(compression, "compression") } path = '/api/object_storage_backup_jobs.json' return session.post_api(path=path, body=body_values, return_type=return_type, **kwargs)
def update_ros_destination(session, ros_destination_id, bucket=None, endpoint=None, username=None, password=None, public=None, use_proxy=None, proxy_host=None, proxy_port=None, proxy_username=None, proxy_password=None, return_type=None, **kwargs): """ Updates options for an existing remote object storage destination. Parameters set to 'None' will not have their existing values changed. :type session: zadarapy.session.Session :param session: A valid zadarapy.session.Session object. Required. :type ros_destination_id: str :param ros_destination_id: The remote object storage destination 'name' value as returned by get_all_ros_destinations. For example: 'obsdst-00000001'. Required. :type bucket: str :param bucket: See documentation for create_ros_destination. Optional. :type endpoint: str :param endpoint: See documentation for create_ros_destination. Optional. :type username: str :param username: See documentation for create_ros_destination. Optional. :type password: str :param password: See documentation for create_ros_destination. Optional. :type public: str :param public: See documentation for create_ros_destination. Optional. :type use_proxy: str :param use_proxy: See documentation for create_ros_destination. Optional. :type proxy_host: str :param proxy_host: See documentation for create_ros_destination. Optional. :type proxy_port: str :param proxy_port: See documentation for create_ros_destination. Optional. :type proxy_username: str :param proxy_username: See documentation for create_ros_destination. Optional. :type proxy_password: str :param proxy_username: See documentation for create_ros_destination. Optional. :type return_type: str :param return_type: If this is set to the string 'json', this function will return a JSON string. Otherwise, it will return a Python dictionary. Optional (will return a Python dictionary by default). :rtype: dict, str :returns: A dictionary or JSON data set as a string depending on return_type parameter. """ verify_ros_destination_id(ros_destination_id) body_values = {} if bucket is not None: body_values['bucket'] = verify_field(bucket, "bucket") if endpoint is not None: body_values['endpoint'] = endpoint if username is not None: body_values['username'] = verify_field(username, "username") if password is not None: body_values['password'] = verify_field(password, "password") if public is not None: public = verify_boolean(public, "public") body_values['connectVia'] = 'public' if public == 'YES' else 'fe' if use_proxy is not None: use_proxy = verify_boolean(use_proxy, "use_proxy") body_values['use_proxy'] = str(use_proxy == 'YES').lower() if proxy_host is not None or use_proxy == 'YES': body_values['proxyhost'] = proxy_host if proxy_port is not None or use_proxy == 'YES': body_values['proxyport'] = verify_port(proxy_port) if proxy_username is not None: body_values['proxyuser'] = verify_field(proxy_username, "proxy_username") if proxy_password is not None: body_values['proxypassword'] = verify_field(proxy_password, "proxy_password") if not body_values: raise ValueError('At least one of the following must be set: ' '"bucket", "endpoint", "username", "password", ' '"public", "use_proxy", "proxy_host", "proxy_port", ' '"proxy_username", "proxy_password"') path = '/api/object_storage_destinations/{0}.json' \ .format(ros_destination_id) return session.put_api(path=path, body=body_values, return_type=return_type, **kwargs)