Пример #1
0
def example_api_get_project():
    #  Set the configuration
    configuration = openapi_client.Configuration(
        host=example_host,
    )
    configuration.verify_ssl = False
    configuration.ssl_ca_cert = None
    configuration.assert_hostname = False
    configuration.cert_file = None

    #  Get an access token and add it to the configuration
    with openapi_client.ApiClient(configuration) as api_client:
        api_instance_auth = openapi_client.AuthenticationApi(api_client)
        body_login = openapi_client.ApiCredentials(password=example_password, username=example_username)
        api_response = api_instance_auth.login(body_login)
        configuration.access_token = api_response.token

        # Create a ProjectApi instance to make API storage commands
        api_instance = openapi_client.ProjectApi(api_client)

        print("# Get a single project")
        try:
            api_response = api_instance.get_project(project_name="Example-Archive-Project")
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling ProjectApi->get_project (example GET single project): %s\n" % e)

        print("# Get ALL projects")
        try:
            api_response = api_instance.list_projects()
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling ProjectApi->list_projects (example GET list of projects): %s\n" % e)
Пример #2
0
def example_api_create_update_project_restore():
    # Create instance of a restore project (the request body)
    example_restore = make_instance_restore_project(include_optional=False)
    example_restore_optional = make_instance_restore_project(include_optional=True)

    #  Set the configuration
    configuration = openapi_client.Configuration(
        host=example_host,
    )
    configuration.verify_ssl = False
    configuration.ssl_ca_cert = None
    configuration.assert_hostname = False
    configuration.cert_file = None

    #  Get an access token and add it to the configuration
    with openapi_client.ApiClient(configuration) as api_client:
        api_instance_auth = openapi_client.AuthenticationApi(api_client)
        body_login = openapi_client.ApiCredentials(password=example_password, username=example_username)
        api_response = api_instance_auth.login(body_login)
        configuration.access_token = api_response.token

        # Create a ProjectApi instance to make API storage commands
        api_instance = openapi_client.ProjectApi(api_client)

        print("# Create restore project with optional fields")
        try:
            api_response = api_instance.update_restore_project(project_name="Example-Restore-Project-Optional-Fields",
                                                               body=example_restore_optional)
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling ProjectApi->update_restore_project (example for restore from local nas "
                  "to local nas w/ optional fields): %s\n" % e)

        print("# Create restore project with required fields")
        try:
            api_response = api_instance.update_restore_project(project_name="Example-Restore-Project",
                                                               body=example_restore)
            pprint(api_response)
        except ApiException as e:
            print("Exception when calling ProjectApi->update_restore_project (example for restore from local nas "
                  "to local nas): %s\n" % e)
def test_project_api():
    show_projects()

    create_project_with_file_system_connector()
    show_projects()

    update_project_with_file_system_connector()
    show_projects()

    create_project_with_git_connector()
    show_projects()

    create_project_with_multiversion_file_system_connector()
    show_projects()

    create_project_with_tfs_connector()
    show_projects()

    create_project_with_svn_connector()
    show_projects()


with openapi_client.ApiClient(configuration) as api_client:
    client = openapi_client.ProjectApi(api_client)

    try:
        test_project_api()
    except ApiException as e:
        print('Exception when calling ProjectApi: %s\n' % e)