API Connect

 View Only
Expand all | Collapse all

CLI tools for Apic v10

  • 1.  CLI tools for Apic v10

    Posted Sat January 22, 2022 12:33 AM
    Hi,

    We have installed Apic v10.0.3.0(cp4i). But when we execute apic related commands facing "apic command not found" error through linux cli. For that we need apicup, apic, & apicops binary files. So can you please guide us from where we can download these files.

    ------------------------------
    Suraj Sakpal
    ------------------------------


  • 2.  RE: CLI tools for Apic v10

    Posted Mon January 24, 2022 07:05 AM
    hi, Suraj
    I assume you can log into the CMC as "admin". Do you see the tile "Download toolkit"? For starters, I recommend downloading the "CLI Only" for your platform along with the "client-creds". I usually create a symbolic link (on Linux) "apic-slim" to "apic" -- however, that is a personal preference. Getting started can be tricky. I recommend you start with the following. NOTE: The endpoints in your installation are likely to differ.

    Get started with command line

    Each user belongs to a realm and authenticates with an identity-provider. To log in, even the admin needs to provide the name of the identity-provider. How can I find the name of the identity-provider if I cannot login? There is a way out. CMC objects belong to the admin scope. This command works without login:

      $ ./apic identity-providers:list --scope admin --server platform.mgmt.dev.apic.xxxxx.test --fields name,title
      total_results: 1
      results:
        - name: default-idp-1
          title: Cloud Manager User Registry

    Log in as admin:

      $ ./apic login
      Enter your API Connect credentials
      Server? apim.mgmt.dev.apic.xxxxx.test
      Realm? admin/default-idp-1
      Username? admin
      Password?

    At this stage there is only one Organization:

    $ ./apic orgs:list  -s apim.mgmt.dev.apic.xxxxx.test --format yaml
    total_results: 1
    results:
      - type: org
        api_version: 2.0.0
        id: 790cbfc3-fafc-489e-a2fe-d7e827cea731
        name: admin
        title: Cloud Admin
        summary: Cloud Admin organization
        state: enabled
        org_type: admin
        owner_url: >-
          https://apim.mgmt.dev.apic.xxxxx.test/api/user-registries/790cbfc3-fafc-489e-a2fe-d7e827cea731/7218cc7f-4ac9-4f0a-992c-53ec31eb032e/users/6037d730-4218-4ed2-8e03-1aa596d34671
        created_at: '2020-07-21T14:15:19.160Z'
        updated_at: '2020-07-21T14:15:19.160Z'
        url: >-
          https://apim.mgmt.dev.apic.xxxxx.test/api/orgs/790cbfc3-fafc-489e-a2fe-d7e827cea731

    The output for just one org is voluminous. Other objects emit far more data. You can generate JSON with --format json, pipe it through jq and extract desired elements to feed your automated scripts.

    $ ./apic orgs:list  -s apim.mgmt.dev.apic.xxxxx.test --format json | jq '.results[0] | {name: .name, org_type: .org_type, summary: .summary, id: .id}'
    {
      "name": "admin",
      "org_type": "admin",
      "summary": "Cloud Admin organization",
      "id": "790cbfc3-fafc-489e-a2fe-d7e827cea731"
    }

    JQ Tutorial is an excellent reference. For further material please consult ibm-apiconnect/apic-hybrid-cloud-enablement in particular Publish API Product Version to a Consumer Organization -- a complex script to implement a specific use case.



    ------------------------------
    Ravi Ramnarayan
    Technical Account Manager - Expertise Connect
    IBM
    ------------------------------



  • 3.  RE: CLI tools for Apic v10

    Posted Sun January 15, 2023 02:01 PM

    Hi Ravi,

    While am trying to write a script - i need below login part to be done via script- using shell/python.

    May i know how can be this achieved. Please help.

    $ ./apic login
      Enter your API Connect credentials
      Server? apim.mgmt.dev.apic.xxxxx.test
      Realm? admin/default-idp-1
      Username? admin
      Password?


    ------------------------------
    Sai Kiran
    ------------------------------



  • 4.  RE: CLI tools for Apic v10

    Posted Tue January 17, 2023 02:36 PM
    hi, Sai Kiran
    Recommend "apic --help" which yields a long list of apic commands. "login" is one such. Next: "apic login --help". See Non Interactive login -- bold text at bottom.

    $ apic login --help
    Usage: apic login [flags]
    Log in to an IBM API Connect cloud
    Flags:
    --apiKey string apiKey
    --context string context
    -h, --help Help for login
    -p, --password string password
    -r, --realm string realm
    -s, --server string management server endpoint
    --sso sso
    -u, --username string user name
    Examples:
    Interactive login
    $ apic login
    Enter your API Connect credentials
    ? Server: mgmnthost.com
    ? Realm: company/realm
    ? Username: tommy
    ? Password: password
    Logged into mgmnthost.com successfully

    Non-interactive login
    $ apic login --username tommy --password password --server mgmnthost.com --realm company/realm
    Logged into mgmnthost.com successfully


    ------------------------------
    Ravi Ramnarayan
    Technical Account Manager - Expertise Connect
    IBM
    ------------------------------



  • 5.  RE: CLI tools for Apic v10

    Posted Wed October 18, 2023 12:13 PM

    apic login --realm admin/default-idp-1 --server apim.mgmt.dev.apic.xxxxx.test -u admin -p ****



    ------------------------------
    Sriniwas Acharya
    ------------------------------



  • 6.  RE: CLI tools for Apic v10

    Posted Tue January 25, 2022 08:19 AM
    Please see publications in ibm-apiconnect/example-toolkit-scripts . In particular,

    ------------------------------
    Ravi Ramnarayan
    Technical Account Manager - Expertise Connect
    IBM
    ------------------------------



  • 7.  RE: CLI tools for Apic v10

    Posted Tue January 25, 2022 08:39 AM
    Hi Ravi,

    Thanks for reply. We will check.

    ------------------------------
    Suraj Sakpal
    ------------------------------



  • 8.  RE: CLI tools for Apic v10

    Posted Tue January 25, 2022 09:48 AM
    Hi Ravi,

    We successfully installed CLI Only(apic) on ApicV10 linux server with chmod permission. But we run following command(by changing server name)- "$ ./apic identity-providers:list --scope admin --server platform.mgmt.dev.apic.xxxxx.test --fields name,title" it shows below error-
    Error: Resource not found
    And when we run - $ apic -v it shows following error- bash: apic: cannot execute binary file.

    ------------------------------
    Suraj Sakpal
    ------------------------------



  • 9.  RE: CLI tools for Apic v10

    Posted Tue January 25, 2022 10:38 AM
    About "apic" not being executable -- please check file permissions and path on your platform. These are bumps during your learning curve. I am sure you can get past them. Good luck.

    ------------------------------
    Ravi Ramnarayan
    Technical Account Manager - Expertise Connect
    IBM
    ------------------------------



  • 10.  RE: CLI tools for Apic v10

    Posted Wed January 26, 2022 04:01 AM
    In APIC v10 'apicup' is only used for vmware OVAs, so you don't need that.
    apicops is also not needed unless directed to do so by APIC L3 Support, so you don't need that either.
    The apic toolkit can be downloaded from your API Manager server as per the docs.

    ------------------------------
    Chris Dudley
    ------------------------------