Skip to content

Commit

Permalink
feat:
Browse files Browse the repository at this point in the history
q
  • Loading branch information
grokify committed Oct 4, 2023
1 parent 8e3f8d3 commit 6c74f11
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 17 deletions.
96 changes: 79 additions & 17 deletions connection.go
Original file line number Diff line number Diff line change
@@ -1,29 +1,91 @@
package saviyntconnectors

import "sort"

type ConnectionMap map[string]Connection

type Connection struct {
ConnectionDescription string `json:"connectiondescription"`
ConnectionName string `json:"connectionname"`
Connectorms bool `json:"connectorms"`
ConnectorType *string `json:"connectorType"`
CredentialChangeConfig *string `json:"credentialChangeConfig"`
ExternalConnectionType string `json:"externalconnectiontype"`
MSConnectorVersion *string `json:"msconnectorversion"`
SSLCertificate *string `json:"sslCertificate"`
SSLCertificateID *string `json:"sslCertificateId"`
Status int `json:"status"`
StatusForEnableDisable int `json:"statusForEnableDisable"`
TemplateMandatoryData string `json:"templateMandatoryData"`
TemplateName string `json:"templateName"`
VaultConfig *string `json:"vaultConfig"`
VaultCredentialConnection *string `json:"vaultCredentialConnection"`
ExternalAttrs []ExternalAttr `json:"EXTERNAL_ATTR"`
ConnectionDescription string `json:"connectiondescription"`
ConnectionName string `json:"connectionname"`
Connectorms bool `json:"connectorms"`
ConnectorType *string `json:"connectorType"`
CredentialChangeConfig *string `json:"credentialChangeConfig"`
ExternalConnectionType string `json:"externalconnectiontype"`
MSConnectorVersion *string `json:"msconnectorversion"`
SSLCertificate *string `json:"sslCertificate"`
SSLCertificateID *string `json:"sslCertificateId"`
Status int `json:"status"`
StatusForEnableDisable int `json:"statusForEnableDisable"`
TemplateMandatoryData string `json:"templateMandatoryData"`
TemplateName string `json:"templateName"`
VaultConfig *string `json:"vaultConfig"`
VaultCredentialConnection *string `json:"vaultCredentialConnection"`
ExternalAttrs ExternalAttrs `json:"EXTERNAL_ATTR"`
}

type ExternalAttrs []ExternalAttr

func (e ExternalAttrs) Inflate() ExternalAttrs {
inflated := ExternalAttrs{}
namesMap := map[string]int{}
for _, ea := range e {
inflated = append(inflated, ea)
namesMap[ea.AttributeName]++
}
allNames := ExternalAttributeNames()
for _, extraName := range allNames {
if _, ok := namesMap[extraName]; !ok {
inflated = append(inflated, ExternalAttr{
AttributeName: extraName,
})
}
}
return inflated
}

func (e ExternalAttrs) Names(sortNames bool) []string {
var names []string
for _, ea := range e {
names = append(names, ea.AttributeName)
}
if sortNames {
sort.Strings(names)
}
return names
}

type ExternalAttr struct {
AttributeName string `json:"attributename"`
CredentialSaveStatus bool `json:"credentialSaveStatus"`
Encryptedattributevalue string `json:"encryptedattributevalue"`
EncryptedAttributeValue string `json:"encryptedattributevalue"`
Formdata *string `json:"formdata"`
}

func ExternalAttributeNames() []string {
return []string{
"AddAccessJSON",
"AddFFIDAccessJSON",
"ChangePassJSON",
"ConfigJSON",
"ConnectionJSON",
"CreateAccountJSON",
"CreateTicketJSON",
"DisableAccountJSON",
"EnableAccountJSON",
"ImportAccountEntJSON",
"ImportUserJSON",
"PasswdPolicyJSON",
"RemoveAccessJSON",
"RemoveAccountJSON",
"RemoveFFIDAccessJSON",
"SendOtpJSON",
"TicketStatusJSON",
"UpdateAccountJSON",
"UpdateUserJSON",
"ValidateOtpJSON",
"ENDPOINTS_FILTER",
"MODIFYUSERDATAJSON",
"PAM_CONFIG",
"STATUS_THRESHOLD_CONFIG",
}
}
45 changes: 45 additions & 0 deletions ringcentral/ringcentral.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,50 @@ func ObjectSummary() saviyntconnectors.ObjectSummary {
TransferUsers: "0",
},
}
}

func Connection() saviyntconnectors.ConnectionMap {
extAttrs := saviyntconnectors.ExternalAttrs{
{
AttributeName: "ConnectionJSON",
EncryptedAttributeValue: "F094T0v6WHOpHcSzOqzN/G0EOXMVamwB8u2E9ttQNJNH/uqcgtvsw9t4/JqDJeCqQsdihkRCJpZn9bLHAwEt1khfhJ57qiyRImlt7xYaAw8R3gKwlb5P5Pls/NpXrJCJEOIIKBqZmra7c/8I5jIPpwDMQA72hCb7+NjiIMbsrgAdpeFAoP6/433ACaPmQ86SoWaZO2mA0+TKvsTYHtVp6K9yHo/Z1fKuWU+vJl7Lxa32+Kz/u5eUMFbVq8zOMQr90/02BPk1s1lKjq1MxsJ7FL18zFq3rzaC2M0icHhhGcz804Dz7klQFnwn58kFix0ThAV8SuLnAi8W4nCINNWsbdbnJomLGY2IQzoogWU7i8lvx1a5VS38MNppSyGQaXnHgO7sdnGs7JHDenJ1Hh25Dz8C1uMfEs7aonK83W+hdAQIi2usFnc5i5z1+9pmhbhkkfQAIuEECtSBCuDyIiOVkpthljbmF+IiIIyYgfSfnv91wCLSwL6NUH/kqcuI870Rwc/WV6bFGGJT3NYaPlf1gvNAfLfBkfrV/eGDAnZX33jK9+vfJDTfYnOgjVztRS21Tr1w3FJNogJjZuRclkjk0ZjoUHZOu9cpoah88ByFN6idLJN51r4kSAMoz+RxnsdfHSuuZKsk3AJmpldcy4QLKV+JnLVy24OSJZC9t4tTfWdKhJUibFN0A3qHMM+o3xhehOeaKooW1q3+FdbZLieB4Q==",
},
{
AttributeName: "CreateAccountJSON",
EncryptedAttributeValue: "{\r\n \"accountIdPath\": \"call1.message.id\",\r\n \"responseColsToPropsMap\": {\r\n \"name\": \"call1.message.userName~#~char\"\r\n },\r\n \"call\": [\r\n {\r\n \"name\": \"call1\",\r\n \"connection\": \"acctAuth\",\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users\",\r\n \"httpMethod\": \"POST\",\r\n \"httpParams\": \"{\\\"active\\\":true,\\\"name\\\":{\\\"familyName\\\":\\\"${user.lastname}\\\",\\\"givenName\\\":\\\"${user.firstname}\\\"},\\\"emails\\\":[{\\\"type\\\":\\\"work\\\",\\\"value\\\":\\\"${user.email}\\\"}],\\\"schemas\\\":[\\\"urn:ietf:params:scim:schemas:core:2.0:User\\\"],\\\"userName\\\":\\\"${user.username}\\\"}\",\r\n \"httpHeaders\": {\r\n \"authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"successResponses\": {\r\n \"statusCode\": [\r\n 200,\r\n 201\r\n ]\r\n }\r\n }\r\n ]\r\n}",
},
{
AttributeName: "DisableAccountJSON",
EncryptedAttributeValue: "{\r\n \"call\": [\r\n {\r\n \"name\": \"call1\",\r\n \"connection\": \"acctAuth\",\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users/${account.accountID}\",\r\n \"httpMethod\": \"PATCH\",\r\n \"httpParams\": \"{\\\"schemas\\\":[\\\"urn:ietf:params:scim:api:messages:2.0:PatchOp\\\"],\\\"Operations\\\":[{\\\"op\\\":\\\"replace\\\",\\\"path\\\":\\\"active\\\",\\\"value\\\":\\\"false\\\"}]}\",\r\n \"httpHeaders\": {\r\n \"authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"successResponses\": {\r\n \"statusCode\": [\r\n 200,\r\n 201\r\n ]\r\n }\r\n }\r\n ]\r\n}",
},
{
AttributeName: "EnableAccountJSON",
EncryptedAttributeValue: "{\r\n \"call\": [\r\n {\r\n \"name\": \"call1\",\r\n \"connection\": \"acctAuth\",\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users/${account.accountID}\",\r\n \"httpMethod\": \"PATCH\",\r\n \"httpParams\": \"{\\\"schemas\\\":[\\\"urn:ietf:params:scim:api:messages:2.0:PatchOp\\\"],\\\"Operations\\\":[{\\\"op\\\":\\\"replace\\\",\\\"path\\\":\\\"active\\\",\\\"value\\\":\\\"true\\\"}]}\",\r\n \"httpHeaders\": {\r\n \"authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"successResponses\": {\r\n \"statusCode\": [\r\n 200,\r\n 201\r\n ]\r\n }\r\n }\r\n ]\r\n}",
},
{
AttributeName: "ImportAccountEntJSON",
EncryptedAttributeValue: "{\r\n \"accountParams\": {\r\n \"connection\": \"acctAuth\",\r\n \"processingType\": \"SequentialAndIterative\",\r\n \"statusAndThresholdConfig\": {\r\n \"statusColumn\": \"customproperty10\",\r\n \"active\": [\r\n \"true\"\r\n ],\r\n \"deleteLinks\": true,\r\n \"accountThresholdValue\": 1000,\r\n \"correlateInactiveAccounts\": false,\r\n \"inactivateAccountsNotInFile\": true,\r\n \"deleteAccEntForActiveAccounts\": true\r\n },\r\n \"call\": {\r\n \"call1\": {\r\n \"callOrder\": 0,\r\n \"stageNumber\": 0,\r\n \"http\": {\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users?filter=&startIndex=1&count=3\",\r\n \"httpHeaders\": {\r\n \"authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"httpMethod\": \"GET\"\r\n },\r\n \"listField\": \"Resources\",\r\n \"keyField\": \"accountID\",\r\n \"colsToPropsMap\": {\r\n \"accountID\": \"id~#~char\",\r\n \"name\": \"userName~#~char\",\r\n \"displayName\": \"emails.value~#~char\",\r\n \"customproperty1\": \"name.familyName~#~char\",\r\n \"customproperty2\": \"name.givenName~#~char\",\r\n \"customproperty3\": \"meta.resourceType~#~char\",\r\n \"customproperty4\": \"meta.created~#~char\",\r\n \"customproperty5\": \"meta.lastModified~#~char\",\r\n \"customproperty6\": \"meta.location~#~char\",\r\n \"customproperty7\": \"schemas~#~char\",\r\n \"customproperty8\": \"emails.type~#~char\",\r\n \"customproperty9\": \"emails.value~#~char\",\r\n \"customproperty10\": \"active~#~char\",\r\n \"customproperty11\": \"addresses.streetAddress~#~char\",\r\n \"customproperty12\": \"addresses.locality~#~char\",\r\n \"customproperty13\": \"addresses.region~#~char\",\r\n \"customproperty14\": \"addresses.postalCode~#~char\",\r\n \"customproperty15\": \"addresses.country~#~char\",\r\n \"customproperty16\": \"addresses.type~#~char\",\r\n \"customproperty17\": \"phoneNumbers.value~#~char\",\r\n \"customproperty18\": \"phoneNumbers.type~#~char\"\r\n }\r\n }\r\n },\r\n \"page\": {\r\n \"pageSizeParam\": \"count\",\r\n \"pageSize\": 20,\r\n \"pageRecordCount\": \"itemsPerPage\",\r\n \"pageNumberParam\": \"page\",\r\n \"totalCountPath\": \"completeResponseMap.meta.totalResults\",\r\n \"firstPageNumber\": 1\r\n }\r\n }\r\n}",
},
{
AttributeName: "RemoveAccountJSON",
EncryptedAttributeValue: "{\r\n \"call\": [\r\n {\r\n \"name\": \"call1\",\r\n \"connection\": \"acctAuth\",\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users/${account.accountID}\",\r\n \"httpMethod\": \"DELETE\",\r\n \"httpHeaders\": {\r\n \"Authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"successResponses\": {\r\n \"statusCode\": [\r\n 200,\r\n 201,\r\n 204\r\n ]\r\n }\r\n }\r\n ]\r\n}",
},
{
AttributeName: "UpdateAccountJSON",
EncryptedAttributeValue: "{\r\n \"call\": [\r\n {\r\n \"name\": \"call1\",\r\n \"connection\": \"acctAuth\",\r\n \"url\": \"https://platform.devtest.ringcentral.com/scim/v2/Users/${account.accountID}\",\r\n \"httpMethod\": \"PUT\",\r\n \"httpParams\": \"{\\\"active\\\":true,\\\"name\\\":{\\\"familyName\\\":\\\"${user.lastname}\\\",\\\"givenName\\\":\\\"${user.firstname}\\\"},\\\"emails\\\":[{\\\"type\\\":\\\"work\\\",\\\"value\\\":\\\"${user.email}\\\"}],\\\"schemas\\\":[\\\"urn:ietf:params:scim:schemas:core:2.0:User\\\"],\\\"userName\\\":\\\"${user.username}\\\"}\",\r\n \"httpHeaders\": {\r\n \"authorization\": \"${access_token}\",\r\n \"Accept\": \"application/json\"\r\n },\r\n \"httpContentType\": \"application/json\",\r\n \"successResponses\": {\r\n \"statusCode\": [\r\n 200,\r\n 201\r\n ]\r\n }\r\n }\r\n ]\r\n}",
},
}
return saviyntconnectors.ConnectionMap{
"RingCentral": saviyntconnectors.Connection{
ConnectionDescription: "RingCentral",
ConnectionName: "RingCentral",
Connectorms: false,
ExternalConnectionType: "REST",
Status: 1,
StatusForEnableDisable: 1,
TemplateMandatoryData: "DwitEostW3Z60d/A6Ua4sw==",
TemplateName: "Ringcentral",
ExternalAttrs: extAttrs.Inflate(),
},
}
}

0 comments on commit 6c74f11

Please sign in to comment.