def delete(context, id, etag): result = component.delete(context, id=id, etag=etag) if result.status_code == 204: utils.format_output({'id': id, 'message': 'Component deleted.'}, context.format) else: utils.format_output(result.json(), context.format)
def create(context, name, type, canonical_project_name, data, title, message, url, topic_id, export_control): """create(context, name, type, canonical_project_name, data, title, message, url, topic_id, export_control) # noqa Create a component. >>> dcictl component-create [OPTIONS] :param string name: Name of the component [required] :param string type: Type of the component [required] :param string topic_id: ID of the topic to associate with [required] :param string canonical_project_name: Project name :param json data: JSON to pass to the component :param string title: Title of the component :param string message: Message for the component :param string url: URL resource to monitor :parma bool export_control: Set the component visible for users """ data = json.loads(data) result = component.create( context, name=name, type=type, canonical_project_name=canonical_project_name, data=data, title=title, message=message, url=url, topic_id=topic_id, export_control=export_control ) utils.format_output(result, context.format, None, component.TABLE_HEADERS)
def update(context, id, etag, name, password, role): result = user.update(context, id=id, etag=etag, name=name, password=password, role=role) if result.status_code == 204: utils.format_output({"id": id, "etag": etag, "message": "User updated."}, context.format) else: utils.format_output(result.json(), context.format)
def delete(context, id, etag): result = user.delete(context, id=id, etag=etag) if result.status_code == 204: utils.format_output({"id": id, "message": "User deleted."}, context.format) else: utils.format_output(result.json(), context.format)
def delete(context, id, etag): result = remoteci.delete(context, id=id, etag=etag) if result.status_code == 204: utils.format_output({'id': id, 'message': 'Remote CI deleted.'}, context.format) else: utils.format_output(result.json(), context.format)
def create(context, name, type, canonical_project_name, data, sha, title, message, url, git, ref): data = json.loads(data) result = component.create( context, name=name, type=type, canonical_project_name=canonical_project_name, data=data, sha=sha, title=title, message=message, url=url, git=git, ref=ref ).json() utils.format_output(result, context.format, component.RESOURCE[:-1])
def update(context, id, etag, name, data): result = test.update(context, id=id, etag=etag, name=name, data=data) if result.status_code == 204: utils.format_output({'id': id, 'etag': etag, 'name': name, 'message': 'Test updated.'}, context.format) else: utils.format_output(result.json(), context.format)
def list(context): """list(context) List all jobstates. >>> dcictl jobstate-list """ result = jobstate.list(context) utils.format_output(result, context.format, jobstate.RESOURCE, jobstate.TABLE_HEADERS)
def list(context, job_id): """list(context) List all files. >>> dcictl file-list """ result = file.list(context, where='job_id:' + job_id) utils.format_output(result, context.format, file.RESOURCE, file.TABLE_HEADERS)
def list(context): """list(context) List all Remote CIs >>> dcictl remoteci-list """ result = remoteci.list(context) utils.format_output(result, context.format, remoteci.RESOURCE, remoteci.TABLE_HEADERS)
def list(context): """list(context) List all users. >>> dcictl user-list """ result = user.list(context) utils.format_output(result, context.format, user.RESOURCE, user.TABLE_HEADERS)
def show(context, id): """show(context, id) Show a jobdefinition. :param string id: ID of the jobdefinition to show [required] """ result = jobdefinition.get(context, id=id) utils.format_output(result, context.format, jobdefinition.RESOURCE[:-1], jobdefinition.TABLE_HEADERS)
def recheck(context, id): """recheck(context, id) Reecheck a job. >>> dcictl job-recheck [OPTIONS] :param string id: ID of the job to recheck [required] """ result = job.recheck(context, id=id) utils.format_output(result, context.format, job.RESOURCE[:-1])
def show(context, id): """show(context, id) Show a component >>> dcictl component-show [OPTIONS] :param string id: ID of the component to show [required] """ result = component.get(context, id=id) utils.format_output(result, context.format, component.RESOURCE[:-1], component.TABLE_HEADERS)
def show(context, id): """show(context, id) Show a test. >>> dcictl test-show [OPTIONS] :param string id: ID of the test to return [required] """ result = test.get(context, id=id) utils.format_output(result, context.format, test.RESOURCE[:-1], test.TABLE_HEADERS)
def list(context, topic_id): """list(context, topic_id) List all components. >>> dcictl component-list [OPTIONS] :param string topic_id: The topic ID for the list of components to return """ components = topic.list_components(context, topic_id) utils.format_output(components, context.format, component.RESOURCE, component.TABLE_HEADERS)
def show(context, id): """show(context, id) Show a user. >>> dcictl user-show [OPTIONS] :param string id: ID of the user to show [required] """ result = user.get(context, id=id) utils.format_output(result, context.format, user.RESOURCE[:-1], user.TABLE_HEADERS)
def file_list(context, id): """file_list(context, id, path) Show a component file >>> dcictl component-file-list [OPTIONS] :param string id: ID of the component to show [required] """ result = component.file_list(context, id=id) utils.format_output(result, context.format, 'component_files', component.TABLE_FILE_HEADERS)
def show(context, id): """show(context, id) Show a jobstate. >>> dcictl jobstate-show [OPTIONS] :param string id: ID of the jobstate to show [required] """ result = jobstate.get(context, id=id) utils.format_output(result, context.format, jobstate.RESOURCE[:-1], jobstate.TABLE_HEADERS)
def show(context, id): """show(context, id) Show a Remote CI. >>> dcictl remoteci-show [OPTIONS] :param string id: ID of the remote CI to show [required] """ result = remoteci.get(context, id=id) utils.format_output(result, context.format, remoteci.RESOURCE[:-1], remoteci.TABLE_HEADERS)
def update(context, id, etag, name, team_id, data, active): result = remoteci.update(context, id=id, etag=etag, name=name, team_id=team_id, data=data, active=active) if result.status_code == 204: utils.format_output({'id': id, 'etag': etag, 'name': name, 'active': active, 'message': 'Remote CI updated.'}, context.format) else: utils.format_output(result.json(), context.format)
def list(context, team_id): """list(context, team_id) List all tests. >>> dcictl test list """ if not team_id: team_id = user.get(context, context.login).json()['user']['team_id'] result = team.list_tests(context, team_id) utils.format_output(result, context.format, test.RESOURCE, test.TABLE_HEADERS)
def file_upload(context, id, path): """file_upload(context, id, path) Upload a file in a component >>> dcictl component-file-upload [OPTIONS] :param string id: ID of the component to show [required] :param string path: Path to the file to upload [required] """ result = component.file_upload(context, id=id, file_path=path) utils.format_output(result, context.format, 'component_file', component.TABLE_FILE_HEADERS)
def list_issues(context, id): """list_issues(context, id) List all job attached issues. >>> dcictl job-list-issue [OPTIONS] :param string id: ID of the job to retrieve issues from [required] """ result = job.list_issues(context, id=id) headers = ['status', 'product', 'component', 'title', 'url'] utils.format_output(result, context.format, 'issues', headers)
def list(context, topic_id): """list(context, id) List all jobdefinitions. >>> dcictl jobdefinition-list [OPTIONS] :param string topic_id: Topic ID [required] """ result = jobdefinition.list(context, topic_id) utils.format_output(result, context.format, jobdefinition.RESOURCE, jobdefinition.TABLE_HEADERS)
def status(context, type, topic_id): """status(context, type, topic_id) Show current status of a component >>> dcictl component-status [OPTIONS] :param string type: Type of component to look up status for :param string topic_id: The topic ID for the list of components to return """ result = component.status(context, type=type, topic_id=topic_id) utils.format_output(result, context.format, 'jobs', component.TABLE_STATUS_HEADERS)
def delete(context, id): """delete(context, id) Delete a component. >>> dcictl component-delete [OPTIONS] :param string id: ID of the component to delete [required] """ result = component.delete(context, id=id) if result.status_code == 204: utils.print_json({'id': id, 'message': 'Component deleted.'}) else: utils.format_output(result, context.format)
def attach_test(context, id, test_id): """attach_test(context, id, test_id) Attach a test to a remoteci. >>> dcictl remoteci-attach-test [OPTIONS] :param string id: ID of the remoteci to attach the test to [required] :param string test_id: ID of the test to attach [required] """ result = remoteci.add_test(context, id=id, test_id=test_id) utils.format_output(result, context.format, None, ['remoteci_id', 'test_id'])
def attach_test(context, id, test_id): """attach_test(context, id, test_id) Attach a test to a jobdefinition. >>> dcictl jobdefinition-attach-test [OPTIONS] :param string id: ID of the jobdefinition to attach the test to [required] :param string test_id: ID of the test to attach [required] """ result = jobdefinition.add_test(context, id=id, test_id=test_id) utils.format_output(result, context.format, None, ['jobdefinition_id', 'test_id'])
def list_test(context, id): """unattach_test(context, id, test_id) Unattach a test from a remoteci. >>> dcictl remoteci-unattach-test [OPTIONS] :param string id: ID of the remoteci to unattach the test from [required] :param string test_id: ID of the test to unattach [required] """ result = remoteci.get_tests(context, id=id) utils.format_output(result, context.format, test.RESOURCE, test.TABLE_HEADERS)
def print_response(response, format, verbose): if response and response.status_code != 204: utils.format_output(response, format, verbose=verbose)