def update_package_holder( connection: Connection, body: dict, id: str, project_id: Optional[str] = None, prefer: str = "respond-async", error_msg: Optional[str] = None) -> requests.Response: """Fill the content of the in-memory metadata package holder per supplied specification. Currently, it's only supported when the holder is empty. Args: connection (Connection): Object representation of connection to MSTR Server. body (dict): dictionarized PackageConfig object (with `to_dict()`) id (str): ID of the package to be updated prefer (str, optional): API currently just supports asynchronous mode, not support synchronous mode, so header parameter ‘Prefer’ must be set to ‘respond-async’ in your request. Defaults to "respond-async". project_id (Optional[str]): Optional ID of a project. Defaults to None. error_msg (Optional[str]): Optional error message. Defaults to None. Returns: requests.Response: Response object containing all of the information returned by the server. """ project_id = project_id if project_id is not None else connection.project_id return connection.put(url=f'{connection.base_url}/api/packages/{id}', headers={ 'X-MSTR-ProjectID': project_id, 'Prefer': prefer }, json=body)
def update_device(connection: Connection, id: str, body: dict, error_msg: Optional[str] = None): """Update a device. Args: connection: MicroStrategy REST API connection object id: ID of the device body: Device update info. error_msg (string, optional): Custom Error Message for Error Handling Returns: Complete HTTP response object. Expected status is 200. """ url = f"{connection.base_url}/api/v2/devices/{id}" return connection.put(url=url, json=body)
def upload_package(connection: Connection, id: str, file: bytes, project_id: Optional[str] = None, error_msg: Optional[str] = None) -> requests.Response: """Upload package to sandbox directly. Args: connection (Connection): Object representation of connection to MSTR Server. id (str): ID of the package to be uploaded. file (bytes): package in a format of a binary string. project_id (Optional[str]): Optional ID of a project. Defaults to None. error_msg (Optional[str]): Optional error message. Defaults to None. Returns: requests.Response: Response object containing all of the information returned by the server. """ project_id = project_id if project_id is not None else connection.project_id return connection.put( url=f'{connection.base_url}/api/packages/{id}/binary', headers={'X-MSTR-ProjectID': project_id}, files={'file': file})