marksull / fmcapi

A Python package designed to help users of Cisco's FMC interface with its API.
BSD 3-Clause "New" or "Revised" License
81 stars 57 forks source link

Access Rule Comments #83

Closed Td3v closed 2 years ago

Td3v commented 4 years ago

I would like the ability to easily add/append "comments" to the access rules for each rule change. If this functionality is available, I'm not sure how to use it at the moment.

https://github.com/daxm/fmcapi/blob/master/fmcapi/api_objects/policy_services/accessrules.py

image

image

daxm commented 4 years ago

I know what you mean!  I'd like that too.  Is this something you would be willing to work on?  I can put it on the list but there are several other requests on said list.

On 10/7/20 11:44 AM, Td3v wrote:

I would like the ability to easily add/append "comments" to the access rules for each rule change. If this functionality is available, I'm not sure how to use it at the moment.

https://github.com/daxm/fmcapi/blob/master/fmcapi/api_objects/policy_services/accessrules.py

image https://user-images.githubusercontent.com/31051420/95367447-65276b00-089a-11eb-91e1-c245518ffc82.png

image https://user-images.githubusercontent.com/31051420/95367624-9738cd00-089a-11eb-804a-70641a9717b5.png

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/daxm/fmcapi/issues/83, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZOMZZI3ZXLYPVB66KWLH3SJSSHBANCNFSM4SHWONHA.

daxm commented 4 years ago

Ben was kind enough to build the ACL rule comment feature for you! Check it out in 20201014.0 release.

Td3v commented 4 years ago

Awesome! I'll try to test it out today and get back to you. You guys are awesome with how quickly the updates are coming through.

daxm commented 3 years ago

Any report on success/failure of this feature?

marksull commented 3 years ago

Any report on success/failure of this feature?

Coincidently we just started using this feature and hit an issue when the comments were passed in via kwargs. I've submitted another pull request to resolve this.

daxm commented 3 years ago

Release 20201103.0 has the bug fix. Try it out and let me know if this issue is resolved. Thanks!

marksull commented 3 years ago

Release 20201103.0 has the bug fix. Try it out and let me know if this issue is resolved. Thanks

Worked well for me....

import pkg_resources
print(f"FMCAPI Version: {pkg_resources.get_distribution('fmcapi').version}")

acp = AccessPolicies(fmc=fmc_session, name="mark-test")
acp.post()

# New comments added using method
rule = AccessRules(fmc=fmc_session, acp_name=acp.name)
rule.action = "ALLOW"
rule.name = "rule-1"
rule.new_comments(action="add", value="rule-1 comment-1")
rule.post()

# New comments added using kwargs
rule = AccessRules(fmc=fmc_session)
rule.post(
    acp_name=acp.name, action="ALLOW", name="rule-2", newComments=["rule-2 comment-1"]
)

for name in ["rule-1", "rule-2"]:
    rule = AccessRules(fmc=fmc_session, acp_name=acp.name).get(name=name)
    print(rule["commentHistoryList"])

Output

FMCAPI Version: 20201103.0
[{'user': {'name': 'xxx, 'type': 'User'}, 'comment': 'rule-1 comment-1', 'date': '2020-11-03T10:52:47.000+0000'}]
[{'user': {'name': 'xxx', 'type': 'User'}, 'comment': 'rule-2 comment-1', 'date': '2020-11-03T10:52:51.000+0000'}]