apiUri = $vcenterModel->host; $this->username = $vcenterModel->user; $this->password = SignRSA::DecryptFunc($vcenterModel->password); $response = Http::withoutVerifying() ->withBasicAuth($this->username, $this->password) ->post("https://{$this->apiUri}/rest/com/vmware/cis/session", []); if ($response->successful()) { $json = $response->json(); if (isset($json['value'])) { $this->token = $json['value']; $vcenterModel->update(['token' => $this->token]); return $this->token; } $body = $response->body(); if (!empty($body)) { $this->token = $body; $vcenterModel->update(['token' => $this->token]); return $this->token; } } return false; } public function checkApiExits(): bool { $response = Http::withoutVerifying() ->withHeaders([ 'vmware-api-session-id' => $this->token ]) ->get("https://$this->apiUri/rest/com/vmware/content/library")->json(); if (isset($response['type'])) { return false; } return true; } public function getUsername(): string { return $this->username; } public function getPassword(): string { return $this->password; } }