Layer7 Access Management

Expand all | Collapse all

Creating policy objects using Swagger Rest API

Jump to Best Answer
  • 1.  Creating policy objects using Swagger Rest API

    Posted 08-26-2017 08:15 PM

    Hi All,

     

    I am trying to explore the options for creating agent and other objects using Swagger Rest API for R12.7, I am getting error I think I am doing something incorrect:

     

    I tried to create an Agent, using 

     

    POST /ca/api/sso/services/policy/v1/SmAgents

     

     

    {
    "Name": "test-agent",
    "Desc": "testagent",
    "AgentTypeLink": {
    "id": "string",
    "path": "/SmAgent4xs/test-agent",
    "href": "string",
    "desc": "string"
    },
    "RealmHintAttrId": 0,
    "type": "string",
    "id": "string"
    }

     

    I got error:

    "message": "Invalid class name: string", "code": 812

     

    Please suggest correct Syntax for creating agents, I would like to create some more objects using API.

     

    Thank you



  • 2.  Re: Creating policy objects using Swagger Rest API
    Best Answer

    Posted 08-27-2017 09:00 PM

    Hi Richard,

     

    Please find correct syntax for creating agents using REST API below :

     

    Create non 4x agent of type "Web Agent":

    Option 1 : Specify full details of Agent Type

    Request  :

     

    {
    "Name": "test-agent",
    "Desc": "test-agent",
    "AgentTypeLink": {
    "id": "CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
    "path": "/SmAgentTypes/Web+Agent",
    "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
    "desc": "SiteMinder Web Agent"
    }
    }

     

    Response :

    {
      "responseType": "object",
      "data": {
        "id": "CA.SM::Agent@01-00019b7e-686f-19a3-a562-ea9f0a837c7f",
        "type": "SmAgent",
        "Name": "test-agent",
        "Desc": "test-agent",
        "RealmHintAttrId": 0,
        "AgentTypeLink": {
          "id": "CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "path": "/SmAgentTypes/Web+Agent",
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "desc": "SiteMinder Web Agent"
        }
      },
      "links": {
        "self": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00019b7e-686f-19a3-a562-ea9f0a837c7f"
        },
        "usedby": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00019b7e-686f-19a3-a562-ea9f0a837c7f/usedby"
        },
        "classinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00019b7e-686f-19a3-a562-ea9f0a837c7f/classinfo"
        },
        "editinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00019b7e-686f-19a3-a562-ea9f0a837c7f?op=editinfo"
        }
      }
    }

     

    Create non 4x agent of type "Web Agent":

    Option 2 : Specify minimal details of Agent Type

     

    Request  :

    {
    "Name": "test-agent-2",
    "Desc": "test-agent-2",
    "AgentTypeLink": {
    "path": "/SmAgentTypes/Web+Agent"
    }
    }

     

    Response:

    {
      "responseType": "object",
      "data": {
        "id": "CA.SM::Agent@01-00021b81-6909-19a3-a562-ea9f0a837c7f",
        "type": "SmAgent",
        "Name": "test-agent-2",
        "Desc": "test-agent-2",
        "RealmHintAttrId": 0,
        "AgentTypeLink": {
          "id": "CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "path": "/SmAgentTypes/Web+Agent",
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "desc": "SiteMinder Web Agent"
        }
      },
      "links": {
        "self": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00021b81-6909-19a3-a562-ea9f0a837c7f"
        },
        "usedby": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00021b81-6909-19a3-a562-ea9f0a837c7f/usedby"
        },
        "classinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00021b81-6909-19a3-a562-ea9f0a837c7f/classinfo"
        },
        "editinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00021b81-6909-19a3-a562-ea9f0a837c7f?op=editinfo"
        }
      }
    }

     

    Create 4x agent of type "Web Agent":

    Option : Specify minimal details of Agent Type

     

    Request :

    {
    "IpAddr": "127.0.0.1",
    "Secret": "siteminder",
    "Name": "test-4x-agent",
    "Desc": "test-4x-agent",
    "AgentTypeLink": {
    "path": "/SmAgentTypes/Web+Agent"
    }
    }

     

    Response:

    {
      "responseType": "object",
      "data": {
        "id": "CA.SM::Agent@01-00018225-69b9-19a3-a562-ea9f0a837c7f",
        "type": "SmAgent4x",
        "Name": "test-4x-agent",
        "Desc": "test-4x-agent",
        "IpAddr": "127.0.0.1",
        "RealmHintAttrId": 0,
        "Secret": "{RC2}xLnbWGQ49M8XOziJ1wsXqMMh8G9hNBjk",
        "AgentTypeLink": {
          "id": "CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "path": "/SmAgentTypes/Web+Agent",
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::AgentType@10-8d78bb96-ae15-11d1-9cdd-006008aac24b",
          "desc": "SiteMinder Web Agent"
        }
      },
      "links": {
        "self": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00018225-69b9-19a3-a562-ea9f0a837c7f"
        },
        "usedby": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00018225-69b9-19a3-a562-ea9f0a837c7f/usedby"
        },
        "classinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00018225-69b9-19a3-a562-ea9f0a837c7f/classinfo"
        },
        "editinfo": {
          "href": "https://shruj01-i1850:8443/ca/api/sso/services/policy/v1/objects/CA.SM::Agent@01-00018225-69b9-19a3-a562-ea9f0a837c7f?op=editinfo"
        }
      }
    }

     

    Let me know if you have any questions.


    Regards,

    Ujwol 



  • 3.  Re: Creating policy objects using Swagger Rest API

    Posted 08-28-2017 10:41 AM

    Thanks Ujwol

     

    That works, how do you identify the Links/Paths/Href, because i am trying to create other objects like agent group/Domain/Auth scheme/policies all fails. I was able to create ACO successfully. 



  • 4.  Re: Creating policy objects using Swagger Rest API

    Posted 08-28-2017 12:39 PM

    To identify path, you can perform GET request first for that object.


    They all however follow the pattern. So once you know the pattern you can always guess them.