{"id":22379133,"url":"https://github.com/sky-uk/gonsx","last_synced_at":"2025-07-31T01:31:48.093Z","repository":{"id":57499415,"uuid":"63148257","full_name":"sky-uk/gonsx","owner":"sky-uk","description":"Go library for VMware vSphere NSX API","archived":false,"fork":false,"pushed_at":"2020-05-06T22:41:51.000Z","size":381,"stargazers_count":6,"open_issues_count":5,"forks_count":13,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-06-19T05:46:09.485Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sky-uk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-12T10:13:23.000Z","updated_at":"2024-06-19T05:46:09.486Z","dependencies_parsed_at":"2022-08-31T13:55:01.489Z","dependency_job_id":null,"html_url":"https://github.com/sky-uk/gonsx","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sky-uk%2Fgonsx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sky-uk%2Fgonsx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sky-uk%2Fgonsx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sky-uk%2Fgonsx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sky-uk","download_url":"https://codeload.github.com/sky-uk/gonsx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228204606,"owners_count":17884711,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-04T23:09:04.738Z","updated_at":"2024-12-04T23:09:05.313Z","avatar_url":"https://github.com/sky-uk.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GoNSX - Go library for VMware vSphere NSX API\n\n## Overview\n\nThis project is a NSXClient library for talking to NSX API.\n\n### Features\n\n| Feature                 | Create | Read  | Update  | Delete |\n|-------------------------|--------|-------|---------|--------|\n| DHCP Relay              |   Y    |   Y   |    Y    |   Y    |\n| Edge Interface          |   Y    |   Y   |    Y    |   Y    |\n| Security Group          |   Y    |   Y   |    Y    |   Y    |\n| Security Policy         |   Y    |   Y   |    Y    |   Y    |\n| Security Tag            |   Y    |   Y   |    Y    |   Y    |\n| Security Tag Attachment |   Y    |   Y   |    Y    |   Y    |\n| Service                 |   Y    |   Y   |    Y    |   Y    |\n| Transport Zone          |   N    |   Y   |    N    |   N    |\n| Virtual Wire            |   Y    |   Y   |    Y    |   Y    |\n\nImplementation of CRUD in above features is partial in some cases.\n\n\n### Security Policy features\n\n\n| Function                      | Attribute                         | Implemented |   Required  |\n|-------------------------------|-----------------------------------|-------------|-------------|\n| Common                        | Name (String)                     |      Y      |      Y      |\n|                               | Description (String)              |      Y      |      Y      |\n|                               | Inherit Security Policy (Boolean) |      N      |      N/A    |\n|                               |   Parent Policy (String)          |      N      |      N/A    |\n|                               | Weight/Precedence (Integer)       |      Y      |      Y      |\n| Guest Introspection Services  | List (String)                     |      N      |      N/A    |\n|                               | Name (String)                     |      N      |      N/A    |\n|                               | Action (String)                   |      N      |      N/A    |\n|                               | Service Type (String)             |      N      |      N/A    |\n|                               | Service Name (String )            |      N      |      N/A    |\n|                               | Service Profile (String)          |      N      |      N/A    |\n|                               | State (String)                    |      N      |      N/A    |\n|                               | Enforce (Boolean)                 |      N      |      N/A    |\n| Firewall rule                 | Name (String)                     |      Y      |      Y      |\n|                               | Description (String)              |      Y      |      Y      |\n|                               | Action (String)                   |      Y      |      Y      |\n|                               | Policy Security Groups (String[]) |      Y      |      Y      |\n|                               | Negate Source (Boolean)           |      N      |      N      |\n|                               | Destination (String[])            |      Y      |      Y      |\n|                               | Service (String[])                |      Y      |      Y      |\n|                               | *State (String)                   |      Y      |      Y      |\n|                               | Log (Boolean)                     |      N      |      N/A    |\n| Network Introspection Service | Name (String)                     |      N      |      N/A    |\n|                               | Description (String)              |      N      |      N/A    |\n|                               | Action (String)                   |      N      |      N/A    |\n|                               | Service Name (String)             |      N      |      N/A    |\n|                               | Profile (String)                  |      N      |      N/A    |\n|                               | Source (String[])                 |      N      |      N/A    |\n|                               | NegateSource (Boolean)            |      N      |      N/A    |\n|                               | Destination (String[])            |      N      |      N/A    |\n|                               | NegateDestination (Boolean)       |      N      |      N/A    |\n|                               | Service (String)                  |      N      |      N/A    |\n|                               | State (String)                    |      N      |      N/A    |\n|                               | Log (Boolean)                     |      N      |      N/A    |\n\n*State is defaulted to true in all cases and can't be modified.\n\n### Security Group features\n\nApart from the basic CRUD functionality the Security Group supports the following \n\n| Component               | Funcionality Name                                           | GONSX |\n|-------------------------|-------------------------------------------------------------|-------|\n| Security Group          | Add Multiple Dynamic Membership Criteria                    |   Y   |\n|                         | OS Name                                                     |   Y   |\n|                         | Computer Name                                               |   Y   |\n|                         | VM Name                                                     |   Y   |\n|                         | Security Tag                                                |   Y   |\n|                         | Entity : This could be                                      |   Y   |\n|                         |  - Another Security Group                                   |   Y   |\n|                         |  - Cluster                                                  |   Y   |\n|                         |  - Logical Switch                                           |   Y   |\n|                         |  - Logical Port Group                                       |   Y   |\n|                         |  - vApp                                                     |   Y   |\n|                         |  - IP Sets                                                  |   Y   |\n|                         |  - Directory Group                                          |   Y   |\n|                         |  - MAC Sets                                                 |   Y   |\n|                         |  - Security Tag                                             |   Y   |\n|                         |  - vNic                                                     |   Y   |\n|                         |  - Virtual Machine                                          |   Y   |\n|                         |  - Resource Pool                                            |   Y   |\n|                         |  - Distributed Port Group                                   |   Y   |\n| Security Group          | Add More than one Dynamic Membership criteria               |   y   |\n| Security Group          | Operators for more than one Dynamic Membership criteria     |   N   |\n| Security Group          | Static Membership (always add these )                       |   N   | \n|                         | Security Group                                              |   N   |  \n|                         | Cluster                                                     |   N   |   \n|                         | Logical Switch                                              |   N   |  \n|                         | Logical Port Group                                          |   N   |\n|                         | vApp                                                        |   N   |\n|                         | Datacenter                                                  |   N   |\n|                         | IP Sets                                                     |   N   |\n|                         | MAC Sets                                                    |   N   |\n|                         | Security Tag                                                |   N   |\n|                         | Directory Group                                             |   N   |\n|                         | vNic                                                        |   N   |\n|                         | Virtual Machine                                             |   N   |\n|                         | Resource Pool                                               |   N   |\n|                         | Distributed Port Group                                      |   N   |\n| Security Group          | Static Exclusions (always exclude these )                   |   N   |\n|                         | Security Group                                              |   N   |  \n|                         | Cluster                                                     |   N   |   \n|                         | Logical Switch                                              |   N   |  \n|                         | Logical Port Group                                          |   N   |\n|                         | vApp                                                        |   N   |\n|                         | Datacenter                                                  |   N   |\n|                         | IP Sets                                                     |   N   |\n|                         | MAC Sets                                                    |   N   |\n|                         | Security Tag                                                |   N   |\n|                         | Directory Group                                             |   N   |\n|                         | vNic                                                        |   N   |\n|                         | Virtual Machine                                             |   N   |\n|                         | Resource Pool                                               |   N   |\n|                         | Distributed Port Group                                      |   N   | \n| Security Group          | Static Exclusions (never include)                           |   N   |\n|                         | Security Group                                              |   N   |\n|                         | Cluster                                                     |   N   |   \n|                         | Logical Switch                                              |   N   |  \n|                         | Logical Port Group                                          |   N   |\n|                         | vApp                                                        |   N   |\n|                         | Datacenter                                                  |   N   |\n|                         | IP Sets                                                     |   N   |\n|                         | MAC Sets                                                    |   N   |\n|                         | Security Tag                                                |   N   |\n|                         | Directory Group                                             |   N   |\n|                         | vNic                                                        |   N   |\n|                         | Virtual Machine                                             |   N   |\n|                         | Resource Pool                                               |   N   |\n|                         | Distributed Port Group                                      |   N   | \n\n\nNOTE: \n\nSecurity Group - Add Multiple Dynamic Membership Criteria  \nThis functionality is implemented partially, this is not accounted when creating , however we can do it while editing.\n\n\n## Usage\n### NSXClient\n\nThe NSXClient is the class used to send requests to the NSX host and pass through credentials.\n \nImport the following files.\n \nTo create an NSX object run the following code, with the correct params. \n\n```\nimport (\n    \"github.com/sky-uk/gonsx\"\n)\n\nnsxclient := gonsx.NewNSXClient(url, username, password, ignoreSSL, debug)\n```\nThe params used:\n\n* url: URL of NSX host\n  \n\u003e E.G. https://nsxhost.com\n\n* username: NSX username\n* password: NSX password\n* ignoreSSL: bool on whether to ignore ssl (default false)\n* debug: bool on whether to debug output (default false)\n\nThe client is also used run the api calls once you have created the resource object.\n\n```\nnsxclient.Do(my_resource_obj)\n```\n\n\n### Virtual Wire(Logical Switch)\n\nVirtual Wire resource. This resource will call the Virtual Wires api within NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/virtualwire\n```\n\nCreate:\n\n```\n api := virtualwire.NewCreate(virtualWireCreateSpec, scopeID)\n nsxclient.Do(api)\n```\n\nRead:\n```\napi := virtualwire.NewGetAll(scopeID)\nnsxclient.Do(api)\nresp := api.GetResponse().FilterByName(virtualWireName)\n```\n\nRead single virtualwire:\n```\napi := virtualwire.NewGet(virtualwireID)\nnsxclient.Do(api)\nresp := api.GetResponse()\n```\n\nUpdate:\n```\napi := virtualwire.NewUpdate(name, desc, virtualwireID)\nnsxclient.Do(api)\n```\n\nDelete:\n```\napi := virtualwire.NewDelete(virtualWireID)\nnsxclient.Do(delete_api)\n```\n\n\n### Edge Interface\n\nInterface resource. This resource will call the interface api within NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/edgeinterface\n```\n\nCreate:\n\n```\n api := edgeinterface.NewCreate(\u0026edgeInterfaces, edgeId)\n nsxclient.Do(api)\n createdEdgeInterfaces := api.GetResponse()\n```\n\nRead:\n```\napi := edgeinterface.NewGet((edgeid, index)\nnsxclient.Do(api)\nedge := api.GetResponse()\n```\n\nUpdate:\n```\napi := edgeinterface.NewUpdate(edgeid, index, edge)\nnsxclient.Do(api)\n\n```\n\nDelete:\n```\napi := edgeinterface.NewDelete(edgeid, index)\nnsxclient.Do(api)\n```\n\n### Dhcp Relay\n\nDHCP resource. This resource will call the DHCP relay api within NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/dhcprelay\n```\n\nThe Dhcp relay behaves differently in the API and as such it doesn't have a create and only an update and delete.\nThe delete function will remove the whole relay and all of its information. If you do not wish to do this and only\nremove interfaces from the DHCP relay, then you must run an update instead. \n\nRead:\n```\napi := dhcp.NewGetAll(edgeId)\nnsxclient.Do(api)\n```\n\nUpdate:\n```\napi := dhcprelay.NewUpdate(dhcpIpAddress, edgeId, relayAgentslist)\nnsxclient.Do(api)\n```\n\nDelete:\n```\napi := dhcprelay.NewDelete(edgeId)\nnsxclient.Do(api)\n```\n\n### Security Tag\n\nSecurity tag resource. This resource will call the security tag api within NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/securitytag\n```\n\nCreate:\n```\napi := securitytag.NewCreate(name, desc)\nnsxclient.Do(api)\n```\n\nRead:\n```\napi := securitytag.NewGetAll()\nnsxclient.Do(api)\n```\n\nUpdate:\n```\nNot yet implemented\n```\n\nDelete:\n```\napi := securitytag.NewDelete(securitytagID)\nnsxclient.Do(api)\n```\n\nDetach:\n```\napi := securitytag.NewDetach(securityTagID, vmID)\nnsxclient.Do(api)\n```\n\nAttach: \n```\napi := securitytag.NewAttach(securityTagID, vmID)\nnsxclient.Do(api)\n```\n\n\n### Service\n\nService resource. This resource will call the service api with NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/service\n```\n\nCreate:\n```\napi := service.NewCreate(scopeID, name, desc, proto, ports)\nnsxclient.Do(api)\n```\n\nRead:\n```\napi := service.NewGetAll(scopeID)\nnsxclient.Do(api)\n```\n\nUpdate:\n```\nNot yet implemented\n```\n\nDelete:\n```\napi := service.NewDelete(serviceID)\nnsxclient.Do(api)\n```\n\n\n### Security Group\n\nSecurity Group resource. This resource will call the security group api with NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/securitygroup\n```\n\nCreate:\n```\napi := securitygroup.NewCreate(scopeID, name, setOperator, criteriaOperator, criteriaKey, criteriaValue, criteria)\nnsxclient.Do(api)\n```\n\nRead:\n```\napi := securitygroup.NewGetAll(scopeID)\nnsxclient.Do(api)\n```\n\nUpdate:\n```\nNot yet implemented\n```\n\nDelete:\n```\napi := securitygroup.NewDelete(serviceID)\nnsxclient.Do(api)\n```\n\n\n### Security Policy\nSecurity Policy resource. This resource will call the security policy with NSX.\nImport the following class:\n```\ngithub.com/sky-uk/gonsx/api/securitypolicy\n```\n\nCreate:\n```\napi := securitypolicy.NewCreate(name, precendence, desc, securityGroupsIDs, actions)\nnsxclient.Do(api)\n```\n\nRead:\n```\napi := securitypolicy.NewGetAll()\nnsxclient.Do(api)\n```\n\nUpdate:\n```\nNot yet implemented\n```\n\nDelete:\n```\napi := securitypolicy.NewDelete(securityPolicyID, force)\nnsxclient.Do(api)\n```\n\nAddOutboundFirewall:\n```\nsecurityPolicyToModify := getAllAPI.GetResponse().FilterByName(securityPolicyName)\n\n// we will use a help function to add a firewall rule.\nsecurityPolicyToModify.AddOutboundFirewallAction(\n\tfirewallName,\n\taction,\n\tdirection,\n\tsecGroupObjectIDs,\n\tserviceIDs,\n)\n\nupdateAPI := securitypolicy.NewUpdate(securityPolicyToModify.ObjectID, securityPolicyToModify)\nnsxclient.Do(updateAPI)\n```\n\nRemoveFirewall:\n```\nsecurityPolicyToModify := getAllAPI.GetResponse().FilterByName(securityPolicyName)\n\nsecurityPolicyToModify.RemoveFirewallActionByName(firewallName)\n\nupdateAPI := securitypolicy.NewUpdate(securityPolicyToModify.ObjectID, securityPolicyToModify)\nnsxclient.Do(updateAPI)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsky-uk%2Fgonsx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsky-uk%2Fgonsx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsky-uk%2Fgonsx/lists"}