cwmiller / broadworks-connector

Simple library for connecting to BroadWorks OCI-P API
MIT License
8 stars 5 forks source link

Unable to set Device Identify Credentials #64

Closed crawc closed 3 years ago

crawc commented 3 years ago

I'm not sure if this is an issue or if I'm just doing this completely wrong but after trying everything I could think of I decided to post this with my fingers crossed. I'm trying to use the GroupAccessDeviceModifyRequest22 request to set a given device's username and password.

Thank you for any assistance that can be provided.

Here is the code: $setCreds = (new GroupAccessDeviceModifyRequest22()) ->setServiceProviderId("LAB_Enterprise") ->setGroupId("LAB_1") ->setDeviceName("testPhone") ->setUseCustomUserNamePassword(true) ->setAccessDeviceCredentials([ (new DeviceManagementUserNamePassword16()) ->setUserName("testDeviceUsername") ->setPassword("testDevicePassword") ]);

try {
    $resultsCreds = $ocip->GroupAccessDeviceModifyRequest22($setCreds);
    print_r($resultsCreds);
} catch (ErrorResponseException $e) {
    echo 'Server Error: ' . $e->getMessage() . PHP_EOL;
    exit();
} catch (ValidationException $e) {
    echo 'Validation Error: ' . $e->getMessage() . PHP_EOL;
    exit();
}

Here is the error: PHP Fatal error: Uncaught TypeError: Argument 1 passed to CWM\BroadWorksConnector\Ocip\Models\GroupAccessDeviceModifyRequest22::setAccessDeviceCredentials() must be an instance of CWM\BroadWorksConnector\Ocip\Models\DeviceManagementUserNamePassword16 or null, array given

TwinMist commented 3 years ago

This works for me.

$request = (new GroupAccessDeviceModifyRequest14()) ->setserviceProviderId($serviceProviderId) ->setgroupId($groupId) ->setdeviceName($deviceName) ->setuseCustomUserNamePassword($useCustomUserNamePassword) ->setaccessDeviceCredentials ( (new DeviceManagementUserNamePassword16()) ->setuserName($credentials) ->setpassword($credentials));

crawc commented 3 years ago

Thank you! It looks like I had some brackets that were causing it not to work correctly. This is now working. The same works with both GroupAccessDeviceModifyRequest14 and GroupAccessDeviceModifyRequest22 without issue.

$setCreds = (new GroupAccessDeviceModifyRequest22())
    ->setserviceProviderId("LAB_Enterprise")
    ->setGroupId("LAB_1")
    ->setDeviceName("testPhone")
    ->setUseCustomUserNamePassword(true)
    ->setAccessDeviceCredentials(
        (new DeviceManagementUserNamePassword16())
            ->setUserName("testDeviceUsername")
            ->setPassword("testDevicePassword")
        );

try {
    $resultsCreds = $ocip->GroupAccessDeviceModifyRequest22($setCreds);
    print_r($resultsCreds);

} catch (ErrorResponseException $e) {
    echo 'Server Error: ' . $e->getMessage() . PHP_EOL;
    exit();
} catch (ValidationException $e) {
    echo 'Validation Error: ' . $e->getMessage() . PHP_EOL;
    exit();
}
TwinMist commented 3 years ago

no problem did you know you can get the result like $response = $ocip->call($request);

crawc commented 3 years ago

No, but thanks for the tip, got any other ;)?

Do you know if there is any way to get the currently GET the AccessDeviceCredentials?

TwinMist commented 3 years ago

got loads!!! you can only get the UserName from the GroupAccessDeviceGetResponse, for the password guess you could read the device xml template file which i do to get passwords.

crawc commented 3 years ago

To get the currently set device password are you saying to check the configurationFileName or repositoryUrl XML files on the AS or PS servers directly or from the OCI API?

We are trying to not have to set a new device password if possible. This is for a zero-touch provisioning server.

TwinMist commented 3 years ago

hi Check the device template file on the ps

crawc commented 3 years ago

Hello, I checked and it looks to be the template file, I need the device username and password to download the repository file via the XSP server.

TwinMist commented 3 years ago

yes you will, is it a standard login same for all device. send me your email if easier to chat

TwinMist commented 3 years ago

Got it

On Wed, 21 Jul 2021, 17:53 crawc, @.***> wrote:

Sure its: crawsol AT gmail.com

Let me know once you have it so I can remove this. Thanks again!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/cwmiller/broadworks-connector/issues/64#issuecomment-884340074, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2EPS4TW27B5C6VK26PUETTY33SDANCNFSM5AUE7ZDA .

crawc commented 3 years ago

Closing issue.